mindspore.ops.renorm
- mindspore.ops.renorm(input, p, axis, maxnorm)[源代码]
返回一个tensor,其中按指定维度计算每个子tensor的 p 范数小于等于 maxnorm。如果大于,返回子tensor上的原始值除以子tensor的 p 范数,然后再乘以 maxnorm 。
- 参数:
input (Tensor) - 输入tensor。
p (int) - 范数计算的幂。
axis (int) - 指定计算轴。
maxnorm (float32) - 指定的最大范数。
- 返回:
Tensor
- 支持平台:
Ascend
GPU
CPU
样例:
>>> import mindspore >>> input = mindspore.tensor([[1., 1, 1], [2, 2, 2], [3, 3, 3]]) >>> output = mindspore.ops.norm(input, 1, 1) >>> print(output) [3. 6. 9.] >>> output = mindspore.ops.renorm(input, 1, 0, 6.) >>> print(output) [[1. 1. 1.] [2. 2. 2.] [2. 2. 2.]]