HobbitLong / SupContrast

PyTorch implementation of "Supervised Contrastive Learning" (and SimCLR incidentally)
BSD 2-Clause "Simplified" License
2.98k stars 525 forks source link

output Nan loss #100

Closed ChuangLee closed 2 years ago

ChuangLee commented 2 years ago

The code below output Nan loss.

    supconloss = SupConLoss(temperature=0.07).cuda()
    data = torch.randn((48, 128))
    labels = torch.arange(0, 24, 0.5).int()
    loss = supconloss(data, labels)
    print(loss)
ChuangLee commented 2 years ago

uh huh... may it's because there is no normalization. close