mindspore.ops.LpNorm

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

返回输入Tensor的矩阵范数或向量范数。

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

有关更多详细信息,请参阅: mindspore.ops.norm()

支持平台:

Ascend GPU CPU

样例:

>>> 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]