評價此頁

torch.blackman_window#

torch.blackman_window(window_length, periodic=True, *, dtype=None, layout=torch.strided, device=None, requires_grad=False) Tensor#

Blackman 窗函式。

w[n]=0.420.5cos(2πnN1)+0.08cos(4πnN1)w[n] = 0.42 - 0.5 \cos \left( \frac{2 \pi n}{N - 1} \right) + 0.08 \cos \left( \frac{4 \pi n}{N - 1} \right)

其中 NN 是完整的窗長。

輸入 window_length 是一個正整數,控制返回視窗的大小。periodic 標誌決定返回的視窗是否會去掉對稱視窗的最後一個重複值,以便能與 torch.stft() 等函式一起作為週期性視窗使用。因此,如果 periodic 為 True,則上述公式中的 NN 實際上是 window_length+1\text{window\_length} + 1。此外,我們總有 torch.blackman_window(L, periodic=True) 等於 torch.blackman_window(L + 1, periodic=False)[:-1]

注意

如果 window_length =1=1,則返回的視窗包含單個值 1。

引數
  • window_length (int) – 返回視窗的大小

  • periodic (bool, optional) – 如果為 True,則返回一個用作週期性函式的視窗。如果為 False,則返回一個對稱視窗。

關鍵字引數
  • dtype (torch.dtype, optional) – 返回張量的目標資料型別。預設:如果 None,則使用全域性預設值(請參閱 torch.set_default_dtype())。僅支援浮點型別。

  • layout (torch.layout, optional) – 返回視窗張量的目標佈局。僅支援 torch.strided(密集佈局)。

  • device (torch.device, 可選) – 返回張量的所需裝置。預設:如果為 None,則使用當前裝置作為預設張量型別(參見 torch.set_default_device())。對於 CPU 張量型別,device 將是 CPU;對於 CUDA 張量型別,device 將是當前的 CUDA 裝置。

  • requires_grad (bool, optional) – 如果 autograd 應記錄在返回的張量上的操作。預設值:False

返回

一個大小為 (window_length,)(\text{window\_length},) 的一維張量,包含視窗。

返回型別

張量