Connect, Not Collapse: Explaining Contrastive Learning for Unsupervised Domain Adaptation

Kendrick Shen, Robbie Jones, Ananya Kumar, Sang Michael Xie, Jeff Z. HaoChen, Tengyu Ma, Percy Liang · DOI

Introduction

In the field of machine learning, the ability to generalize from a labeled "source" domain to an unlabeled "target" domain—such as transitioning from high-resolution photographs to artistic sketches—remains a significant challenge. This problem, known as Unsupervised Domain Adaptation (UDA), has traditionally been approached through the lens of domain invariance. The prevailing theory suggested that a model must learn to ignore domain-specific features to succeed. However, recent research from Stanford University challenges this dogma, demonstrating that contrastive learning succeeds not by collapsing domains together, but by "connecting" them while maintaining their distinct identities.

The Shift from Invariance to Connectivity

Standard UDA methods often employ adversarial training to force the network to produce features where the source and target domains are indistinguishable. While intuitive, this "merging" can lead to a loss of discriminative information. In contrast, this paper investigates a simple two-stage pipeline:

  1. Contrastive Pre-training: Utilizing self-supervised algorithms like SwAV or SimCLR on the pooled unlabeled data from both domains.
  2. Linear Fine-tuning: Training a simple linear classifier (or "head") using only the labeled source data.

The authors find that this approach often matches or exceeds the performance of specialized UDA algorithms. The key insight is that contrastive learning does not hide domain differences; instead, it disentangles them from class-relevant information.

Theoretical Framework: The Stochastic Block Model

To explain this phenomenon, the researchers developed a theoretical framework based on a Stochastic Block Model (SBM). In this model, data is viewed as a graph where nodes represent images and edges represent the likelihood that one image can be transformed into another via data augmentation (e.g., cropping or color-shifting).

The success of the adaptation is governed by three critical connectivity parameters:

  • $α$ (Cross-Domain, Same-Class): The probability of an augmentation connecting a photo of a dog to a sketch of a dog.
  • $β$ (Within-Domain, Different-Class): The probability of connecting a photo of a dog to a photo of a cat.
  • $γ$ (Cross-Domain, Different-Class): The probability of connecting a photo of a dog to a sketch of a cat.

The authors posit that if augmentations provide sufficient "bridge" connectivity—specifically, if $α > γ$—the contrastive objective will naturally group the same classes across domains together in the feature space, even if the domains themselves remain distinct.

Disentanglement and Orthogonality

One of the paper's most striking findings is the "Disentanglement Discovery." In contrastive feature space, domain information is actually preserved and easily identifiable—often more so than in models specifically designed for domain invariance (like DANN).

The model achieves this by partitioning information into different feature dimensions. Empirically, the researchers demonstrated that the weight vectors the model uses to identify a class are nearly orthogonal (approximately 90 degrees apart) to the weights used to identify a domain. This separation allows a linear classifier to focus exclusively on the "class dimensions" while ignoring the "domain dimensions," effectively bypassing the need for domain collapse.

Empirical Validation

The authors validated their theory across several rigorous computer vision benchmarks, including DomainNet, BREEDS (Living-17 and Entity-30), and STL-10 → CIFAR-10. Key results include:

  • Competitive Performance: On DomainNet, contrastive pre-training (SwAV) achieved 44.91% accuracy, nearly matching the specialized DANN method (45.81%).
  • Superiority on Complex Tasks: On the Entity-30 benchmark, contrastive pre-training outperformed the best baseline by 3.1%.
  • Predictive Power: The theoretical ratio of connectivity ($α/γ$) proved to be a highly accurate predictor of empirical performance, with an $R^2$ value of 0.78.

Conclusion and Future Directions

The research suggests that the "glue" of UDA is not the elimination of domain variance, but the strategic use of data augmentations to create connectivity. By providing a bridge between domains, augmentations allow the underlying class structure to transfer without sacrificing the richness of the data.

While the study relies on a stylized SBM and acknowledges a high sensitivity to the choice of augmentations, it opens a new path for UDA research. Rather than focusing on forcing domain invariance, future efforts should prioritize designing augmentations and data selection strategies that maximize cross-domain connectivity.

Summary updated

BibTeX
@inproceedings{shen2022connect,
  author = {Kendrick Shen and Robbie Jones and Ananya Kumar and Sang Michael Xie and Jeff Z. HaoChen and Tengyu Ma and Percy Liang},
  title = {{Connect, Not Collapse: Explaining Contrastive Learning for Unsupervised Domain Adaptation}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=e9SBpJ6jsfy},
}
Figure