pairwise_distances

torchdr.pairwise_distances(X: Tensor, Y: Tensor | None = None, metric: str = 'sqeuclidean', keops: bool = False)[source]

Compute pairwise distances matrix between points in two datasets.

Returns the pairwise distance matrix as torch tensor or KeOps lazy tensor (if keops is True).

Parameters:
  • X (torch.Tensor of shape (n_samples, n_features)) – First dataset.

  • Y (torch.Tensor of shape (m_samples, n_features), optional) – Second dataset. If None, Y = X.

  • metric (str, optional) – Metric to use for computing distances. The default is “sqeuclidean”.

  • keops (bool, optional) – If True, uses KeOps for computing the distances.

Returns:

  • C (torch.Tensor or pykeops.torch.LazyTensor (if keops is True))

  • of shape (n_samples, m_samples) – Pairwise distances matrix.