Skip to content

Some questions about Supervised_NT_xent #49

@A-New-Page

Description

@A-New-Page

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions