linear_distance#

hypercoil.functional.kernel.linear_distance(X0: Tensor, X1: Tensor | None = None, theta: Tensor | None = None) Tensor[source]#
hypercoil.functional.kernel.linear_distance(X0: BCOO, X1: BCOO | None = None, theta: Tensor | BCOO | None = None) BCOO

Squared Euclidean (L2) distance (or Mahalanobis if theta is set).

Parameters:
X0tensor

A feature tensor.

X1tensor or None

Second feature tensor. If not explicitly provided, the kernel of X with itself is computed.

thetatensor or None

Kernel parameter (generally a representation of a positive definite matrix). If not provided, defaults to identity (an unparameterised kernel). If the last two dimensions are the same size, they are used as a matrix parameter; if they are not, the final axis is instead used as the diagonal of the matrix.

Returns:
Tensor

Distance matrix.