mindspore.ops.EuclideanNorm

class mindspore.ops.EuclideanNorm(keep_dims=False)[source]

Computes the euclidean norm of elements across dimensions of a tensor. Reduces input along the dimensions given in axis.

Parameters

keep_dims (bool, optional) – If true, the reduceed dimensions are retained with length 1. If false, don’t keep these dimensions. Default: False.

Inputs:
  • x (Tensor) - The input tensor. Must be one of the following types :float16, float32, float64, int8, int16, int32, int64, complex64, complex128, uint8, uint16, uint32, uint64. The tensor to reduce.

  • axes (Tensor) - The dimensions to reduce. Must be one of the following types: int32, int64. Must be in the range [-rank(x), rank(x)).

Outputs:

Tensor, has the same type as the ‘x’.

Raises
Supported Platforms:

GPU

Examples

>>> x = Tensor(np.array([[3, 5], [4, 12]])).astype(np.int32)
>>> axes = Tensor([0])
>>> op = ops.EuclideanNorm(keep_dims=True)
>>> output = op(x, axes)
>>> print(output)
[[5 13]]