Probabilistic Contrastive Learning with Explicit Concentration on the Hypersphere

Hongwei Bran Li, Cheng Ouyang, Tamaz Amiranashvili, Matthew S. Rosen, Bjoern H. Menze, Juan Eugenio Iglesias

Abstract

Self-supervised contrastive learning has predominantly adopted deterministic methods, which are not suited for environments characterized by uncertainty and noise. This paper introduces a new perspective on incorporating uncertainty into contrastive learning by embedding representations within a spherical space, inspired by the von Mises-Fisher distribution (vMF). We introduce an unnormalized form of vMF and leverage the concentration parameter, $\kappa$, as a direct, interpretable measure to quantify uncertainty explicitly. Our empirical results demonstrate that the estimated concentration parameter correlates strongly with the degree of unforeseen data corruption encountered at test time, enables failure analysis, and enhances existing out-of-distribution detection methods.

Introduction: The Deterministic Gap

Contrastive learning frameworks like SimCLR have revolutionized self-supervised representation learning by mapping images to points on a hypersphere. However, these methods are fundamentally deterministic. In high-stakes domains such as medical imaging or autonomous driving, the inability of a model to express uncertainty is a critical flaw. A standard deterministic model projects a highly corrupted or out-of-distribution image to a single point without any indication of its low reliability. While Gaussian embeddings have been explored, they often conflict with the spherical geometry essential for contrastive learning performance.

Methods: Modeling Uncertainty on the Hypersphere

To address this, we propose a probabilistic framework based on the von Mises-Fisher (vMF) distribution, often described as the "Gaussian of the sphere."

The vMF Distribution and Concentration ($\kappa$)

A vMF distribution is defined by a mean direction ($\mu$) and a concentration parameter ($\kappa$). While $\mu$ represents the semantic content of the representation, $\kappa$ quantifies the model's confidence. A high $\kappa$ indicates that the distribution is tightly clustered around the mean, signifying high certainty. Conversely, a low $\kappa$ suggests a spread-out distribution, reflecting high uncertainty.

Visualizing the effect of the concentration parameter $\kappa$ on point distribution on a hypersphere. Higher $\kappa$ values lead to tighter clusters.

Numerical Stability and Loss Formulation

Training with vMF distributions typically involves complex Bessel functions that are prone to numerical overflow. We circumvent this by utilizing an unnormalized form of the distribution. To prevent the model from trivially maximizing $\kappa$, we introduce an $\ell_2$ regularization term that mimics the natural mathematical penalty of the original distribution. The final objective is a tripartite loss combining alignment (weighted by concentration), regularization, and a standard contrastive term to preserve discriminative power.

Key Results: $\kappa$ as a Reliable Uncertainty Sensor

Our experiments on CIFAR-10, CIFAR-100, and MNIST demonstrate that $\kappa$ serves as an exceptionally sensitive sensor for data quality.

Correlation with Corruption

When tested against CIFAR-10-C (a benchmark of 18 corruption types), the predicted $\kappa$ values showed a near-perfect negative correlation with corruption severity. As images become blurrier or noisier, $\kappa$ decreases monotonically. For many noise types like Fog or Contrast, the Spearman correlation reached -1.000, indicating that the model's internal uncertainty perfectly tracks external data degradation.

Failure Analysis and OOD Detection

Beyond tracking noise, $\kappa$ provides a mechanism for failure prediction. We observed that misclassified samples consistently exhibit significantly lower $\kappa$ values than correctly classified ones. This allows the model to "flag" potential errors before they occur. Furthermore, incorporating $\kappa$ into feature sets improves Out-of-Distribution (OOD) detection performance, raising the AUROC on CIFAR-10 vs CIFAR-100 tasks.

Left (A): Kappa values decrease as corruption levels increase across various noise types. Right (B): Misclassified samples show significantly lower Kappa values than correctly classified ones.

Conclusion

By replacing point embeddings with vMF distributions, we provide a mathematically grounded way to quantify uncertainty in contrastive learning. The concentration parameter $\kappa$ offers a "plug-and-play" diagnostic tool for model reliability, enabling safer deployment in real-world scenarios where data quality cannot be guaranteed. Future work will explore extending this framework to other self-supervised paradigms like Masked Autoencoders.

Summary updated

BibTeX
@misc{li2024probabilistic,
  author = {Hongwei Bran Li and Cheng Ouyang and Tamaz Amiranashvili and Matthew S. Rosen and Bjoern H. Menze and Juan Eugenio Iglesias},
  title = {{Probabilistic Contrastive Learning with Explicit Concentration on the Hypersphere}},
  year = {2024},
  eprint = {2405.16460},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.16460},
}
Figure