point_dist#
- iskra.geometry.distances.point_dist(x: Tensor, y: Tensor, ord: int | float | str = 2, keepdim: bool = False) Tensor[SOURCE]#
Computes the distance between batches of vectors x_i and y_i.
Unlike PyTorch’s
torch.cdist, this function works withtorch.functransforms and allows for other norms allowed bytorch.linalg.vector_norm, at the cost of higher memory usage.torch.cdistis recommended if memory usage is important.- Parameters:
x (
Tensor[Float, [Bs, Dim]]) – Batch of Dim-dimensional vectors.y (
Tensor[Float, [Bs, Dim]]) – Batch of Dim-dimensional vectors.ord (int | float | str, optional) – Order of p-norm. follows same convention as PyTorch’s
vector_norm. Defaults to 2.keepdim (bool, optional) – Whether to keep the last dimension after reduction. Defaults to False.
- Raises:
ValueError – Tensors x and y must have the same shape.
- Returns:
(
Tensor[Float, [Bs] | [Bs, 1]]) – Last dimension of output is 1 ifkeepdim=True, otherwise it is removed.