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

The loss label of of NCESoftmaxLoss in NCECriterion.py? #46

Closed
xuChenSJTU opened this issue Mar 2, 2020 · 0 comments
Closed

The loss label of of NCESoftmaxLoss in NCECriterion.py? #46

xuChenSJTU opened this issue Mar 2, 2020 · 0 comments

Comments

@xuChenSJTU
Copy link

Hi,

I see your code for NCESoftmaxLoss as follows:

#########
class NCESoftmaxLoss(nn.Module):
"""Softmax cross-entropy loss (a.k.a., info-NCE loss in CPC paper)"""
def init(self):
super(NCESoftmaxLoss, self).init()
self.criterion = nn.CrossEntropyLoss()

def forward(self, x):
    bsz = x.shape[0]
    x = x.squeeze()
    label = torch.zeros([bsz]).cuda().long()
    loss = self.criterion(x, label)
    return loss

###########
The label for this loss is label = torch.zeros([bsz]).cuda().long(), but in your paper, according to eq.2,
image
You have one positive for each sample.

So is something missed here??

Thanks.

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