Tradeoffs Between Contrastive and Supervised Learning: An Empirical Study

Ananya Karthik, Mike Wu, Noah D. Goodman, Alex TamkinarXiv 2021

Abstract

Contrastive learning has made considerable progress in computer vision, outperforming supervised pretraining on a range of downstream datasets. However, is contrastive learning the better choice in all situations? We demonstrate two cases where it is not. First, under sufficiently small pretraining budgets, supervised pretraining on ImageNet consistently outperforms a comparable contrastive model on eight diverse image classification datasets. This suggests that the common practice of comparing pretraining approaches at hundreds or thousands of epochs may not produce actionable insights for those with more limited compute budgets. Second, even with larger pretraining budgets we identify tasks where supervised learning prevails, perhaps because the object-centric bias of supervised pretraining makes the model more resilient to common corruptions and spurious foreground-background correlations. These results underscore the need to characterize tradeoffs of different pretraining objectives across a wider range of contexts and training regimes.

Introduction

In recent years, contrastive learning—a self-supervised approach where models learn representations by distinguishing between different image instances—has set new benchmarks in computer vision. The prevailing consensus suggests that contrastive pretraining yields more "holistic" representations than traditional supervised learning. However, most empirical comparisons are conducted at the "limit," involving hundreds or thousands of training epochs on massive compute clusters.

Researchers at Stanford University investigated whether these advantages hold under more constrained conditions. They focused on two primary questions:

  1. The Budget Question: Does contrastive learning remain superior when compute is limited (e.g., fewer than 15 epochs)?
  2. The Bias Question: Does the holistic nature of contrastive learning introduce vulnerabilities in tasks requiring a strict focus on foreground objects?

Methodology

The study employed a controlled "head-to-head" comparison using a ResNet-18 architecture pretrained on ImageNet. To ensure fairness, architecture and data augmentations were kept identical. The only variable was the objective function:

  • Supervised: Standard cross-entropy loss using ImageNet labels.
  • Contrastive: The InfoNCE objective, treating every image as a unique class (instance discrimination).

Representations were evaluated via linear probing, where the pretrained backbone is frozen and a simple linear classifier is trained for various downstream tasks. This isolates the quality of the features learned during pretraining.

The "Break-Even" Point in Training

A key finding is that supervised learning provides a significant head start. For the first ~15 epochs of pretraining, supervised models consistently offer better representations for downstream tasks. Contrastive learning is a "slow burner," requiring more iterations to build its holistic world model.

Accuracy vs. Pretraining Epochs across eight downstream tasks.

Interestingly, downstream accuracy is not always monotonic. As models improve at their specific pretraining task (e.g., discriminating between nearly identical image crops), they can occasionally lose performance on general transfer tasks. After a full 200 epochs, however, the contrastive model eventually outperformed the supervised model on 7 out of 8 transfer tasks.

The Object-Centric Advantage

Supervised learning's requirement to predict specific labels (e.g., "Goldfinch") forces the model to ignore backgrounds and focus on the primary object. In contrast, contrastive learning often "cheats" by utilizing background context to match augmented versions of the same image.

This "object-centric bias" makes supervised models more resilient to spurious correlations. On the Waterbirds dataset, supervised models were significantly better at identifying birds when placed in "mismatched" backgrounds (e.g., a water bird on land), whereas contrastive models were more prone to being fooled by the context.

Transfer accuracy on the Waterbirds dataset, highlighting performance on mismatched backgrounds.

Furthermore, supervised models demonstrated superior robustness to noise, achieving a lower mean Corruption Error (mCE) of 91.08% compared to the contrastive model's 95.41% on ImageNet-C. This suggests that the narrow focus on the "object" makes the model less likely to be distracted by noise in the rest of the frame.

Conclusion

While contrastive models eventually dominate on many transfer tasks, this study highlights critical tradeoffs. For practitioners with tight compute budgets (under 15 epochs), supervised pretraining remains the more efficient choice. Additionally, for tasks where background context is a distractor or where image quality may be degraded, supervised learning's object-centric focus provides a distinct advantage.

Future research should prioritize publishing learning curves rather than just final accuracy metrics, enabling better decision-making based on available compute resources. There is also a clear need for methods that combine the holistic strengths of contrastive learning with the robustness of supervised learning.

Summary updated

BibTeX
@misc{karthik2021tradeoffs,
  author = {Ananya Karthik and Mike Wu and Noah D. Goodman and Alex Tamkin},
  title = {{Tradeoffs Between Contrastive and Supervised Learning: An Empirical Study}},
  year = {2021},
  eprint = {2112.05340},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.05340},
}
Figure