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

Margin in NCA loss #59

Open
EvelynChee opened this issue Mar 26, 2022 · 3 comments
Open

Margin in NCA loss #59

EvelynChee opened this issue Mar 26, 2022 · 3 comments

Comments

@EvelynChee
Copy link

margins = torch.zeros_like(similarities)
margins[torch.arange(margins.shape[0]), targets] = margin
similarities = scale * (similarities - margin)

Based on the equation in the paper, shouldn't line 74 be similarities - margins instead? Currently it seems to remove the margin for all classes instead of the only the target class?

@arthurdouillard
Copy link
Owner

Line 73 does that, margins is zero for all negative class, and of value margin for the target class.

@EvelynChee
Copy link
Author

@arthurdouillard yes, margins has that but in line 74, the value margin is deducted instead of margins?

@arthurdouillard
Copy link
Owner

Oh yes, you're definitely right!

Thanks for catching that, I'll fix it.

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