Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

torch_pdist

Pdist


Description

Pdist

Usage

torch_pdist(self, p = 2L)

Arguments

self

NA input tensor of shape N \times M.

p

NA p value for the p-norm distance to calculate between each vector pair \in [0, ∞].

pdist(input, p=2) -> Tensor

Computes the p-norm distance between every pair of row vectors in the input. This is identical to the upper triangular portion, excluding the diagonal, of torch_norm(input[:, NULL] - input, dim=2, p=p). This function will be faster if the rows are contiguous.

If input has shape N \times M then the output will have shape \frac{1}{2} N (N - 1).

This function is equivalent to scipy.spatial.distance.pdist(input, 'minkowski', p=p) if p \in (0, ∞). When p = 0 it is equivalent to scipy.spatial.distance.pdist(input, 'hamming') * M. When p = ∞, the closest scipy function is scipy.spatial.distance.pdist(xn, lambda x, y: np.abs(x - y).max()).


torch

Tensors and Neural Networks with 'GPU' Acceleration

v0.3.0
MIT + file LICENSE
Authors
Daniel Falbel [aut, cre, cph], Javier Luraschi [aut], Dmitriy Selivanov [ctb], Athos Damiani [ctb], Christophe Regouby [ctb], Krzysztof Joachimiak [ctb], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.