Papers › Supervised Contrastive Learning

Supervised Contrastive Learning

23 Apr 2020NeurIPS 2020 12arXiv:2004.11362archive 2025-07-28

Prannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna, Yonglong Tian, Phillip Isola, Aaron Maschinot, Ce Liu, Dilip Krishnan

Contrastive learning applied to self-supervised representation learning has seen a resurgence in recent years, leading to state of the art performance in the unsupervised training of deep image models. Modern batch contrastive approaches subsume or significantly outperform traditional contrastive losses such as triplet, max-margin and the N-pairs loss. In this work, we extend the self-supervised batch contrastive approach to the fully-supervised setting, allowing us to effectively leverage label information. Clusters of points belonging to the same class are pulled together in embedding space, while simultaneously pushing apart clusters of samples from different classes. We analyze two possible versions of the supervised contrastive (SupCon) loss, identifying the best-performing formulation of the loss. On ResNet-200, we achieve top-1 accuracy of 81.4% on the ImageNet dataset, which is 0.8% above the best number reported for this architecture. We show consistent outperformance over cross-entropy on other datasets and two ResNet variants. The loss shows benefits for robustness to natural corruptions and is more stable to hyperparameter settings such as optimizers and data augmentations. Our loss function is simple to implement, and reference TensorFlow code is released at https://t.ly/supcon.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2004.11362")

Code

Syntology Ran 6 of 23 code samples harvested from 7 repositories linked to this paper; 17 have no recorded run. Of those that ran: 2 ran · honoured contract; 2 ran · our draft was wrong; 1 ran · fixture could not drive it; 1 ran with no contract checked.

By repository: community (archive-listed): 23 samples from 7 repositories, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

26 repositories listed; official and paper-mentioned ones first.

HobbitLong/SupContrast officialmentioned in papermentioned on GitHubpytorchBSD-2-Clause report
Liut2016/ecg-supcontrast mentioned on GitHubpytorch report
PaperCodeReview/SupCL-TF mentioned on GitHubtfMIT report
XG293/SupConLoss mentioned on GitHubpytorchBSD-2-Clause report
ZIZUN/CPFT mentioned on GitHubpytorch report
alexk1704/scclv2 mentioned on GitHubtfMIT report
caesarea38/doclangid mentioned on GitHubpytorch report
davidczy/supcon_gamma mentioned on GitHubpytorchBSD-2-Clause report
delyan-boychev/grad-cache-con-learning mentioned on GitHubpytorch report
flyingsheepbin/pet-biometrics mentioned on GitHubpytorchApache-2.0 report
forcesh/SupContrast mentioned on GitHubpytorch report
guerbet-ai/wsp-contrastive mentioned on GitHubpytorch report
hannaiiyanggit/unicon mentioned on GitHubpytorch report
hooman650/supcl-seq mentioned on GitHubpytorchMIT report
ilyassmoummad/ProtoCLR mentioned on GitHubpytorch report
renato145/ContrastiveLoss mentioned on GitHubpytorch report
salarim/Semi-Supervised-CL mentioned on GitHubpytorch report
sidtandon2014/fw-shapley mentioned on GitHubpytorchApache-2.0 report
uiuctml/HypStructure mentioned on GitHubpytorchMIT report
vk1996/contrastive_learning mentioned on GitHubtf report
PaddlePaddle/PaddleClas paddleApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

23 samples harvested; 6 ran; 2 honoured the contract we drafted; 17 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · honoured contract
2ran · our draft was wrong
1ran · fixture could not drive it
1ran
17unverified

Licence: 0 of the 23 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 7 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

conv3x3x3 davidczy/supcon_gamma/networks/ThreeDResnet.py community (archive-listed) ran · our draft was wrong BSD-2-Clause (permissive) · c3b215555357b9d1 · report
downsample_basic_block davidczy/supcon_gamma/networks/ThreeDResnet.py community (archive-listed) ran · our draft was wrong BSD-2-Clause (permissive) · 43c0211ff8dbca5f · report
obtain_contrastive_loss Liut2016/ecg-supcontrast/losses.py community (archive-listed) ran · fixture could not drive it fingerprinted BSD-2-Clause (permissive) · 909920018e1f3cef · report
pil_loader sidtandon2014/fw-shapley/src/shapley/embedding/custom_loader.py community (archive-listed) ran · honoured contract Apache-2.0 (permissive) · f321f54723433661 · report
set_optimizer XG293/SupConLoss/util.py community (archive-listed) ran BSD-2-Clause (permissive) · a44a1925c2c778ba · report
train raymin0223/self-contrastive-learning/main_represent.py community (archive-listed) ran · honoured contract MIT (permissive) · d8660dac176225e1 · report
accimage_loader sidtandon2014/fw-shapley/src/shapley/embedding/custom_loader.py community (archive-listed) unverified Apache-2.0 (permissive) · 404fb2b2daa1ae78 · report
accuracy XG293/SupConLoss/util.py community (archive-listed) unverified BSD-2-Clause (permissive) · 913d82af53065418 · report
create_model PaperCodeReview/SupCL-TF/model.py community (archive-listed) unverified MIT (permissive) · 6ea12cd09e4f96c6 · report
crossentropy PaperCodeReview/SupCL-TF/loss.py community (archive-listed) unverified MIT (permissive) · e42d6851a241a214 · report
default_loader sidtandon2014/fw-shapley/src/shapley/embedding/custom_loader.py community (archive-listed) unverified Apache-2.0 (permissive) · 7bf07d5f59aae36d · report
fetch_dataset PaperCodeReview/SupCL-TF/dataloader.py community (archive-listed) unverified MIT (permissive) · 104ecf80bfd973ca · report
get_fine_tuning_parameters davidczy/supcon_gamma/networks/ThreeDResnet.py community (archive-listed) unverified BSD-2-Clause (permissive) · 49df9db56daeba4a · report
get_logger PaperCodeReview/SupCL-TF/common.py community (archive-listed) unverified MIT (permissive) · e9cdcc13fe49820c · report
read_img alexk1704/scclv2/src/cl_replay/api/utils/convert_ds.py community (archive-listed) unverified MIT (permissive) · 1fd4a495ba449048 · report
read_labels alexk1704/scclv2/src/cl_replay/api/utils/convert_ds.py community (archive-listed) unverified MIT (permissive) · f4731b89be918d6f · report
search_same PaperCodeReview/SupCL-TF/common.py community (archive-listed) unverified MIT (permissive) · d04d43e439b0324a · report
set_dataset PaperCodeReview/SupCL-TF/dataloader.py community (archive-listed) unverified MIT (permissive) · 221d06a1b512b025 · report
set_loader XG293/SupConLoss/main_ce.py community (archive-listed) unverified BSD-2-Clause (permissive) · 2297ed2ca4911b7c · report
set_loader davidczy/supcon_gamma/main_supcon_thick.py community (archive-listed) unverified BSD-2-Clause (permissive) · 750f33f8190dba7b · report
supervised_contrastive PaperCodeReview/SupCL-TF/loss.py community (archive-listed) unverified MIT (permissive) · 852634a603bdd4fa · report
train raymin0223/self-contrastive-learning/main_linear.py community (archive-listed) unverified MIT (permissive) · 18ee2c887bb737f7 · report
wrn28_10 XG293/SupConLoss/networks/wide_resnet.py community (archive-listed) unverified BSD-2-Clause (permissive) · 5e3536a0b5948376 · report

Tasks

Class Incremental LearningContrastive LearningData AugmentationImage ClassificationRepresentation LearningSelf-Supervised Learning

1 archive task tag without a task page not shown.

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Class Incremental Learning cifar100 SCR 10-stage average accuracy 65.98 #2 of 7 Archive leaderboard report
Image Classification ImageNet ResNet-200 (Supervised Contrastive) Top 1 Accuracy 80.8% #679 of 1060 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

1x1 ConvolutionAutoAugmentAverage PoolingBatch NormalizationBottleneck Residual BlockConvolutionCosine AnnealingExponential DecayGlobal Average PoolingKaiming InitializationLARSLSTMMax PoolingRMSPropReLUResidual BlockResidual ConnectionSGD with MomentumSigmoid ActivationSupervised Contrastive LossTanh Activation

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections