PCL: Proxy-based Contrastive Learning for Domain Generalization

Xufeng Yao, Yang Bai, Xinyun Zhang, Yuechen Zhang, Qi Sun, Ran Chen, Ruiyu Li, Bei Yu

Introduction

Domain Generalization (DG) aims to train models on multiple "source" domains (e.g., photos, sketches, and cartoons) such that they perform robustly on entirely unseen "target" domains. A common strategy in DG is Contrastive Learning (CL), which aligns features by pulling "positive" pairs (same class) together and pushing "negative" pairs (different classes) apart.

However, this paper identifies a critical flaw in standard CL for DG: the positive alignment problem. In datasets like PACS, the distribution gap between domains is massive. Forcing a model to perfectly align a minimalist line-drawing (sketch) with a high-resolution photo of the same object can distort the feature space, ultimately degrading generalization performance.

Comparison of standard contrastive loss and the proposed proxy-based approach on the PACS benchmark.

Methodology: Proxy-based Contrastive Learning (PCL)

To mitigate the issues of direct sample-to-sample alignment, the authors propose Proxy-based Contrastive Learning (PCL). Instead of comparing samples directly, PCL compares samples to proxies—learnable representative vectors for each class.

Key Components

  • Proxy-to-Sample Relations: By pulling samples toward a central class proxy rather than toward each other, the model avoids the "tug-of-war" caused by trying to align disparate cross-domain images. The proxy acts as a stable semantic anchor.
  • Projection Heads: Multi-layer perceptrons (MLPs) map both sample embeddings and proxy weights into a specialized space optimized for contrastive loss calculation.
  • In-domain Negative Sampling: The model prioritizes pushing apart negative pairs (different classes) that originate from the same domain. These pairs provide a cleaner signal for learning discriminative features without the noise of cross-domain distribution shifts.
  • Hybrid Loss Function: The final objective function integrates a standard Softmax Cross-Entropy loss with the novel PCL loss to ensure both classification accuracy and robust feature representation.

Geometric Intuition and Key Insights

The core innovation of PCL lies in treating proxies as buffers. In a standard contrastive setup, a "sketch dog" is forced to be identical to a "photo dog." In PCL, both only need to be similar to the "dog proxy." This allows the model to maintain domain-specific nuances while capturing shared semantic essence.

Visualization of feature alignment on a hypersphere: contrastive-based loss (left) vs. proxy-based loss (right).

As shown in the hypersphere visualization, the proxy-based approach prevents the feature space from becoming overly constrained by difficult cross-domain positive pairs. The authors found that adding a direct "positive alignment" objective to a standard baseline actually decreased accuracy on PACS (from 88.1% to 86.7%), confirming that over-alignment is counterproductive for generalization.

Experimental Results

PCL sets new state-of-the-art (SOTA) benchmarks across several major DG datasets using a ResNet-50 backbone:

  • PACS: Achieved 90.2% average accuracy, significantly outperforming the previous SOTA of 88.1%.
  • Office-Home: Reached 71.6% average accuracy.
  • DomainNet: Achieved 47.7%, demonstrating scalability to large-scale datasets with hundreds of classes.
  • Learning from Scratch: In scenarios without ImageNet pre-training (e.g., Cifar100), PCL showed even more robust gains, improving top-1 accuracy by approximately 4-5% over standard Softmax baselines.

Conclusion

PCL addresses the fundamental tension between feature alignment and domain diversity in Contrastive Learning. By replacing sample-to-sample comparisons with stable proxy-to-sample relations, the method provides a more robust framework for Domain Generalization. While the approach sacrifices some fine-grained semantic relations between individual samples, the gain in stability and generalization across diverse domains makes it a powerful tool for real-world computer vision tasks.

Summary updated

BibTeX
@inproceedings{yao2022pcl,
  author = {Xufeng Yao and Yang Bai and Xinyun Zhang and Yuechen Zhang and Qi Sun and Ran Chen and Ruiyu Li and Bei Yu},
  title = {{PCL: Proxy-based Contrastive Learning for Domain Generalization}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  doi = {10.1109/cvpr52688.2022.00696},
}
Figure