Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Supervised Contrastive Learning

Supervised contrastive learning pulls same-class images together in embedding space

  • Problem Cross-entropy is the default supervised loss, and alternatives rarely beat it on large datasets. Contrastive losses use one positive per anchor, so they cannot use several same-class samples.
  • Method SupCon lets every sample sharing the anchor's class count as a positive, instead of only an augmented copy. It pulls those positives together and pushes other batch samples apart.
  • Results On ResNet-200, SupCon reached 81.4% top-1 accuracy on ImageNet, which is 0.8% above the best reported for that architecture.

Why cross-entropy is hard to replace

Cross-entropy is the default loss for supervised classifiers, and it is still behind many state of the art ImageNet results. Its weak spots are well documented, including sensitivity to noisy labels and poor margins, but alternatives rarely beat it on large datasets. Contrastive learning takes a different route: it pulls a positive pair together in embedding space and pushes the anchor away from negatives.

Self-supervised contrastive losses use exactly one positive per anchor, and the standard form cannot take several same-class samples as positives.

Many same-class positives per anchor

The core idea is to let every sample that shares the anchor's class count as a positive, instead of only an augmented copy of the anchor. The negatives stay the same as in contrastive learning, namely the remaining samples of the batch, so the many-negatives design is kept. The authors also frame the loss as a generalization: the triplet loss uses one positive and one negative per anchor, and the N-pairs loss uses one positive with many negatives.

Generalizing to several positives can be done in more than one way, so the authors compared two forms. In one form the sum over positives sits outside the logarithm, and in the other it sits inside. Because the logarithm is concave, Jensen's inequality implies the inside form is at most the outside form. Their gradients differ mainly through a weight on the positives, and the outside form makes that weight uniform, which removes a bias that the inside form keeps.

How one training step runs

Each labeled batch of N images is augmented twice, which gives 2N views that form a multiviewed batch. Both views pass through the same encoder, which outputs a 2048-dimensional vector that is normalized to unit length. A projection network then maps each vector to a normalized 128-dimensional output, either through one hidden layer of size 2048 or as a single linear layer.

The outside-log loss is computed on these projections, and for each anchor i it reads \[ L^{\mathrm{sup}}_{\mathrm{out},i} = -\frac{1}{|P(i)|}\sum_{p\in P(i)}\log\frac{\exp(z_i\cdot z_p/\tau)}{\sum_{a\in A(i)}\exp(z_i\cdot z_a/\tau)} \] The temperature τ is set to 0.1 for all main runs, and it scales the inner products inside the loss. No separate hard-mining step is needed, because the gradient already weights hard positives and negatives more heavily.

After contrastive training the projection network is discarded, and a linear classifier is trained with cross-entropy on the frozen encoder. This second stage is optional for transfer or retrieval, and the authors say it needs as few as 10 epochs.

Why the outside-log form wins

On ResNet-50 at batch size 6144, the outside-log form reached 78.7% top-1 accuracy on ImageNet, while the inside-log form reached 67.4%. The authors trace the gap to the normalization factor, which sits outside the logarithm in the outside form and so rescales each positive term. Inside the logarithm the same factor only adds a constant and leaves the gradient unchanged, so the inside form stays more exposed to bias among the positives.

Setting each positive to the mean positive makes the inside weight equal the outside weight, so the authors use the outside form for the rest of the paper.

ImageNet accuracy against cross-entropy

With ResNet-200, SupCon reached 81.4% top-1 accuracy, which the authors report as 0.8% above the best figure reported for that architecture. That ResNet-200 run used Stacked RandAugment, which the authors found best for ResNet-200 with both losses.

Batch size is a confound, because SupCon uses two views per sample and so has an effective batch twice that of cross-entropy. Cross-entropy at batch size 12,288 reached only 77.5%, and training it for 1400 epochs lowered accuracy to 77.0%, so a larger batch alone doesn't close the gap.

A memory bank of 8192 vectors with batch size 256 gave SupCon 79.1% on ResNet-50, slightly above the 78.7% at batch size 6144 without memory. N-pairs in the same framework reached only 57.4%, which the authors attribute to missing multiple views, a temperature of 1 instead of 0.1, and fewer positives.

Robustness and transfer

On ImageNet-C with ResNet-50, SupCon scored a Mean Corruption Error of 67.2, against 68.6 for cross-entropy, and lower is better. Relative mCE gives the same ordering, 94.6 against 96.2 for ResNet-50. The ResNet-200 rows point the same way, with 50.6 for SupCon against 52.4 for cross-entropy on mCE.

Across changes of augmentation, optimizer and learning rate, the authors measured lower variance in SupCon's top-1 accuracy than in cross-entropy's. On 12 natural image datasets the transfer results are on par, with SupCon-50 averaging 84.27 against 84.67 for cross-entropy on ResNet-50. On ResNet-200 the averages are 85.67 for SupCon and 85.77 for cross-entropy.

Limits and open questions

The main ImageNet results use batch size 6144, although the authors note that 2048 is enough for most purposes. More heavily tuned models deteriorated in Expected Calibration Error, which the authors report as a cost of tuning.

All encoders are ResNet-50, ResNet-101 or ResNet-200, so other architectures are untested. The authors leave the choice of projection network architecture to future work. They also leave open how the training objective relates to transfer performance.

Paper info

Authors
Khosla, Prannay, Teterwak, Piotr, Wang, Chen, Sarna, Aaron, Tian, Yonglong, Isola, Phillip, Maschinot, Aaron, Liu, Ce, Krishnan, Dilip
Venue
arXiv · Preprint
First published
2020-4-23
Added
2026-11-12
Updated
2021-3-10
Version
v5
arXiv
2004.11362
Category
cs.LG · cs.CV · stat.ML
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Khosla, Prannay, Teterwak, Piotr, Wang, Chen, Sarna, Aaron, Tian, Yonglong, Isola, Phillip, Maschinot, Aaron, Liu, Ce, Krishnan, Dilip (2020). Supervised Contrastive Learning. arXiv:2004.11362v5. https://arxiv.org/abs/2004.11362v5

BibTeX
@misc{prannay2020supervised,
  title = {{Supervised Contrastive Learning}},
  author = {Khosla, Prannay and Teterwak, Piotr and Wang, Chen and Sarna, Aaron and Tian, Yonglong and Isola, Phillip and Maschinot, Aaron and Liu, Ce and Krishnan, Dilip},
  year = {2020},
  eprint = {2004.11362},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2004.11362v5}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up