ScalarProductAffinity#

class torchdr.ScalarProductAffinity(device: str = 'auto', backend: str | None = None, verbose: bool = False)[source]#

Bases: UnnormalizedAffinity

Compute the scalar product affinity matrix.

Its expression is given by \(\mathbf{X} \mathbf{X}^\top\) where \(\mathbf{X} = (\mathbf{x}_1, \ldots, \mathbf{x}_n)^\top\) with each row vector \(\mathbf{x}_i\) corresponding to the i-th data sample.

Parameters:
  • device (str, optional) – Device to use for computations. Default is “cuda”.

  • 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 ScalarProductAffinity:#

PCA via SVD and via AffinityMatcher

PCA via SVD and via AffinityMatcher