facebookresearch / moco

PyTorch implementation of MoCo: https://arxiv.org/abs/1911.05722
MIT License
4.82k stars 794 forks source link

Positive key indicators are always zeros #101

Closed AlekseySh closed 3 years ago

AlekseySh commented 3 years ago

positive key indicators are always zeros, is this okay?

moco/builder/Moco/forward:

        # logits: Nx(1+K)
        logits = torch.cat([l_pos, l_neg], dim=1)

        # apply temperature
        logits /= self.T

        # labels: positive key indicators
        labels = torch.zeros(logits.shape[0], dtype=torch.long).cuda()
AlekseySh commented 3 years ago

for me it looks like the following line of code should be added labels[0] = 1

AlekseySh commented 3 years ago

I found that this issue has been discussed before https://github.com/facebookresearch/moco/issues/24#issuecomment-625508418

So, I guess, the better naming of variables allows to avoid confusion (positive_ids instead of labels probably)