Abstract
Supervised Contrastive (SupCon) loss is a popular framework for representation learning that extends self-supervised contrastive methods to labeled data. However, SupCon suffers from a fundamental mathematical inconsistency known as "intra-class repulsion," where samples from the same class are treated as noise. We present SINCERE (Supervised InfoNCE REvisited), a theoretically grounded loss function that eliminates this repulsion. By ensuring same-class images are never treated as noise, SINCERE produces better-separated embeddings and significantly improves transfer learning performance across multiple benchmarks.
Introduction
In representation learning, the objective is to map data into an embedding space where semantically similar items are clustered together and dissimilar items are pushed apart. Self-supervised methods like SimCLR achieve this using the InfoNCE loss, which contrasts an image with its own augmentations (the "target") against a set of other images in a batch (the "noise"). When labels are available, the Supervised Contrastive (SupCon) loss is often employed. However, SupCon's formulation introduces a conflict: when calculating the loss for a pair of images from the same class, other images from that same class are often included in the denominator—the noise set.
The Intra-class Repulsion Problem
The authors identify that SupCon is probabilistically inconsistent because its denominator terms are poorly defined relative to the target class. In its denominator, SupCon includes terms for all samples in a batch other than the anchor, regardless of their class label. This results in "intra-class repulsion," where the model is simultaneously tasked with pulling same-class images together (numerator) and pushing them apart (denominator). This effect becomes more pronounced as the number of samples per class increases, hindering the formation of clean clusters.
As illustrated in the figure above, while SupCon includes same-class samples $a$ and $b$ in the denominator—leading to a "Repel $p$" effect—SINCERE excludes them. This ensures that the model only learns to distinguish the target class from truly different classes ($\mathcal{N}$), restoring the core assumption of Noise-Contrastive Estimation.
The SINCERE Method
SINCERE is proposed as a "drop-in" replacement for SupCon, derived from a probabilistic generative model from first principles.
- The Fix: Unlike SupCon, SINCERE explicitly excludes all images sharing the same class label from the noise set. This ensures that same-class images are only ever "pulled" together and never "pushed" apart.
- Theoretical Grounding: The authors prove that SINCERE is a true generalization of InfoNCE. They also derive an information-theoretic bound showing that SINCERE loss acts as an upper bound on the negative symmetrized KL divergence between the data-generating distributions of the target class and all other classes.
- Gradient Analysis: By analyzing the gradients, they demonstrate that while SupCon's update can sometimes push same-class embeddings away from each other, SINCERE’s update always encourages them to move closer.
Experimental Evaluation
The models were trained and evaluated on standard computer vision benchmarks including CIFAR-10, CIFAR-100, and ImageNet-100. To highlight the repulsion effect in its most extreme form, a "CIFAR-2" (cats vs. dogs) subset was used. Transfer learning performance was tested on six diverse datasets: Pet-37, DTD-47 (Textures), FGVC-Aircraft, Food-101, Flowers-102, and Cars-196.
Key Results
- Improved Separation: SINCERE dramatically increased the margin between median cosine similarities of target vs. noise pairs. For example, on CIFAR-10, the margin jumped from 0.270 (SupCon) to 0.854 (SINCERE).
- Transfer Learning Superiority: SINCERE outperformed SupCon on all 6 transfer learning datasets tested. It also outperformed $\epsilon$-SupInfoNCE (a recent variant requiring a margin hyperparameter) on 4 out of 6 datasets, despite requiring no extra tuning.
- Convergence: In the CIFAR-2 setup, SINCERE's training loss approached zero (~0.99), while SupCon's remained high (~6.28) due to the inherent conflict in its objective.
Conclusion
SINCERE addresses a critical flaw in supervised contrastive learning by restoring probabilistic consistency to the loss function. By eliminating intra-class repulsion, SINCERE creates wider margins in the embedding space, leading to more robust features that generalize better to downstream tasks. Its simplicity as a hyperparameter-free, drop-in replacement makes it a powerful tool for supervised representation learning.
Summary updated