PyTorch torch.hamming_window Function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.hamming_windowIt is a function in PyTorch used to generate the Hamming window. The Hamming window is a weighted cosine window function widely used in signal analysis in speech processing and communication systems.

Function Definition

torch.hamming_window(window_length, periodic=True, alpha=0.54, beta=0.46, dtype=None, layout=torch.strided, device=None, requires_grad=False)

Usage Example

Example

import torch

# Create a Hamming window of length 512
window = torch.hamming_window(512)
print("Hamming window shape:", window.shape)
print("First 5 values of the window:", window[:5])

# Customize alpha and beta parameters
window2 = torch.hamming_window(256, alpha=0.54, beta=0.46)
print("Custom window shape:", window2.shape)

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions