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 View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

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

For agents, on Syntology's MCP service (how to connect):

Code

No sample from the archive's official repositories (HobbitLong/SupContrast, google-research/google-research) is linked to this paper; the 23 samples below come from 7 community repositories. Syntology harvested code from HobbitLong/SupContrast for another paper; from google-research/google-research for 24 other papers.

HobbitLong/SupContrast: Syntology's graph links these samples to Combating Bilateral Edge Noise for Robust Link Prediction (arXiv:2311.01196; that paper's own run record: 20 ran (of which 2 constructed an object rather than computing a result; 15 with no instrument failure: 3 honoured, 1 violated, 11 with no contract checked; 5 where Syntology's instrument failed) · 14 unverified); nothing checks that they implement this paper's method. google-research/google-research: Syntology's graph links these samples to Efficient Neural Architecture Search via Parameter Sharing (arXiv:1802.03268; that paper's own run record: 18 ran (of which 10 constructed an object rather than computing a result; 12 with no instrument failure: 1 honoured, 0 violated, 11 with no contract checked; 6 where Syntology's instrument failed) · 20 unverified), Milking CowMask for Semi-Supervised Image Classification (arXiv:2003.12022; that paper's own run record: 1 ran (of which 1 constructed an object rather than computing a result; 1 with no instrument failure: 0 honoured, 0 violated, 1 with no contract checked; 0 where Syntology's instrument failed) · 1 unverified; the one sample that ran constructed an object rather than computing a result), Neural Additive Models: Interpretable Machine Learning with Neural Nets (arXiv:2004.13912; that paper's own run record: 26 ran (of which 14 constructed an object rather than computing a result; 26 with no instrument failure: 5 honoured, 0 violated, 21 with no contract checked; 0 where Syntology's instrument failed) · 7 unverified) and 21 more (every one in this page's JSON twin); nothing checks that they implement this paper's method.

Syntology 23 code samples harvested from 7 repositories linked to this paper: 17 ran (of which 0 constructed an object rather than computing a result; 12 with no instrument failure: 2 honoured, 0 violated, 10 with no contract checked; 5 where Syntology's instrument failed) · 6 unverified. Where Syntology's instrument failed: 3 where our contract draft was wrong; 2 where the contract check could not run; failures of Syntology's instrument, not of the code.

By repository: community (archive-listed): 23 samples from 7 repositories, 17 ran (12 with no instrument failure; 5 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

No sample is linked to this paper from 8 of its repositories that Syntology harvested for other papers:

Levels written between 2026-09-22 and 2026-09-25 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed.

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

HobbitLong/SupContrast officialmentioned in papermentioned on GitHubpytorchBSD-2-ClauseSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to Combating Bilateral Edge Noise for Robust Link Prediction (arXiv:2311.01196; that paper's own run record: 20 ran (of which 2 constructed an object rather than computing a result; 15 with no instrument failure: 3 honoured, 1 violated, 11 with no contract checked; 5 where Syntology's instrument failed) · 14 unverified); nothing checks that they implement this paper's method. report
google-research/google-research officialtfSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to Efficient Neural Architecture Search via Parameter Sharing (arXiv:1802.03268; that paper's own run record: 18 ran (of which 10 constructed an object rather than computing a result; 12 with no instrument failure: 1 honoured, 0 violated, 11 with no contract checked; 6 where Syntology's instrument failed) · 20 unverified), Milking CowMask for Semi-Supervised Image Classification (arXiv:2003.12022; that paper's own run record: 1 ran (of which 1 constructed an object rather than computing a result; 1 with no instrument failure: 0 honoured, 0 violated, 1 with no contract checked; 0 where Syntology's instrument failed) · 1 unverified; the one sample that ran constructed an object rather than computing a result), Neural Additive Models: Interpretable Machine Learning with Neural Nets (arXiv:2004.13912; that paper's own run record: 26 ran (of which 14 constructed an object rather than computing a result; 26 with no instrument failure: 5 honoured, 0 violated, 21 with no contract checked; 0 where Syntology's instrument failed) · 7 unverified) and 21 more (every one in this page's JSON twin); nothing checks that they implement this paper's method. report
Liut2016/ecg-supcontrast mentioned on GitHubpytorchSyntology: 1 sample, 1 ran (1 instrument-failed) · 0 unverified report
PaperCodeReview/SupCL-TF mentioned on GitHubtfMITSyntology: 7 samples, 6 ran (0 instrument-failed) · 1 unverified report
XG293/SupConLoss mentioned on GitHubpytorchBSD-2-ClauseSyntology: 4 samples, 2 ran (1 instrument-failed) · 2 unverified report
ZIZUN/CPFT mentioned on GitHubpytorchSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to Few-Shot Intent Detection via Contrastive Pre-Training and Fine-Tuning (arXiv:2109.06349; that paper's own run record: 3 ran (of which 2 constructed an object rather than computing a result; 2 with no instrument failure: 0 honoured, 0 violated, 2 with no contract checked; 1 where Syntology's instrument failed) · 1 unverified); nothing checks that they implement this paper's method. report
alexk1704/scclv2 mentioned on GitHubtfMITSyntology: 2 samples, 2 ran (0 instrument-failed) · 0 unverified report
caesarea38/doclangid mentioned on GitHubpytorchSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to A Simple Framework for Contrastive Learning of Visual Representations (arXiv:2002.05709; that paper's own run record: 115 ran (of which 33 constructed an object rather than computing a result; 89 with no instrument failure: 1 honoured, 1 violated, 87 with no contract checked; 26 where Syntology's instrument failed) · 22 unverified); nothing checks that they implement this paper's method. report
davidczy/supcon_gamma mentioned on GitHubpytorchBSD-2-ClauseSyntology: 4 samples, 3 ran (2 instrument-failed) · 1 unverified report
delyan-boychev/grad-cache-con-learning mentioned on GitHubpytorchSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to A Simple Framework for Contrastive Learning of Visual Representations (arXiv:2002.05709; that paper's own run record: 115 ran (of which 33 constructed an object rather than computing a result; 89 with no instrument failure: 1 honoured, 1 violated, 87 with no contract checked; 26 where Syntology's instrument failed) · 22 unverified); nothing checks that they implement this paper's method. report
flyingsheepbin/pet-biometrics mentioned on GitHubpytorchApache-2.0Syntology: not harvested report
forcesh/SupContrast mentioned on GitHubpytorchSyntology: not harvested report
guerbet-ai/wsp-contrastive mentioned on GitHubpytorchSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to A Simple Framework for Contrastive Learning of Visual Representations (arXiv:2002.05709; that paper's own run record: 115 ran (of which 33 constructed an object rather than computing a result; 89 with no instrument failure: 1 honoured, 1 violated, 87 with no contract checked; 26 where Syntology's instrument failed) · 22 unverified); nothing checks that they implement this paper's method. report
hannaiiyanggit/unicon mentioned on GitHubpytorchSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to A Simple Framework for Contrastive Learning of Visual Representations (arXiv:2002.05709; that paper's own run record: 115 ran (of which 33 constructed an object rather than computing a result; 89 with no instrument failure: 1 honoured, 1 violated, 87 with no contract checked; 26 where Syntology's instrument failed) · 22 unverified); nothing checks that they implement this paper's method. report
hooman650/supcl-seq mentioned on GitHubpytorchMITSyntology: not harvested report
ilyassmoummad/ProtoCLR mentioned on GitHubpytorchSyntology: not harvested report
renato145/ContrastiveLoss mentioned on GitHubpytorchSyntology: not harvested report
salarim/Semi-Supervised-CL mentioned on GitHubpytorchSyntology: not harvested report
sayakpaul/Supervised-Constrastive-Learning-in-TensorFlow-2 mentioned on GitHubtfSyntology: not harvested report
sidtandon2014/fw-shapley mentioned on GitHubpytorchApache-2.0Syntology: 3 samples, 2 ran (1 instrument-failed) · 1 unverified report
uiuctml/HypStructure mentioned on GitHubpytorchMITSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to Learning Structured Representations with Hyperbolic Embeddings (arXiv:2412.01023; that paper's own run record: 12 ran (of which 0 constructed an object rather than computing a result; 5 with no instrument failure: 0 honoured, 0 violated, 5 with no contract checked; 7 where Syntology's instrument failed) · 3 unverified); nothing checks that they implement this paper's method. report
vk1996/contrastive_learning mentioned on GitHubtfSyntology: not harvested report
GuoQuanhao/SupContrast-Paddle paddleMITSyntology: not harvested report
PaddlePaddle/PaddleClas paddleApache-2.0Syntology: not harvested report
paddorch/SupContrast.paddle paddleMITSyntology: not harvested report
raymin0223/self-contrastive-learning pytorchSyntology: 2 samples, 1 ran (0 instrument-failed) · 1 unverified 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.

