Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSFR loss #13

Closed
misakshoyan opened this issue Jan 10, 2022 · 6 comments
Closed

MSFR loss #13

misakshoyan opened this issue Jan 10, 2022 · 6 comments

Comments

@misakshoyan
Copy link

Hi @INVOKERer.
In MIMO-UNET, where pytorch version is 1.4, the FFT for MSFR loss is calculated as
torch.rfft(image, signal_ndim=2, normalized=False, onesided=False)

Could you, please, tell me how do you port it to torch.fft.rfft in pytorch 1.8?

@INVOKERer
Copy link
Owner

You can use torch.fft.rfft2/fft2/fftn/rfftn to calculate MSFR. We use torch.fft.fft2 to calculate MSFR.

@misakshoyan
Copy link
Author

torch.fft.fft2 or torch.fft.rfft2?
And, could you, please, share your one line code with me if it is possible?

@INVOKERer
Copy link
Owner

torch.mean(abs(torch.fft.fft2(x) - torch.fft.fft2(y)))

@misakshoyan
Copy link
Author

Thank You!

@misakshoyan
Copy link
Author

misakshoyan commented Jan 10, 2022

I get the following warning message after loss.backward():
"Warning: Casting complex values to real discards the imaginary part (function operator())"

Is this expected?

When I use rfft2 instead of fft2,
"torch.mean(abs(torch.fft.rfft2(x) - torch.fft.rfft2(y)))"
warning disappears.

@misakshoyan
Copy link
Author

misakshoyan commented Jan 10, 2022

I think this is a bug of pytorch, the warning message should not be given:
pytorch/pytorch#59524

But code should work correct.

@INVOKERer INVOKERer mentioned this issue Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants