Shortcuts

# torch.hamming_window¶

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

Hamming window function.

$w[n] = \alpha - \beta\ \cos \left( \frac{2 \pi n}{N - 1} \right),$

where $N$ is the full window size.

The input window_length is a positive integer controlling the returned window size. periodic flag determines whether the returned window trims off the last duplicate value from the symmetric window and is ready to be used as a periodic window with functions like torch.stft(). Therefore, if periodic is true, the $N$ in above formula is in fact $\text{window\_length} + 1$. Also, we always have torch.hamming_window(L, periodic=True) equal to torch.hamming_window(L + 1, periodic=False)[:-1]).

Note

If window_length $=1$, the returned window contains a single value 1.

Note

This is a generalized version of torch.hann_window().

Parameters
• window_length (int) – the size of returned window

• periodic (bool, optional) – If True, returns a window to be used as periodic function. If False, return a symmetric window.

• alpha (float, optional) – The coefficient $\alpha$ in the equation above

• beta (float, optional) – The coefficient $\beta$ in the equation above

Keyword Arguments
Returns

A 1-D tensor of size $(\text{window\_length},)$ containing the window.

Return type

Tensor

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials