Could you give an example of implementing a two-dimensional Fourier transform by use torchkbnufft? #82
Replies: 3 comments
-
Converting this to a Discussion as it does not document a bug. At a high level the equivalent is import torchkbnufft as tkbn
a = torch.rand(4, 4)
nufft_ob = tkbn.KbNufft(im_size=(4, 4))
b = nufft_ob(a, ktraj) You need to define a For a full detailed example for 2D arrays, please see the Basic Example notebook. |
Beta Was this translation helpful? Give feedback.
-
import torch a = torch.rand(4, 4)+1j nufft_ob = tkbn.KbNufft(im_size=(4, 4)) ktraj = torch.ones(4,4)*torch.pi print(b) D:\anaconda\envs\pytorchcuda\lib\site-packages\torchkbnufft_nufft\interp.py:385: UserWarning: rfloordiv is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
RuntimeError: The following operation failed in the TorchScript interpreter.
RuntimeError: The size of tensor a (4) must match the size of tensor b (0) at non-singleton dimension 0 WHY? |
Beta Was this translation helpful? Give feedback.
-
Sorry, I didn't test my example that I wrote. We need batch and channel dimensions (a PyTorch convention). The notebook should be the primary source of truth. Please consult the notebooks for the future. import torch
import torchkbnufft as tkbn
nufft_ob = tkbn.KbNufft(im_size=(4, 4))
a = torch.rand(1, 1, 4, 4) + 1j*torch.rand(1, 1, 4, 4)
ktraj = torch.randn(2, 128)
b = nufft_ob(a, ktraj) |
Beta Was this translation helpful? Give feedback.
-
Hello,torchkbnufft is great but the example is not easy.So,I want to know if I want to compute the Fourier transform of a two-dimensional array by use torchkbnufft,what should I do?
example:a = torch.rand((4,4))
fft: b = torch.fft.fft2(a)
torchkbnufft:???
Beta Was this translation helpful? Give feedback.
All reactions