335 Star 1.5K Fork 862

MindSpore / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
std_mean.md 2.86 KB
一键复制 编辑 原始数据 按行查看 历史
luojianing 提交于 2023-07-21 15:16 . replace target=blank

Function Differences with torch.std_mean

View Source On Gitee

torch.std_mean

torch.std_mean(input, dim, unbiased=True, keepdim=False, *, out=None)

For more information, see torch.std_mean.

mindspore.ops.std_mean

mindspore.ops.std_mean(input, axis=None, ddof=0, keepdims=False)

For more information, see mindspore.ops.std_mean.

Differences

PyTorch: Output the standard deviation and mean value of the Tensor in each dimension, or the standard deviation and mean value of the specified dimension according to dim. If unbiased is True, use Bessel for correction; if False, use bias estimation to calculate the standard deviation. keepdim controls whether the output and input dimensions are the same.

MindSpore: Output the standard deviation and mean value of the Tensor in each dimension, or the standard deviation and mean value of the specified dimension according to axis. If ddof is a boolean, it has the same effect as unbiased; if ddof is an integer, the divisor used in the calculation is N-ddof, where N denotes the number of elements. keepdim controls whether the output and the input have the same dimensionality.

Categories Subcategories PyTorch MindSpore Differences
Parameters Parameter 1 input input Same function, different parameter names
Parameter 2 dim axis Same function, different parameter names
Parameter 3 unbiased ddof ddof is the same as unbiased when it is a boolean value
Parameter 4 keepdim keepdims Same function, different parameter names
Parameter 5 out - MindSpore does not have this parameter

Code Example

# PyTorch
import torch

input = torch.tensor([[[9, 7, 4, -10],
                       [-9, -2, 1, -2]]], dtype=torch.float32)
print(torch.std_mean(input, dim=2, unbiased=True, keepdim=True))
# (tensor([[[8.5829],
#          [4.2426]]]), tensor([[[ 2.5000],
#          [-3.0000]]]))

# MindSpore
import mindspore as ms

input = ms.Tensor([[[9, 7, 4, -10],
                    [-9, -2, 1, -2]]], ms.float32)
print(ms.ops.std_mean(input, axis=2, ddof=True, keepdims=True))
# (Tensor(shape=[1, 2, 1], dtype=Float32, value=
# [[[ 8.58292866e+00],
#   [ 4.24264050e+00]]]), Tensor(shape=[1, 2, 1], dtype=Float32, value=
# [[[ 2.50000000e+00],
#   [-3.00000000e+00]]]))
1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r2.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891