question about the code
Mdahao opened this issue · 1 comments
Hi~ Thanks for your excellent work. I have a question about
orthohash/functions/loss/orthohash.py
Line 79 in 756771e
I would like to understand the association between line of code and (O_yn,V_n ) in formula (8) in paper.
Hi @Mdahao , thanks for your interest in our work.
When we normalize O_yn and V_n to have the same norm, which is ||O_yn|| = ||V_n|| = 1, then the dot product of O_yn and V_n is equivalent to the cosine similarity of O_yn and V_n. (i.e., rewrite equation 8 as equation 9 without the sqrt(K)). Thus logits
is the cosine similarity of O_yn and V_n computed by CosSim
module.
This line of code is to compute the margin logits, which is the cosine margin (footnote 4) and scaling (scale the margin cosine similarity by sqrt(K)).
You can also refer to https://github.com/MuggleWang/CosFace_pytorch for the cosine margin implementation.