0

I followed the example from 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)

and got the error

AttributeError: module 'torch.fft' has no attribute 'fftfreq'

I tried pip torch==1.7.0+cu110 and pip torch==1.7.1+cu110 and also conda pytorch==1.7.1 with cudatoolkit=11.0. Others have the same problem https://discuss.pytorch.org/t/unable-to-use-correctly-the-new-torch-fft-module/104560/6 But changing to torch1.7.0 didn't solve the problem.

How to use torch.fft correctly?

1
  • 1
    Your code is working for me with torch.__version__ == '1.8.1+cu111' Commented Sep 9, 2021 at 9:00

1 Answer 1

1

Function torch.fft.fftfreq was introduced in PyTorch version 1.8.0. You need to upgrade to this version or higher in order to use it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.