A Message Passing Perspective on Learning Dynamics of Contrastive Learning

Yifei Wang, Qi Zhang, Tianqi Du, Jiansheng Yang, Zhouchen Lin, Yisen Wang

In the world of self-supervised learning, Contrastive Learning (CL) is a reigning champion. By teaching models to pull "similar" images together and push "dissimilar" ones apart, CL achieves remarkable results without needing a single human-provided label. But despite its empirical success, the exact learning dynamics—the "why" and "how" features evolve during training—have remained somewhat of a black box.

A recent paper, A Message Passing Perspective on Learning Dynamics of Contrastive Learning, provides a brilliant theoretical framework by bridging two seemingly unrelated fields: Contrastive Learning and Graph Neural Networks (GNNs).

Unpacking the Black Box of Learning Dynamics

While we have many successful CL recipes (like SimCLR or MoCo), existing theories often focus on the "optimal" state the model eventually reaches, ignoring the step-by-step path it takes to get there. This leaves several critical questions unanswered:

  1. Why do features sometimes "collapse" into a single point?
  2. How exactly do data augmentations (like cropping or color jittering) guide the learning process?
  3. Is there a deeper mathematical connection between CL and other architectures like Graph Neural Networks or Transformers?

The Breakthrough: CL as Message Passing

The authors tackle these questions by shifting the analysis from the model's weights to the feature space. They operate under an "unconstrained features" assumption, meaning the model is powerful enough to move features wherever the loss function dictates.

They decompose the popular InfoNCE loss into two distinct forces:

  1. Alignment: Pulling augmented views of the same image together.
  2. Uniformity: Pushing all different images apart to cover the feature space evenly.

The breakthrough insight is that the gradient descent update for Alignment is mathematically equivalent to a Graph Convolutional Network (GCN) layer acting on an "augmentation graph." Similarly, the Uniformity update corresponds to a form of "reversed" message passing on an "affinity graph"—a process strikingly similar to the Self-Attention mechanism used in Transformers.

Key Insights and Ideas

Viewing Contrastive Learning through the lens of graph message passing yields several fascinating insights:

  • CL as a Competition between Graphs: Learning is essentially a tug-of-war. The Augmentation Graph wants to cluster everything together, while the Affinity Graph wants to spread everything out. Equilibrium is reached when the model's estimated distribution matches the ground-truth data distribution.
Evolution of 2D features under different update rules: alignment causes collapse, while the full contrastive update balances alignment and uniformity.
  • Feature Collapse = Oversmoothing: In GNNs, if you pass messages too many times, all node features become identical (a known issue called oversmoothing). The authors demonstrate that "feature collapse" in CL is the exact same phenomenon, driven purely by the alignment update.
  • The Transformer Connection: The paper proves that the uniformity update in CL is essentially a gradient ascent step of a self-attention module. This provides a fresh, optimization-based explanation for why Transformers sometimes suffer from representation collapse.

GNN-Inspired Upgrades and Results

Because CL is mathematically analogous to message passing, we can borrow established "tricks" from the GNN world to improve vision models. The researchers validated these new designs on standard computer vision benchmarks (CIFAR-10, CIFAR-100, and ImageNet-100):

  1. Multi-stage Aggregation (Inspired by JK-Net): To prevent feature collapse, the authors designed a variant that aggregates features from previous epochs. Applying this to SimSiam significantly boosted performance. On ImageNet-100, a ResNet-50 went from 70.9% to 72.3% linear probing accuracy.
  2. Graph Attention (Inspired by GAT): Instead of treating all positive pairs equally, they used an attention mechanism to ignore "bad" augmentations that might crop out the object of interest. This adaptively weighted SimCLR variant improved CIFAR-10 accuracy from 88.2% to 89.4%.

These results are particularly impressive because they do not require massive new architectures—just smarter update rules derived from graph theory.

Limitations and Future Work

The primary limitation of this theoretical framework is the unconstrained feature assumption. In reality, a neural network's architecture (like the inductive bias of a ConvNet) restricts how features can move, which this theory doesn't fully account for. Additionally, the Multi-stage Aggregation technique requires a memory bank to store features from previous epochs, increasing memory overhead.

Ultimately, this message-passing perspective opens the door for exciting interleaving studies. Could CL techniques be used to solve the oversmoothing problem in GNNs? By establishing these mathematical links, the authors pave the way for a unified theory of representation learning that spans images, graphs, and text.

Summary updated

BibTeX
@inproceedings{wang2023message,
  author = {Yifei Wang and Qi Zhang and Tianqi Du and Jiansheng Yang and Zhouchen Lin and Yisen Wang},
  title = {{A Message Passing Perspective on Learning Dynamics of Contrastive Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=VBTJqqWjxMv},
}
Figure