mindspore.ops.dist

mindspore.ops.dist(input, other, p=2)[source]

Computes batched the \(p\)-norm distance between each pair of the two collections of row vectors.

Note

Since only normalization for integer \(p\)-normal form is supported in MindSpore, a type error will be raised if \(p\) is not an integer.

Parameters
  • input (Tensor) – The first input tensor. The dtype must be float16 or float32.

  • other (Tensor) – The second input tensor. The dtype must be float16 or float32.

  • p (int, optional) – The order of norm. p is greater than or equal to 0. Default: 2.

Returns

Tensor, has the same dtype as input, which shape is \((1)\).

Raises
  • TypeError – If input or other is not a Tensor.

  • TypeError – If dtype of input or other is neither float16 nor float32.

  • TypeError – If p is not a non-negative integer.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor([[[1.0, 1.0], [2.0, 2.0]]])
>>> input_y = Tensor([[[3.0, 3.0], [3.0, 3.0]]])
>>> out = ops.dist(input_x, input_y)
>>> print(out.asnumpy())
3.1622777