NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SelfReg: Self-supervised Contrastive Regularization for Domain Generalization

Daehee Kim, Seunghyun Park, Jinkyu Kim, Jaekoo Lee

Introduction

Deep learning models often struggle when the training and test data distributions differ, a phenomenon known as "domain shift." Changes in environmental factors like lighting, artistic style, or background can cause significant performance degradation. Domain Generalization (DG) seeks to address this by training models on multiple source domains to learn features that generalize to entirely unseen target domains.

While contrastive learning has emerged as a powerful tool for extracting domain-invariant features, traditional methods typically rely on "negative pairs"—samples from different classes—to prevent representation collapse. However, identifying effective negative pairs is computationally intensive and can lead to training instability. SelfReg introduces a novel regularization framework that achieves state-of-the-art DG performance using only positive data pairs, mapping same-class samples from different domains close together in the latent space.

Methodology

The SelfReg framework is built upon several key components designed to enforce domain invariance while maintaining training stability.

Overview of the SelfReg architecture and its regularization block.

In-batch Contrastive Regularization

Unlike standard contrastive approaches, SelfReg focuses exclusively on positive pairs. It minimizes the distance between samples that share the same class label but originate from different domains. This forces the model to ignore domain-specific "noise" (like texture or style) and focus on core semantic features.

Class-specific Domain Perturbation Layer (CDPL)

To prevent the model from collapsing all representations into a single point—a common risk when using only positive pairs—the authors introduce the CDPL. This small MLP projection head adds a layer of complexity, ensuring the model aligns features across domains while still retaining the nuances necessary to distinguish between different classes.

Heterogeneous In-batch Dissimilarity Loss

SelfReg employs an "inter-domain mixup" strategy to further enhance robustness. By creating synthetic features through the interpolation of same-class samples from different domains, the model is forced to generalize to the feature space between known domains. This is particularly effective for challenging target domains like "Sketch" in the PACS dataset.

Gradient Stabilization and SWA

Contrastive losses can sometimes dominate the standard classification loss, leading to suboptimal convergence. SelfReg mitigates this through loss clipping, which scales the regularization gradient based on the classification loss. Additionally, Stochastic Weight Averaging (SWA) is used to find flatter minima in the loss landscape, which are generally more robust to domain shifts.

Experimental Evaluation

The effectiveness of SelfReg was validated on two primary benchmarks:

  • PACS: A standard DG benchmark consisting of four domains (Photo, Art Painting, Cartoon, and Sketch) characterized by significant stylistic shifts.
  • DomainBed: A comprehensive evaluation suite for DG that includes seven diverse datasets: ColoredMNIST, RotatedMNIST, VLCS, PACS, OfficeHome, TerraIncognita, and DomainNet.

Discussion of Results

SelfReg demonstrates superior performance across both benchmarks, characterized by high accuracy and remarkable stability.

Quantitative Performance

On the PACS dataset, SelfReg achieved an average accuracy of 83.62%, a 1.52% improvement over previous state-of-the-art methods like RSC. Furthermore, the method exhibited significantly lower variance (0.3 vs. 0.9 for competitors), indicating more reliable training. In the DomainBed benchmark, SelfReg ranked 2nd overall among 15 algorithms, showing particular strength on the large-scale DomainNet dataset.

Qualitative Analysis

The success of the alignment strategy is clearly visible in t-SNE visualizations of the latent space.

t-SNE visualizations comparing the baseline, RSC, and SelfReg on the PACS dataset.

As shown in the visualizations, SelfReg successfully merges clusters of the same class from different domains into tight, cohesive groups. In contrast, baseline models often leave these clusters fragmented by domain, failing to achieve true domain invariance. This qualitative evidence confirms that by forcing a "Dog" in a Sketch domain to align with a "Dog" in a Photo domain, the model learns to prioritize high-level geometric features over low-level textures.

Conclusion

SelfReg presents a streamlined and effective approach to Domain Generalization. By leveraging self-supervised contrastive regularization with only positive pairs, it avoids the complexities and instabilities associated with negative sampling. While the current implementation relies on class labels and introduces some computational overhead via mixup layers, its performance on competitive benchmarks like DomainBed underscores its potential. Future research may explore extending SelfReg to unsupervised settings or incorporating Siamese network architectures for more sophisticated pair selection.

Summary updated

BibTeX
@inproceedings{kim2021selfreg,
  author = {Daehee Kim and Seunghyun Park and Jinkyu Kim and Jaekoo Lee},
  title = {{SelfReg: Self-supervised Contrastive Regularization for Domain Generalization}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00948},
}
Figure