Affinity#
- class torchdr.Affinity(metric: str = 'sqeuclidean', zero_diag: bool = True, device: str = 'auto', backend: str | None = None, verbose: bool = False)[source]#
Bases:
ABC
Base class for affinity matrices.
- Parameters:
metric (str, optional) – The distance metric to use for computing pairwise distances.
zero_diag (bool, optional) – Whether to set the diagonal of the affinity matrix to zero.
device (str, optional) – The device to use for computation. Typically “cuda” for GPU or “cpu” for CPU. If “auto”, uses the device of the input data.
backend ({"keops", "faiss", None}, optional) – Which backend to use for handling sparsity and memory efficiency. Default is None.
verbose (bool, optional) – Verbosity. Default is False.
Examples using Affinity
:#
![](../_images/sphx_glr_demo_ea_adaptivity_thumb.png)
Entropic Affinities can adapt to varying noise levels
Entropic Affinities can adapt to varying noise levels
![](../_images/sphx_glr_demo_ne_methods_affinity_matcher_thumb.png)
Neighbor Embedding on genomics & equivalent affinity matcher formulation
Neighbor Embedding on genomics & equivalent affinity matcher formulation