Stochastic Contrastive Learning

Jason Ramapuram, Dan Busbridge, Xavier Suau, Russ WebbarXiv 2021

Abstract

Contrastive self-supervised learning (SSL) typically produces dense, deterministic representations. We introduce Stochastic Contrastive Learning (StochCon), which integrates prescribed latent variable distributions, such as Bernoulli and Gaussian, into the SimCLR framework. This approach yields highly compressed and interpretable representations while improving downstream fine-tuning performance on major vision benchmarks like CIFAR10 and ImageNet.

Introduction

State-of-the-art contrastive SSL models, such as SimCLR and BYOL, have significantly narrowed the performance gap with fully supervised models. However, these models typically map inputs to deterministic, continuous feature vectors, lacking the ability to infer latent variables—a capability central to generative models like Variational Autoencoders (VAEs). Latent variable models are highly desirable as they allow for uncertainty attribution, task-specific data compression, and the generation of interpretable, discrete representations. StochCon addresses the challenge of injecting these probability distributions into large-scale contrastive SSL without compromising competitive performance.

Methods

StochCon modifies the standard SimCLR framework by introducing an asymmetric stochastic bottleneck. While standard SimCLR maximizes similarity between two augmented views of an image, StochCon forces the representation of one branch through a pathwise differentiable distribution.

The StochCon architecture illustrating the stochastic bottleneck in one branch of the contrastive framework.

The architecture outputs the natural parameters of a distribution (e.g., mean and variance), from which a latent variable $z'$ is sampled. The authors explored two primary distributions:

  1. Isotropic-Gaussian: Utilizes the standard reparameterization trick. To prevent variance collapse, the network estimates the variance of the opposing view's representation.
  2. Gumbel-Bernoulli: Uses a continuous relaxation to allow backpropagation through discrete binary variables.

The latent variable can be projected into a lower-dimensional bottleneck (e.g., $d=64$) before being upsampled for the contrastive loss. This mechanism encourages the model to learn a compressed representation that retains essential information for the contrastive task.

Results and Insights

Experiments conducted on CIFAR10 and ImageNet demonstrate that adding stochasticity improves fine-tuning performance.

Performance scaling with bottleneck dimension (left) and classification efficiency using a small number of latent units (right).

Performance Benchmarks

StochCon (Bernoulli) achieves superior fine-tuned accuracy compared to standard SimCLR:

  • CIFAR10 (ResNet50): 96.42% vs. 94.35% (SimCLR) and 95.00% (Supervised).
  • ImageNet (ResNet50): 77.49% vs. 76.37% (SimCLR).
  • ImageNet (ResNet200): 80.24% vs. 79.82% (SimCLR).

Compression and Interpretability

The use of Bernoulli latent variables enables extreme data compression. The authors report a 588x reduction in representation size when using binary outputs compared to standard floats. Furthermore, these discrete features are highly efficient; on CIFAR10, a Random Forest required only 11 binary feature units from a 64-dimensional latent space to achieve high classification accuracy. The model also demonstrates high capacity utilization, maximizing information entropy by using available bits effectively (e.g., 50% zeros and 50% ones in a 512-dimensional bottleneck).

Conclusion

StochCon successfully integrates stochastic latent variables into contrastive SSL, providing a path toward more interpretable and compressed representations without sacrificing performance. While the frozen linear probe performance of the Bernoulli variant currently lags slightly behind the Gaussian version—likely due to temperature annealing schedules—the gains in fine-tuning accuracy are significant. Future research may explore alternative distributions, such as pathwise Beta distributions or non-parametric latent variables like normalizing flows, to further enhance the richness of SSL representations.

Summary updated

Abstract

While state-of-the-art contrastive Self-Supervised Learning (SSL) models produce results competitive with their supervised counterparts, they lack the ability to infer latent variables. In contrast, prescribed latent variable (LV) models enable attributing uncertainty, inducing task specific compression, and in general allow for more interpretable representations. In this work, we introduce LV approximations to large scale contrastive SSL models. We demonstrate that this addition improves downstream performance (resulting in 96.42% and 77.49% test top-1 fine-tuned performance on CIFAR10 and ImageNet respectively with a ResNet50) as well as producing highly compressed representations (588x reduction) that are useful for interpretability, classification and regression downstream tasks.
BibTeX
@misc{ramapuram2021stochastic,
  author = {Jason Ramapuram and Dan Busbridge and Xavier Suau and Russ Webb},
  title = {{Stochastic Contrastive Learning}},
  year = {2021},
  eprint = {2110.00552},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2110.00552},
}
Figure