Function Differences with torch.bartlett_window
torch.bartlett_window
torch.bartlett_window(
window_length,
periodic=True,
*,
dtype=None,
layout=torch.strided,
device=None,
requires_grad=False
) -> Tensor
For more information, see torch.bartlett_window.
mindspore.ops.bartlett_window
mindspore.ops.bartlett_window(
window_length,
periodic=True,
dtype=mstype.float32
) -> Tensor
For more information, see mindspore.ops.bartlett_window.
Differences
PyTorch: Returns a bartlett 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, and the precision varies slightly.
Categories |
Subcategories |
PyTorch |
MindSpore |
Differences |
---|---|---|---|---|
Parameters |
Parameter 1 |
window_length |
window_length |
An int in PyTorch and a Tensor in MindSpore |
Parameter 2 |
periodic |
periodic |
- |
|
Parameter 3 |
dtype |
dtype |
- |
|
Parameter 4 |
layout |
- |
Not involved |
|
Parameter 5 |
device |
- |
Not involved |
|
Parameter 6 |
requires_grad |
- |
MindSpore does not have this parameter and supports reverse derivation by default |
Code Example 1
# PyTorch
import torch
torch_output = torch.bartlett_window(5, periodic=True)
print(torch_output.numpy())
#[0. 0.4 0.8 0.79999995 0.39999998]
# MindSpore
import mindspore
from mindspore import Tensor
window_length = Tensor(5, mindspore.int32)
ms_output = mindspore.ops.bartlett_window(window_length, periodic=True)
print(ms_output.asnumpy())
#[0. 0.4 0.8 0.8 0.4]