快捷鍵

torch.hann_window

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

Hann 視窗函數。

w[n]=12 [1cos(2πnN1)]=sin2(πnN1),w[n] = \frac{1}{2}\ \left[1 - \cos \left( \frac{2 \pi n}{N - 1} \right)\right] = \sin^2 \left( \frac{\pi n}{N - 1} \right),

其中 NN 是完整的視窗大小。

輸入的 window_length 是一個正整數,用於控制返回的視窗大小。periodic 標記決定了返回的視窗是否會從對稱視窗中修剪掉最後一個重複值,並準備好用作具有像 torch.stft() 這樣的函數的週期性視窗。因此,如果 periodic 為 true,則上述公式中的 NN 實際上是 window_length+1\text{window\_length} + 1。 此外,我們始終有 torch.hann_window(L, periodic=True) 等於 torch.hann_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, optional) – 傳回張量的期望裝置。預設值:如果 None,則對預設張量型別使用目前裝置 (請參閱 torch.set_default_device())。對於 CPU 張量型別,device 將為 CPU;對於 CUDA 張量型別,將為目前的 CUDA 裝置。

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

傳回

大小為 (window_length,)(\text{window\_length},) 的 1 維張量,其中包含視窗

傳回型別

Tensor

文件

取得 PyTorch 的完整開發人員文件

檢視文件

教學

取得適用於初學者和進階開發人員的深入教學

檢視教學

資源

尋找開發資源並取得您問題的解答

檢視資源