AttributeError: module ‘torch‘ has no attribute ‘rfft‘

2024-01-03 12:44:30

解决报错:AttributeError: module ‘torch‘ has no attribute ‘irfft‘_attributeerror: module 'torch' has no attribute-CSDN博客文章浏览阅读230次。再在当前文件页面搜索 torch.rfft 和 torch.irfft 将其改为 rfft 和 irfft 也就是把torch.去掉,再运行就好了。因为torch版本问题,新版本删除了irfft。但我不想降低torch版本。在使用了torch.irfft的文件中加上这段代码。_attributeerror: module 'torch' has no attributehttps://blog.csdn.net/m0_47893709/article/details/133696788因为torch版本问题,新版本删除了irfft。但我不想降低torch版本。在使用了torch.irfft的文件中加上这段代码。

try:
    from torch import irfft
    from torch import rfft
except ImportError:
    from torch.fft import irfft2
    from torch.fft import rfft2
    def rfft(x, d):
        t = rfft2(x, dim = (-d))
        return torch.stack((t.real, t.imag), -1)
    def irfft(x, d, signal_sizes):
        return irfft2(torch.complex(x[:,:,0], x[:,:,1]), s = signal_sizes, dim = (-d))

再在当前文件页面搜索 torch.rfft 和 torch.irfft 将其改为 rfft 和 irfft 也就是把torch.去掉,再运行就好了。

文章来源:https://blog.csdn.net/weixin_44466434/article/details/135359776
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。