A paper named beside a repository with no sample linked to this paper is shown with that paper's own run record, not this paper's: “ran” means executed on a synthesized input, not that the code is correct, and “where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Papers are listed in arXiv-id order, at most three per repository.

Code Syntology ran Syntology

23 samples harvested: 17 ran (of which 0 constructed an object rather than computing a result; 12 with no instrument failure: 2 honoured, 0 violated, 10 with no contract checked; 5 where Syntology's instrument failed) · 6 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page last changed ; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

2ran · honoured contract
3ran · our draft was wrong
2ran; the contract check could not run
10ran
6unverified

Licence: 5 of the 23 samples are pointer only, meaning Syntology does not serve that copy's text. For 5 of them, this paper's copy is under a permissive licence and cleared, but the stored copy of the same code that Syntology serves is not; the licence label's tooltip gives Syntology's recorded reason. 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; the list below is grouped by repository, each group headed by its name and what it is to the paper. “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. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (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 are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. 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 six 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; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. 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.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity. A census tag appears when Syntology's census ran implementations with that name on one shared input per bucket: it gives how many were compared, from how many papers, and how many distinct outputs they produced, and names this sample's bucket when this sample was one of them.

Liut2016/ecg-supcontrast community (archive-listed) 1 sample, 1 ran (1 instrument-failed) · 0 unverified
obtain_contrastive_loss losses.py ran; the contract check could not run (RAISES) · metamorphic tier: invariant fingerprinted BSD-2-Clause (permissive) · 909920018e1f3cef · report fixture: signature latent_embeddings:Tensor/3/float, pids:list/1/str, trial:str/0/str · returned Tensor · level recorded 2026-09-22
PaperCodeReview/SupCL-TF community (archive-listed) 7 samples, 6 ran (0 instrument-failed) · 1 unverified
create_model in 163 papers model.py ran MIT (permissive) · 6ea12cd09e4f96c6 · report fixture: signature args:Args/0/?, logger:MinimalLogger/0/? · returned Functional · level recorded 2026-09-24
crossentropy loss.py ran MIT (permissive) · e42d6851a241a214 · report fixture: signature args:ArgsConfig/0/? · returned function · level recorded 2026-09-24
fetch_dataset in 7 papers dataloader.py ran MIT (permissive) · 104ecf80bfd973ca · report fixture: signature path:str/0/str, y:EagerTensor/0/int · returned _TensorDataset · level recorded 2026-09-24
get_logger in 383 papers common.py ran MIT (permissive) · e9cdcc13fe49820c · report fixture: signature name:str/0/str · returned Logger · level recorded 2026-09-24
set_dataset dataloader.py ran MIT (permissive) · 221d06a1b512b025 · report fixture: signature args:Args/0/? · returned tuple · level recorded 2026-09-24
supervised_contrastive loss.py ran MIT (permissive) · 852634a603bdd4fa · report fixture: signature args:Args/0/?, batch_size_per_replica:int/0/int · returned function · level recorded 2026-09-24
search_same common.py unverified MIT (permissive) · d04d43e439b0324a · report
XG293/SupConLoss community (archive-listed) 4 samples, 2 ran (1 instrument-failed) · 2 unverified
set_optimizer in 24 papers util.py ran · our draft was wrong BSD-2-Clause (permissive) here; the stored copy is pointer only · a44a1925c2c778ba · report fixture: signature opt:Options/0/?, model:callable/0/? · returned SGD · level recorded 2026-09-24
wrn28_10 in 5 papers networks/wide_resnet.py ran BSD-2-Clause (permissive) · 5e3536a0b5948376 · report fixture: signature num_classes:int/0/int, loss_type:str/0/str · returned WideResNet · level recorded 2026-09-24
accuracy in 872 papers
census: 8 implementations from 7 papers, 7 distinct outputs across 6 buckets, one shared input per bucket
util.py unverified BSD-2-Clause (permissive) here; the stored copy is pointer only · 913d82af53065418 · report
set_loader in 10 papers main_ce.py unverified BSD-2-Clause (permissive) here; the stored copy is pointer only · 2297ed2ca4911b7c · report
alexk1704/scclv2 community (archive-listed) 2 samples, 2 ran (0 instrument-failed) · 0 unverified
read_img in 41 papers src/cl_replay/api/utils/convert_ds.py ran MIT (permissive) · 1fd4a495ba449048 · report fixture: signature file:str/0/str · returned ndarray · level recorded 2026-09-24
read_labels in 11 papers src/cl_replay/api/utils/convert_ds.py ran MIT (permissive) · f4731b89be918d6f · report fixture: signature file:str/0/str · returned ndarray · level recorded 2026-09-24
davidczy/supcon_gamma community (archive-listed) 4 samples, 3 ran (2 instrument-failed) · 1 unverified
conv3x3x3 in 32 papers networks/ThreeDResnet.py ran · our draft was wrong BSD-2-Clause (permissive) · c3b215555357b9d1 · report fixture: signature in_planes:int/0/int, out_planes:int/0/int, stride:int/0/int · returned Conv3d · level recorded 2026-09-22
downsample_basic_block in 26 papers networks/ThreeDResnet.py ran · our draft was wrong BSD-2-Clause (permissive) · 43c0211ff8dbca5f · report fixture: signature x:Tensor/5/float, planes:int/0/int, stride:int/0/int · returned Tensor · level recorded 2026-09-22
get_fine_tuning_parameters in 14 papers networks/ThreeDResnet.py ran BSD-2-Clause (permissive) · 49df9db56daeba4a · report fixture: signature model:callable/0/?, ft_prefixes:str/0/str · returned list · level recorded 2026-09-24
set_loader in 10 papers main_supcon_thick.py unverified BSD-2-Clause (permissive) · 750f33f8190dba7b · report
sidtandon2014/fw-shapley community (archive-listed) 3 samples, 2 ran (1 instrument-failed) · 1 unverified
default_loader in 66 papers src/shapley/embedding/custom_loader.py ran; the contract check could not run (DEP_MISSING) Apache-2.0 (permissive) here; the stored copy is pointer only · 7bf07d5f59aae36d · report fixture: signature path:str/0/str · returned Image · level recorded 2026-09-25
pil_loader in 144 papers src/shapley/embedding/custom_loader.py ran · honoured contract Apache-2.0 (permissive) · f321f54723433661 · report fixture: signature path:str/0/str · returned Image · level recorded 2026-09-22
accimage_loader in 47 papers src/shapley/embedding/custom_loader.py unverified Apache-2.0 (permissive) here; the stored copy is pointer only · 404fb2b2daa1ae78 · report
raymin0223/self-contrastive-learning community (archive-listed) 2 samples, 1 ran (0 instrument-failed) · 1 unverified
train in 522 papers main_represent.py ran · honoured contract MIT (permissive) · d8660dac176225e1 · report fixture: returned float · level recorded 2026-09-22
train in 522 papers main_linear.py unverified MIT (permissive) · 18ee2c887bb737f7 · 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