htyao89 / KgCoOp

82 stars 8 forks source link

a question about loss_kg #6

Open YaoShunyu19 opened 8 months ago

YaoShunyu19 commented 8 months ago

Hi, In paper formula (3), L_kg compute the euclidean distance between w_i and w_clip_i. And in code, L_kg=1-cosine_similarity(.,.). Whether the two cases will affect the final effect? Thanks!

htyao89 commented 8 months ago

Hi, In paper formula (3), L_kg compute the euclidean distance between w_i and w_clip_i. And in code, L_kg=1-cosine_similarity(.,.). Whether the two cases will affect the final effect? Thanks!

For the normalized features, the Euclidean distance is consistent with the cosine distance. Moreover, the smaller the Euclidean distance, the better. The higher the cosine similarity, the better. Therefore, (1-cosine) is the same as the Euclidean.

More detailed information can be see: https://stats.stackexchange.com/questions/146221/is-cosine-similarity-identical-to-l2-normalized-euclidean-distance