Conditional Alignment and Uniformity for Contrastive Learning with Continuous Proxy Labels

Benoit Dufumier, Pietro Gori, Julie Victor, Antoine Grigis, Edouard DuchesnayarXiv 2021

Abstract

Standard contrastive learning losses inadvertently push all images away from each other, even when metadata suggests they should be similar. This paper, presented at NeurIPS 2021, introduces "Conditional Uniformity," a framework that leverages "free" metadata—such as a patient's age or sex—to refine the representation space. By only repelling samples with dissimilar metadata, the proposed method achieves significantly better feature representations for both natural images and medical datasets like brain MRIs.

Introduction

Contrastive learning has become a cornerstone of self-supervised learning, primarily by teaching models to pull augmented versions of the same image together (alignment) while pushing different images apart (uniformity). Methods like SimCLR have shown great success, but they typically treat all distinct images as equally "different."

In domains like medical imaging, this approach ignores valuable structural information. For instance, two brain scans from 70-year-old males likely share more underlying features than a scan from a 70-year-old and a scan from a newborn. Existing methods that attempt to incorporate such metadata, like the y-Aware InfoNCE loss, still enforce a "global uniformity" constraint. This forces all representations to spread evenly across a hypersphere, creating a conflict between metadata-driven alignment and blind global repulsion.

The Uniformity Paradox

The authors identify a "Uniformity Paradox" in standard contrastive learning. While uniformity is intended to preserve information by preventing representation collapse, forcing samples with related metadata to be far apart actually discards useful information.

Conceptual comparison between Global Uniformity (left) which repels all samples, and Conditional Uniformity (right) which allows samples with similar metadata to cluster.

Mathematical analysis reveals that the y-Aware InfoNCE loss decomposes into Conditional Alignment and Global Uniformity. The "global" component is the bottleneck, as it treats every sample pair as a negative pair regardless of their metadata similarity.

Proposed Framework: Conditional Uniformity

To resolve this, the researchers propose a framework based on two properties:

  1. Conditional Alignment: This pulls samples with similar metadata closer together in the representation space, typically using a Gaussian kernel to measure similarity.
  2. Conditional Uniformity: This is the core innovation. Instead of uniform repulsion, the model weights the "push." It strongly repels samples with very different metadata but reduces the repulsion between samples that have similar metadata.

By optimizing these properties directly, the model learns a "latent geography" that respects the underlying structure of the metadata without forcing an unnatural global distribution.

Experimental Evaluation

The approach was evaluated on natural image benchmarks (CIFAR-10/100) and a large-scale medical imaging task (BHB-10K brain MRIs).

Natural Images (CIFAR)

Using class labels as proxy metadata, the proposed method outperformed standard SimCLR and even supervised contrastive learning (SupCon) in linear evaluation accuracy. Notably, the model demonstrated faster convergence, suggesting that metadata-aware repulsion helps the model find an optimal representation space more efficiently.

Accuracy vs. Contrastive Epoch on CIFAR-10 and CIFAR-100, showing the proposed method achieving higher accuracy and faster convergence than baselines.

Medical Imaging (Brain MRI)

On the BHB-10K dataset (10,000+ 3D scans), the model was pre-trained using age and sex as metadata. When evaluated on the BIOBD clinical dataset for detecting bipolar disorder, the model showed improved Area Under the Curve (AUC) compared to models trained without conditional uniformity.

Conclusion

By replacing global uniformity with conditional uniformity, contrastive learning can more effectively leverage continuous proxy labels. This approach not only improves the quality of learned representations but also increases training efficiency. Future work will focus on handling noisy or missing metadata and extending the framework to other medical modalities like CT or X-ray scans.

Summary updated

BibTeX
@misc{dufumier2021conditional,
  author = {Benoit Dufumier and Pietro Gori and Julie Victor and Antoine Grigis and Edouard Duchesnay},
  title = {{Conditional Alignment and Uniformity for Contrastive Learning with Continuous Proxy Labels}},
  year = {2021},
  eprint = {2111.05643},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2111.05643},
}
Figure