An Empirical Investigation of Domain Generalization with Empirical Risk Minimizers

Shanmukha Ramakrishna Vedantam, David Lopez-Paz, David J. SchwabNeurIPS 2021 · OpenReview

The Challenge of Domain Generalization

In machine learning, Domain Generalization (DG) is the "holy grail" of robustness. The goal is to train a model on several related source environments (e.g., photos and cartoons of dogs) so that it performs reliably on a completely unseen target environment (e.g., sketches of dogs).

Recently, the field was shaken by the "DomainBed" benchmark, which demonstrated that simple Empirical Risk Minimization (ERM)—standard training without specialized DG algorithms—often achieves state-of-the-art performance. However, the community lacks a clear understanding of why or when ERM generalizes.

Target accuracy varies widely for models with similar source accuracy across different datasets.

As shown in the figure above, models that achieve the exact same accuracy on their training (source) domains can exhibit wildly different accuracies on unseen target domains. This variance highlights a critical problem: in-domain validation accuracy is not always a reliable predictor of out-of-distribution (OOD) success.

Methodology: Predicting Generalization

To understand this phenomenon, the researchers conducted a massive empirical study, training approximately 12,000 deep neural networks across various hyperparameters on three popular DG benchmarks: RotatedMNIST, VLCS, and PACS.

Experimental setup: Models are trained on labeled source domains and evaluated using unlabeled test inputs to predict generalization.

Their methodology involved two main thrusts:

  1. Testing Classical Theory: They calculated the terms of the seminal Ben-David et al. (2007) domain adaptation bound. This theory suggests that OOD error is limited by source domain error, the "distance" between domains ($\mathcal{H}$-divergence), and a constant representing the best possible joint error.
  2. Evaluating Empirical Measures: Because theoretical bounds often prove loose in deep learning, the authors tested a catalog of empirical measures to see which correlated best with actual OOD accuracy. These included predictive entropy, Jacobian norm, Fisher information, and maximum mean discrepancy (MMD).

Key Insights and Results

Classical Theory is "Slack"

While the Ben-David theory is mathematically sound, the researchers found that the bounds it provides are very loose in the context of deep neural networks. High $\mathcal{H}$-divergence—meaning the domains look very different to the model—does not necessarily mean the model will fail to generalize. Using Spearman’s rank correlation ($\rho$) to measure predictive power (where 1.0 is perfect), classical $\mathcal{H}$-divergence scored a mere $\rho = 0.151$, highlighting its failure to provide a practical ranking of model quality for DG.

The Power of Predictive Entropy

The most surprising and actionable insight was the predictive power of Predictive Entropy on the target data. If a model is confident (exhibits low entropy) when processing the new, unseen domain—even without access to labels—it is highly likely to be accurate.

Predictive Entropy on the target domain was the strongest single predictor of OOD performance ($\rho = 0.734$), even outperforming standard in-domain validation accuracy ($\rho = 0.712$) in some settings.

Sensitivity and Smoothness Matter

Measures evaluating the "flatness" or "smoothness" of the learned function also proved to be strong predictors, significantly outperforming theoretically motivated domain-distance measures:

  • Fisher Alignment: $\rho = 0.441$ (measures sensitivity to changes in the model's own parameters).
  • Jacobian Norm: $\rho = 0.420$ (measures sensitivity to small changes in the input).

Furthermore, when combining these measures with in-domain accuracy, the predictive power for Jacobian and MMD-based measures jumped significantly (above 0.75), suggesting these metrics capture complementary information about the model's robustness.

Limitations and Future Directions

While this empirical investigation provides valuable practical guidance, it has limitations. The study identifies what correlates with success but does not yet offer a new, tight mathematical theory to replace the classical bounds it critiques. Additionally, the best predictors, like Target Entropy, require access to unlabeled data from the test domain. In a strictly "blind" DG scenario, this data might not be available during model selection.

Ultimately, these findings encourage the community to look beyond traditional domain-adaptation distance metrics. By focusing on the intrinsic properties of neural networks—such as predictive confidence and functional smoothness—we can build a more reliable understanding of when and why deep networks generalize out-of-distribution.

Summary updated

Abstract

Recent work demonstrates that deep neural networks trained using Empirical Risk Minimization (ERM) can generalize under distribution shift, outperforming specialized training algorithms for domain generalization. The goal of this paper is to further understand this phenomenon. In particular, we study the extent to which the seminal domain adaptation theory of Ben-David et al. (2007) explains the performance of ERMs. Perhaps surprisingly, we find that this theory does not provide a tight explanation of the out-of-domain generalization observed across a large number of ERM models trained on three popular domain generalization datasets. This motivates us to investigate other possible measures—that, however, lack theory—which could explain generalization in this setting. Our investigation reveals that measures relating to the Fisher information, predictive entropy, and maximum mean discrepancy are good predictors of the out-of-distribution generalization of ERM models. We hope that our work helps galvanize the community towards building a better understanding of when deep networks trained with ERM generalize out-of-distribution.
BibTeX
@inproceedings{vedantam2021empirical,
  author = {Shanmukha Ramakrishna Vedantam and David Lopez-Paz and David J. Schwab},
  title = {{An Empirical Investigation of Domain Generalization with Empirical Risk Minimizers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=Z8mLxlpSyrJ},
}
Figure