sthalles / SimCLR

PyTorch implementation of SimCLR: A Simple Framework for Contrastive Learning of Visual Representations
https://sthalles.github.io/simple-self-supervised-learning/
MIT License
2.25k stars 466 forks source link

Loss function #13

Closed Sherrylone closed 4 years ago

Sherrylone commented 4 years ago

Hi. Thanks for your great work. But I have a little confusion. You implement the contrastive loss by Cross-Entropy Loss without softmax function. So the negatives actually didn't work but only positives.

nzw0301 commented 4 years ago

@Sherrylone The softmax function is applied in torch.nn.CrossEntropyLoss.