mindspore.ops.Pdist

class mindspore.ops.Pdist(p=2.0)[source]

Computes the p-norm distance between each pair of row vectors in the input.

Refer to mindspore.ops.pdist() for more details.

Parameters

p (float, optional) – The order of norm distance, \(p∈[0, ∞)\). Default: 2.0 .

Inputs:
  • x (Tensor) - Input tensor of shape \((*B, N, M)\). \(*B\) is batch size, one-dim or multi-dim. Supported dtypes: float16, float32 or float64.

Outputs:

Tensor, has the same dtype as x.

Supported Platforms:

GPU CPU

Examples

>>> from mindspore import Tensor, ops
>>> import numpy as np
>>> x = Tensor(np.array([[1.0, 1.0], [2.0, 2.0], [3.0, 3.0]]).astype(np.float32))
>>> op = ops.Pdist(p=2.0)
>>> y = op(x)
>>> print(y)
[1.4142135 2.828427  1.4142135]