335 Star 1.5K Fork 862

MindSpore / docs

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

Function Differences with torch.hann_window

View Source On Gitee

torch.hann_window

torch.hann_window(
    window_length,
    periodic=True,
    *,
    dtype=None,
    layout=torch.strided,
    device=None,
    requires_grad=False
) -> Tensor

For more information, see torch.hann_window.

mindspore.numpy.hanning

mindspore.numpy.hanning(M) -> Tensor

For more information, see mindspore.numpy.hanning.

Differences

PyTorch: Return the Hanning window with the same size as window_length. The periodic parameter determines whether the returned window will remove the last duplicate value of the symmetric window.

MindSpore: MindSpore API basically implements the same function as PyTorch, but it lacks the parameter periodic, which is equivalent to setting periodic to False.

Categories Subcategories PyTorch MindSpore Difference
Input Single input window_length M Same function, different parameter names
Parameters Parameter 1 periodic - Equivalent to setting periodic to False in MindSpore
Parameter 2 dtype - MindSpore does not have this parameter, and the output dtype is Float32, consistent with the default of the marker
Parameter 3 layout - Not involved
Parameter 4 device - Not involved
Parameter 5 requires_grad - MindSpore does not have this parameter and supports reverse derivation by default

Code Example 1

The periodic parameter in the PyTorch operator determines whether the return window will remove the last repeated value of the symmetric window, while the MindSpore operator lacks the parameter, equivalent to setting periodic to False.

# PyTorch
import torch

torch_output = torch.hann_window(12, periodic=False)
print(torch_output.numpy())
# [0.         0.07937324 0.29229248 0.57115734 0.82743037 0.97974646
#  0.9797465  0.8274305  0.5711575  0.29229265 0.07937327 0.        ]

# MindSpore
import mindspore

ms_output = mindspore.numpy.hanning(12)
print(ms_output)
# [0.         0.07937324 0.29229248 0.57115734 0.82743037 0.97974646
#  0.9797465  0.8274305  0.5711575  0.29229265 0.07937327 0.        ]
1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs
r2.0

搜索帮助

53164aa7 5694891 3bd8fe86 5694891