Applying weiner filter and pytorch iffrt error


I need help and kind guidance. I am trying to implement and apply a wiener filter on the input image of the shape:
input = [1,3,128,128]
1) When I try to perform iffrt:

return torch.irfft(Y.div(G),2,signal_sizes = input.shape[-2:]), c

the following error occurred :

AttributeError: module ‘torch’ has no attribute ‘irfft’

2) Following the above error I also tried with fft

return torch.fft.irfft(Y.div(G),2,signal_sizes = input.shape[-2:]), c

the following error occurred:

TypeError: fft_irfft() got an unexpected keyword argument ‘signal_sizes’

The second approach is correct and you should use torch.fft.irfft.
This call does not accept a signal_sizes argument as seen in the docs.

1 Like

Thanks a lot for your kind response.

I followed the doc you mentioned in your reply and pass n and dim parameters but got errors :

Y = [1,1,3,128,128,2]

G = [1,4,3,128,128,1]

  1. return torch.fft.irfft(Y.div(G),2, n = input.shape[-2:])

TypeError: fft_irfft() got multiple values for argument ‘n’

  1. return torch.fft.irfft(Y.div(G),2, dim = input.shape[-2:])

TypeError: fft_irfft(): argument ‘dim’ must be int, not torch.Size

I want to use “input.shape[-2:]” or something equivalent to it but no idea how to do it in torch.fft.irfft.

Output should be like ==> batch x N x channels x height x width => 1x4x3x128x128