Jiahao000/MFM

Question about computing loss in the code

cooma04 opened this issue · 0 comments

Hi, authors.
Thank you for the great work. I really enjoyed reading through your work.

In the mean time, I got a question on the loss function (in the code).
From the paper, the MFM computes losses on real and imaginary part of frequency representations between the prediction and target.
Now, my question is in your code (line 64 and 65 in frequency_loss.py), you are doing

tmp = (recon_freq - real_freq) ** 2
loss = torch.sqrt(tmp[..., 0] + tmp[..., 1] + 1e-12) ** self.loss_gamma, given recon_freq and real_freq are tensors of complex number of shape (NxPxCxHxW).

Then, what would "tmp[..., 0] + tmp[..., 1]" mean?
Are you computing the loss only over the first and second elements of W dimension?

Please correct me if I am misunderstanding anything from your code above.