mindspore.ops.LpNorm

class mindspore.ops.LpNorm(axis, p=2, keep_dims=False, epsilon=1e-12)[源代码]

Returns the matrix norm or vector norm of a given tensor.

\[output = sum(abs(input)**p)**(1/p)\]

Refer to mindspore.ops.norm() for more detail.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]]).astype(np.float32))
>>> op = ops.LpNorm(axis=[0, 1], p=2, keep_dims=False)
>>> output = op(input_x)
>>> print(output)
[ 9.165152 10.954452]