NormalizedGaussianAffinity#
- class torchdr.NormalizedGaussianAffinity(sigma: float = 1.0, metric: str = 'sqeuclidean', zero_diag: bool = True, device: str = 'auto', backend: str | None = None, verbose: bool = False, normalization_dim: int | Tuple[int] = (0, 1))[source]#
Bases:
LogAffinity
Compute the Gaussian affinity matrix which can be normalized along a dimension.
The algorithm computes \(\exp( - \mathbf{C} / \sigma)\) where \(\mathbf{C}\) is the pairwise distance matrix and \(\sigma\) is the bandwidth parameter. The affinity can be normalized according to the specified normalization dimension.
- Parameters:
sigma (float, optional) – Bandwidth parameter.
metric (str, optional) – Metric to use for pairwise distances computation.
zero_diag (bool, optional) – Whether to set the diagonal of the affinity matrix to zero.
device (str, optional) – Device to use for computations.
backend ({"keops", "faiss", None}, optional) – Which backend to use for handling sparsity and memory efficiency. Default is None.
verbose (bool, optional) – Verbosity.
normalization_dim (int or Tuple[int], optional) – Dimension along which to normalize the affinity matrix. Default is (0, 1)
Examples using NormalizedGaussianAffinity
:#
![](../_images/sphx_glr_demo_ea_adaptivity_thumb.png)
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