Differences with torch.renorm
The following mapping relationships can be found in this file.
PyTorch APIs |
MindSpore APIs |
---|---|
torch.renorm |
mindspore.ops.renorm |
torch.Tensor.renorm |
mindspore.Tensor.renorm |
torch.renorm
torch.renorm(input, p, dim, maxnorm, *, out=None) -> Tensor
For more information, see torch.renorm.
mindspore.ops.renorm
mindspore.ops.renorm(input, p, axis, maxnorm)
For more information, see mindspore.ops.renorm.
Differences
API function of MindSpore is consistent with that of PyTorch.
PyTorch: The data type of parameter p
is float
.
MindSpore: The data type of parameter p
is int
.
Categories |
Subcategories |
PyTorch |
MindSpore |
Differences |
---|---|---|---|---|
Parameters |
Parameter 1 |
input |
input |
- |
Parameter 2 |
p |
p |
The data type supported by PyTorch is |
|
Parameter 3 |
dim |
axis |
Different parameter names |
|
Parameter 4 |
maxnorm |
maxnorm |
- |
|
Parameter 5 |
out |
- |
For details, see General Difference Parameter Table |
Code Example 1
# PyTorch
import torch
x = torch.tensor([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]], dtype=torch.float32)
out = torch.renorm(x, 2.0, 0, 5.0)
print(out.numpy())
# [[0. 1. 2. 3. ]
# [1.7817416 2.2271771 2.6726124 3.1180477]
# [2.0908334 2.3521876 2.6135418 2.874896 ]]
# MindSpore
import mindspore
import mindspore.ops as ops
from mindspore import Tensor
x = Tensor([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]], dtype=mindspore.float32)
out = ops.renorm(x, 2, 0, 5.0)
print(out.numpy())
# [[0. 1. 2. 3. ]
# [1.7817416 2.2271771 2.6726124 3.118048 ]
# [2.0908334 2.3521876 2.6135418 2.874896 ]]