【问题标题】:AttributeError: module 'torch.fft' has no attribute 'fftfreq'AttributeError:模块“torch.fft”没有属性“fftfreq”
【发布时间】:2021-11-05 22:31:34
【问题描述】:

我从 https://pytorch.org/docs/stable/generated/torch.fft.fftshift.html#torch.fft.fftshift

import torch.fft
f = torch.fft.fftfreq(4)
a = torch.fft.fftshift(f)
print(a)

得到了错误

AttributeError: 模块 'torch.fft' 没有属性 'fftfreq'

我尝试了 pip torch==1.7.0+cu110 和 pip torch==1.7.1+cu110 以及 conda pytorch==1.7.1 和 cudatoolkit=11.0。 其他人也有同样的问题https://discuss.pytorch.org/t/unable-to-use-correctly-the-new-torch-fft-module/104560/6 但是改成torch1.7.0并没有解决问题。

如何正确使用torch.fft?

【问题讨论】:

  • 你的代码对我有用,torch.__version__ == '1.8.1+cu111'

标签: python pytorch fft


【解决方案1】:

函数torch.fft.fftfreq 是在PyTorch version 1.8.0 中引入的。您需要升级到此版本或更高版本才能使用它。

【讨论】:

    猜你喜欢
    • 2018-04-14
    • 2019-02-18
    • 1970-01-01
    • 2020-01-01
    • 2019-07-20
    • 2021-11-04
    • 2021-02-23
    • 2021-12-23
    相关资源
    最近更新 更多