SelfTuningAffinity
- class torchdr.SelfTuningAffinity(K: int = 7, normalization_dim: int | Tuple[int] = (0, 1), metric: str = 'sqeuclidean', zero_diag: bool = True, device: str | None = None, keops: bool = True, verbose: bool = False)[source]
Bases:
LogAffinity
Compute the self-tuning affinity introduced in [22].
The affinity has a sample-wise bandwidth \(\mathbf{\sigma} \in \mathbb{R}^n\).
\[\exp \left( - \frac{C_{ij}}{\sigma_i \sigma_j} \right)\]In the above, \(\mathbf{C}\) is the pairwise distance matrix and \(\sigma_i\) is the distance from the K’th nearest neighbor of data point \(\mathbf{x}_i\).
- Parameters:
K (int, optional) – K-th neirest neighbor .
normalization_dim (int or Tuple[int], optional) – Dimension along which to normalize the affinity matrix.
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.
keops (bool, optional) – Whether to use KeOps for computations.
verbose (bool, optional) – Verbosity. Default is False.
References