Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.hamming_window function

PyTorch torch.hamming_window function


PyTorch torch reference manual PyTorch torch reference manual

torch.hamming_window A function in PyTorch for generating a Hamming window. The Hamming window is a weighted cosine window function widely used in signal analysis for 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 examples

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 the alpha and beta parameters

window2

=

torch.

hamming_window

(

256

,

alpha

=

0.54

,

beta

=

0.46

)

print

(

"Custom window shape:"

,

window2.

shape

)


PyTorch torch reference manual PyTorch torch reference manual