mindspore.ops.renorm

View Source On Gitee
mindspore.ops.renorm(input, p, axis, maxnorm)[source]

Returns a tensor where each subtensor along the specified dimension is renormalized such that its p norm is less than or equal to maxnorm. If the p norm exceeds maxnorm, return the values that are obtained by dividing the original values of the subtensor by its p norm and then multiplying by maxnorm.

Parameters
  • input (Tensor) – The input tensor.

  • p (int) – The power of norm calculation.

  • axis (int) – Specify the axis for computation.

  • maxnorm (float32) – The max norm specified.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

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