In Search of Lost Domain Generalization

Ishaan Gulrajani, David Lopez-Paz

Abstract: The goal of domain generalization algorithms is to predict well on distributions different from those seen during training. While a myriad of domain generalization algorithms exist, inconsistencies in experimental conditions—datasets, architectures, and model selection criteria—render fair and realistic comparisons difficult. In this paper, we are interested in understanding how useful domain generalization algorithms are in realistic settings. As a first step, we realize that model selection is non-trivial for domain generalization tasks. Contrary to prior work, we argue that domain generalization algorithms without a model selection strategy should be regarded as incomplete. Next, we implement DomainBed, a testbed for domain generalization including seven multi-domain datasets, nine baseline algorithms, and three model selection criteria. We conduct extensive experiments using DomainBed and find that, when carefully implemented, empirical risk minimization shows state-of-the-art performance across all datasets. Looking forward, we hope that the release of DomainBed, along with contributions from fellow researchers, will streamline reproducible and rigorous research in domain generalization.

The Reproducibility Crisis in Domain Generalization

Machine learning models often fail catastrophically when deployed in environments that differ from their training data—a phenomenon known as a lack of domain generalization (DG). For instance, a vision system for a self-driving car trained exclusively in sunny weather may struggle to identify obstacles in a snowstorm. While the research community has proposed numerous specialized algorithms to solve this, progress has been difficult to measure.

The authors identify a "reproducibility crisis" driven by inconsistent experimental protocols. Without a standard way to select hyperparameters or validate models without "peeking" at the test data, it becomes impossible to discern if a new algorithm's success is due to its mathematical innovation or simply a more favorable backbone architecture or a lucky hyperparameter sweep.

DomainBed: A Standardized Testbed

To address these inconsistencies, the authors introduced DomainBed, an open-source PyTorch benchmark designed to provide a level playing field for DG research. The testbed standardizes several key variables:

  1. Architectures: Most image tasks utilize a ResNet-50 backbone to ensure that performance gains are not merely the result of using larger, more modern models.
  2. Algorithm Implementations: DomainBed includes standard Empirical Risk Minimization (ERM) alongside eight specialized methods, such as Invariant Risk Minimization (IRM), Group DRO, and Domain-Adversarial Neural Networks (DANN).
  3. Model Selection Criteria: Perhaps the most critical contribution is the formalization of model selection. The authors argue that an algorithm is incomplete without a strategy to choose hyperparameters. They evaluate three realistic criteria:
  4. Training-domain validation set: Splitting training data into training and validation subsets.
  5. Leave-one-domain-out cross-validation: Training on $N-1$ domains and validating on the $N^{th}$ training domain.
  6. Test-domain validation (Oracle): Selecting the best model based on the actual test set performance. While unrealistic for deployment, this serves as an "upper bound" for potential performance.

To ensure statistical rigor, the researchers conducted an exhaustive search, training a total of 45,900 neural networks.

Benchmarking Across Diverse Datasets

The authors evaluated the suite on seven multi-domain datasets that represent a spectrum from synthetic tasks to large-scale real-world imagery:

  • Colored & Rotated MNIST: Synthetic tasks designed to test specific invariances like color and orientation.
  • VLCS & PACS: Standard benchmarks featuring diverse styles such as "Art," "Cartoon," "Photo," and "Sketch."
  • Office-Home: Images of everyday objects in four distinct settings.
  • Terra Incognita: Real-world photos of wild animals captured by various camera traps.
  • DomainNet: A massive dataset containing 345 classes across six domains (e.g., Clipart, Infographic, Painting).
The DomainBed benchmark includes seven datasets covering a wide variety of domains and shifts.

The Surprising Efficacy of ERM

The most striking finding of the study is that a well-tuned Empirical Risk Minimization (ERM) baseline—the standard method for training most neural networks—often outperforms complex, specialized DG algorithms. When ERM is given the same modern treatment as its competitors (strong data augmentation, ResNet-50 backbones, and careful tuning), it is remarkably difficult to beat.

On the PACS dataset, for example, the authors' tuned ERM achieved an average accuracy of 85.7%, surpassing the previously reported state-of-the-art of 84.5%. Across the board, ERM remained the top performer or within a fraction of a percent of the best specialized method when using realistic model selection criteria.

Dataset Previous SOTA Our ERM
Rotated MNIST 97.2% 98.0%
PACS 84.5% 85.7%
VLCS 75.9% 77.4%
Office-Home 65.5% 67.5%

Key Insights and Future Directions

The study offers several vital takeaways for the field:

  • Model Selection is Part of the Algorithm: Reporting "Oracle" results is unrealistic. Future research must include a deployment-ready model selection strategy.
  • Data Augmentation as Feature Removal: Techniques like random cropping and color jittering act as powerful DG tools by forcing models to ignore spurious features that vary across domains.
  • The "No Free Lunch" Theorem: No single specialized algorithm consistently outperformed ERM across all datasets. In many instances, the complex math intended to find "invariances" actually hindered performance.

While the results serve as a "reality check," a ~2% performance gap still exists between realistic model selection and "Oracle" selection, suggesting that hyperparameter tuning for out-of-distribution tasks remains an open challenge. The authors suggest that the field should move toward more impactful, realistic tasks, such as medical imaging across different hospitals, rather than focusing solely on stylistic shifts like "Cartoon vs. Photo."

Summary updated

Abstract

The goal of domain generalization algorithms is to predict well on distributions different from those seen during training. While a myriad of domain generalization algorithms exist, inconsistencies in experimental conditions -- datasets, architectures, and model selection criteria -- render fair and realistic comparisons difficult. In this paper, we are interested in understanding how useful domain generalization algorithms are in realistic settings. As a first step, we realize that model selection is non-trivial for domain generalization tasks. Contrary to prior work, we argue that domain generalization algorithms without a model selection strategy should be regarded as incomplete. Next, we implement DomainBed, a testbed for domain generalization including seven multi-domain datasets, nine baseline algorithms, and three model selection criteria. We conduct extensive experiments using DomainBed and find that, when carefully implemented, empirical risk minimization shows state-of-the-art performance across all datasets. Looking forward, we hope that the release of DomainBed, along with contributions from fellow researchers, will streamline reproducible and rigorous research in domain generalization.
BibTeX
@inproceedings{gulrajani2021search,
  author = {Ishaan Gulrajani and David Lopez-Paz},
  title = {{In Search of Lost Domain Generalization}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
  url = {https://openreview.net/forum?id=3dn4FoT6mdA},
}
Figure