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

Cosine similarity #6

Open
llyyyll opened this issue Mar 22, 2024 · 3 comments
Open

Cosine similarity #6

llyyyll opened this issue Mar 22, 2024 · 3 comments

Comments

@llyyyll
Copy link

llyyyll commented Mar 22, 2024

Thanks for your great work. I would like to ask what part of the code the cosine similarity calculation is specifically embodied in?

@Herschel555
Copy link
Owner

Hi! You can check https://github.com/Herschel555/CAML/blob/master/code/utils/correlation.py#L24, which is a conventional way to achieve similarity calculation.

@llyyyll
Copy link
Author

llyyyll commented Mar 26, 2024

Thank you for your answer. I have one more question, in the

loss_o = torch.sum(torch.sum(-corr_a * torch.log(corr_v + 1e-8), dim=1)) / num_samples
, why do you do logarithmic operations on corr_v instead of corr_a when calculating cross-entropy

Thank you!

@Herschel555
Copy link
Owner

It can be seen that we choose corr_a as the label to supervise corr_v as the prediction.

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