ScalarProductAffinity#
- class torchdr.ScalarProductAffinity(device: str = 'auto', backend: str | None = None, verbose: bool = False, compile: bool = False, _pre_processed: bool = False)[source]#
Bases:
NegativeCostAffinity
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 “auto”.
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.
compile (bool, optional) – Whether to compile the formula.
_pre_processed (bool, optional) – If True, assumes inputs are already torch tensors on the correct device and skips the to_torch conversion. Default is False.