focal-frequency-loss icon indicating copy to clipboard operation
focal-frequency-loss copied to clipboard

About the calculation of distance

Open IItaly opened this issue 2 years ago • 5 comments

https://github.com/EndlessSora/focal-frequency-loss/blob/5c34c2cb03bb9b26fa917fd9f032c009599290a5/focal_frequency_loss/focal_frequency_loss.py#L90 Thanks for your work I want to know the calculation of the distance. Euclidean distance needs square operation and why here just "tmp[...,0],tmp[...,1]" what does it mean?

IItaly avatar Jun 01 '22 08:06 IItaly

https://github.com/EndlessSora/focal-frequency-loss/blob/5c34c2cb03bb9b26fa917fd9f032c009599290a5/focal_frequency_loss/focal_frequency_loss.py#L89 Thanks for your interest. We performed the square operation in Line 89. We use the squared Euclidean distance. You can consider printing each tensor out to understand the code.

EndlessSora avatar Jun 01 '22 12:06 EndlessSora

https://github.com/EndlessSora/focal-frequency-loss/blob/5c34c2cb03bb9b26fa917fd9f032c009599290a5/focal_frequency_loss/focal_frequency_loss.py#L89

Thanks for your interest. We performed the square operation in Line 89. We use the squared Euclidean distance. You can consider printing each tensor out to understand the code.

Thank you! Can I regard that (recon_freq - real_freq) as the Euclidean distance?

IItaly avatar Jun 01 '22 12:06 IItaly

No. You can regard the square root of freq_distance in Line 90 as the Euclidean distance. We apply the squared Euclidean distance to ensure a smooth gradient.

EndlessSora avatar Jun 02 '22 05:06 EndlessSora

No. You can regard the square root of freq_distance in Line 90 as the Euclidean distance. We apply the squared Euclidean distance to ensure a smooth gradient.

Thanks for your reply. I don't think I understand what tmp[..., 0], tmp[..., 1] is doing. And If I want to make the distance bigger in other research area whether I could refer to this loss? like 1/FFLoss One problem I face is that the loss does not decrease when it set to 1/FFLoss. Would you have any ideas?

IItaly avatar Jun 02 '22 15:06 IItaly

If you would like the frequency distance to be larger as the model is trained, you may try to apply -FFLoss as your objective function.

EndlessSora avatar Jun 04 '22 08:06 EndlessSora