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

Some questions about Supervised_NT_xent #49

Open
A-New-Page opened this issue May 7, 2022 · 0 comments
Open

Some questions about Supervised_NT_xent #49

A-New-Page opened this issue May 7, 2022 · 0 comments

Comments

@A-New-Page
Copy link

A-New-Page commented May 7, 2022

Excuse me, I recently paid attention to this paper.

when I use the Supervised_NT_xent loss, I find that there are some question maybe.

In SupCLR paper, when calculate the loss, the positive pair is (i, j), where label_i is the same as label_j, and the pair (i, i) is not regarded as positive pair, even though label_i must be the same as label_i.

However, when i use the Supervised_NT_xent loss from your code, and calculate Mask, I notice that Mask[i,i] is not zero. Therefore, the pair(i, i) will also be regarded as positive pair to calculate loss.

Mask = torch.eq(labels, labels.t()).float().to(device)
#Mask = eye * torch.stack([labels == labels[i] for i in range(labels.size(0))]).float().to(device)
Mask = Mask / (Mask.sum(dim=1, keepdim=True) + eps)

Maybe line 72 should be
Mask = torch.eq(labels, labels.t()).float().to(device) * (1 - eye)

I have some questions about it. May I trouble you to answer it?
Looking forward to your reply!

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

1 participant