Year: 2021

Abstract:
The domain generalization (DG) problem setting challenges a model trained on multiple known data distributions to generalise well on unseen data distributions. Due to its practical importance, a large number of methods have been proposed to address this challenge. However most of the work in general purpose DG is heuristically motivated, as the DG problem is hard to model formally; and recent evaluations have cast doubt on existing methods’ practical efficacy – in particular compared to a well chosen empirical risk minimisation baseline. We present a novel learning-theoretic generalisation bound for DG that bounds novel domain generalisation performance in terms of the model’s Rademacher complexity. Based on this, we conjecture that existing methods’ efficacy or lack thereof is a variant of the standard empirical risk-predictor complexity trade-off, and demonstrate that their performance variability can be explained in these terms. Algorithmically, this analysis suggests that domain generalisation should be achieved by simply performing regularised ERM with a leave-one-domain-out cross-validation objective. Empirical results on the DomainBed benchmark corroborate this.

heading: 1 INTRODUCTION
text: Machine learning systems have shown exceptional performance on numerous tasks in computer vision and beyond. However performance drops rapidly when the standard assumption of i.i.d. training and testing data is violated. This domain-shift phenomenon occurs widely in many applications of machine learning (Csurka, 2017; Zhou et al., 2021; Koh et al., 2021), and often leads to disappointing results in practical machine learning deployments, since data ‘in the wild’ is almost inevitably different from reference training sets.
Given the practical significance of this issue, a large number of methods have been proposed that aim to improve models’ robustness to deployment under a different distribution than used for training (Zhou et al., 2021), a problem setting known as domain generalisation (DG). These methods span diverse approaches such as specialised neural architectures, data augmentation strategies, and regularisers. Nevertheless, the DG problem setting is difficult to model formally for principled derivation and theoretical analysis of algorithms, the target domain of interest is unobservable during training, and cannot be directly approximated by the training domains due to unknown distribution shift. Therefore the majority of these existing approaches are based on poorly understood empirical heuristics.
To make matters worse, a recent study by Gulrajani & Lopez-Paz (2021) assessed the state of DG research with a carefully conducted comparative evaluation of algorithms on a large benchmark suite under a common platform. They found that published methods were not as effective as claimed, and in particular reported that ‘no existing method reliably beats a well tuned empirical risk minimization (ERM) baseline’. We argue that this negative result highlights the need for better theory in this area in order to understand why existing algorithms have such erratic performance, and to guide the development of principled algorithms that are more effective and reliable.
To this end, our first contribution is to present an intuitive learning-theoretic bound for DG performance. Intuitively, while the held-out domain of interest is indeed unobservable during training, we can bound its performance using learning theoretic tools similar to the standard ones used to bound the performance on (unobserved) testing data given (observed) training data. In particular we show that the performance on a held out target domain is bounded by the performance on known source
domains, plus two additional model complexity terms, that describe how much a model can possibly have overfitted to the training domains. This theoretical contribution leads to several insights.
Firstly, our theory suggests that DG performance is governed by a trade-off between empirical risk and model complexity that is analogous to the corresponding and widely understood trade-off that explains generalisation in standard i.i.d. learning as an overfitting-underfitting trade-off (Geman et al., 1992). Based on this, we hypothesise that performance variability is determined by implicit or explicit regularisation. That is, the plethora of different strategies available (Zhou et al., 2021) – from data-augmentation to specialised optimisers – actually affect DG performance by explicitly or implicitly choosing different fit-complexity trade-offs. We corroborate this hypothesis by evaluating a number of models in the DomainBed suite in terms of complexity, and showing that their apparently erratic performance in Gulrajani & Lopez-Paz (2021) is actually consistent with an explanation in terms of implied complexity.
Practically, our analysis suggests that the model selection strategy (Hastie et al., 2009) is a factor in DG performance that is at least as important as the actual mechanism of model complexity control (i.e., Tuning of regularisation strength vs specific parametric design of regulariser). In particular, regularisation should be stronger when optimizing for future DG performance than when optimizing for performance on seen domains. Unfortunately, model complexity is hard to carefully control in deep learning due to the large number of relevant factors (architecture, regularisers, implicit regularisation from optimiser, etc). Gulrajani & Lopez-Paz (2021) attempted to address this by hyper-parameter search in the DomainBed benchmark, but are hampered by the computational infeasibility of accurate hyper-parameter search. In this paper, we use linear models and off-the-shelf self-supervised features to demonstrate much more clearly how cross-domain performance depends on complexity. Specifically, our theoretical and empirical results show that, contrary to the conclusion of Gulrajani & Lopez-Paz (2021), simple domain-wise cross-validation is a better objective to drive DG model selection.
In summary, based on our new generalisation bound, and associated empirical analysis, our takehome messages are: (i) Model fit vs complexity trade-off is a key determinant of DG performance, that explains existing DG algorithm performance variability. (ii) The complexity control strategy used to determine bias-variance trade-off is crucial in practice, with peak DG performance achieved when optimizing model complexity based on domain-wise validation. (iii) Regularisation required for optimal DG is greater than for conventional optimization for within-domain performance.

heading: 2 RELATED WORK
text: Theoretical Analysis of the DG Setting and Algorithms The DG problem setting was first analysed in Blanchard et al. (2011). Since then there have been some attempts to analyse DG algorithms from a generalisation bound perspective (Muandet et al., 2013; Blanchard et al., 2021; Hu et al., 2020; Albuquerque et al., 2020; Rosenfeld et al., 2021). However these studies have theoretical results that are either restricted to specific model classes, such as kernel machines, or make strong assumptions about how the domains seen during training will resemble those seen at test time—e.g., that all domains are convex combinations of a finite pre-determined set of prototypical domains. In contrast, our Rademacher complexity approach can be applied to a broad range of model classes (including neural networks), and makes comparatively milder assumptions about the relationship between domains—i.e., they are i.i.d. samples from another arbitrary distribution over domains.
The majority of the existing work investigating the theoretical foundations of DG follow the initial formalisation of the domain generalisation problem put forth by Blanchard et al. (2011), where the goal is to minimise the expected error over unseen domains. However, several recent works have also explored the idea of bounding the error on a single unseen domain with the most pathological distribution shift (Janzing, 2019). This type of analysis is typically rooted in methods from causal inference, rather than statistical learning theory. As a consequence, they are able to make stronger claims for the problems they address, but the scope of their analysis is necessarily limited to the scenarios where their assumptions about the underlying causal structures are valid. For example, Janzing (2019) provides bounds that assume problems conform to a specific class of structural equation models, and the analysis is performed under the assumption that infinite training data is available within each of the observed training domains. Throughout the work we address the stan-
dard DG formalisation given by Blanchard et al. (2011), where one is concerned with the expected performance of a model on domains sampled from some distribution over domains.
Others rely on trying to link between domain adaptation objectives (where target domains are observable for alignment to source domains) and domain generalisation (where target domains are not observable and thus cannot correctly be used in a learning objective). Albuquerque et al. (2020) proceed by making assumptions on the structure of the distribution over possible domains (i.e., that it has support determined by the convex hull of a finite set of prototypical domains), which allows them to upper bound the domain alignment metric. Ye et al. (2021) provide a bound that depends on an unobservable domain distance quantity, which they then approximate in experiments using kernel density estimates.
Rosenfeld et al. (2021) is another piece of work that theoretically investigates the generalisation of ERM in a DG setting. They deal with online DG, where each time-step corresponds to observing a new domain, and the learner must produce a new model capable of generalising to novel domains. Another point of difference between their work and the standard DG problem setting of Blanchard et al. (2011) is that the domain at each time-step is chosen by an adversary. They analyse this game for a finite number of time-steps, but they assume each domain has an infinite amount of data. They also put some limitations on the adversary: e.g., it must choose a domain that is a convex combination of a finite number of pre-determined domains. In contrast, our theoretical analysis is in the more realistic setting where one has a finite amount of data per domain, and the domains we consider are not limited to convex combinations of a set of prototypical domains. Possibly the most similar work to our theoretical contributions is due to Ahuja et al. (2021), who also provide learningtheoretic generalisation bounds for DG. However, their analysis only applies to finite hypothesis classes (which does not include, e.g., linear models or neural networks), whereas ours can be applied to any class amenable to analysis with Rademacher complexity.
Empirical Analysis The main existing empirical analysis on DG is Gulrajani & Lopez-Paz (2021), who compared several state of the art DG methods under a common evaluation and hyper-parameter tuning protocol called DomainBed. They ultimately defend Empirical Risk Minimization (ERM) over more sophisticated alternatives on the grounds that no competitor consistently beats it across the benchmark suite. We also broadly defend ERM, and build on the same benchmark, but differently we provide a much deeper analysis into when and why ERM works. More specifically: (i) We provide a new theoretical analysis of ERM’s generalisation quality unlike the prior purely empirical evaluation, (ii) We re-use the DomainBed benchmark to directly corroborate this theory under controlled conditions using linear models where model complexity can be tractably and accurately tuned. (iii) We use our complexity-based analysis to explain the previously erratic results of prior DomainBed competitors in terms of model complexity. (iv) We identify, and empirically validate, the preferred model selection criterion for DG, a point which was inconclusive in Gulrajani & Lopez-Paz (2021).

heading: 3 BOUNDING RISK FOR DOMAIN GENERALIZATION
text: I.i.d. learning is concerned with learning a mapping from some input space X , to a label space Y , given data drawn from a distribution on X × Y . One aims to find a model, f∗ ∈ F , that minimises the expected loss (also called risk) on unseen data,
f∗ = arg min f∈F Lp(f), Lp(f) = E(~x,y)∼p[`(f(~x), y)], (1)
where p is the data distribution and `(·, ·) is the loss function. In practice, we only have access to a finite set of data, S = {(~xi, yi)}mi=1, sampled i.i.d. from this distribution, so must minimise an empirical risk estimate,
f̂ = arg min f∈F
L̂p(f), L̂p(f) = 1
m m∑ i=1 `(f(~xi), yi). (2)
wherem is the number of training examples. One of the central focuses of statistical learning theory is to bound the difference between these two types of risk. For example, in the standard single domain setting this can be done via
Lp(f) ≤ L̂p(f) + 2Rm(F) +O (√ ln(1/δ) m ) , (3)
which holds with probability at least 1− δ, andR(F) is known as the empirical Rademacher complexity of the hypothesis class, F . This complexity term is defined as
Rm(F) = E~σ [ sup f∈F 1 m m∑ i=1 σi`(f(~xi), yi) ] . (4)
For a hypothesis class consisting of norm-constrained linear classifiers, one can achieve the following upper bound on the empirical Rademacher complexity (Shalev-Shwartz & Ben-David, 2014),
Rm(F) ≤ XB√ m , F = {~x 7→ ~x · ~w : ‖~w‖2 ≤ B},
where we assume that each input, ~x, has a Euclidean norm of at mostX . There are a variety of ways to define hypothesis classes for neural networks, but most recent approaches take the view of fixing a particular architecture and specifying constraints on the norms of weights or distances they can move from their initialisations (Bartlett et al., 2017; Neyshabur et al., 2019; Gouk et al., 2021).
Domain generalisation. While standard i.i.d. learning assumes all data come from the same distribution, the DG problem setting assumes the existence of an environment E , of distributions p (Blanchard et al., 2011). Note that we do not restrict what types of differences one could see between different domains sampled from E : for any two distributions in p, qsupp(E) it could be the case that either p(~x) 6= q(~x), or p(y|~x) 6= q(y|~x), or even that both types of distribution shift have occurred. The conceptually simplest—and often implicitly assumed—goal of DG methods is to minimise the expected risk across different distributions that could be sampled from the environment,
LE(f) = Ep∼E [Lp(f)]. (5)
This object is also the most commonly analysed idealised objective in the learning theory literature (Blanchard et al., 2011; Muandet et al., 2013; Blanchard et al., 2021; Rosenfeld et al., 2021), but other formulations also exist (Arjovsky et al., 2019). As with the single domain learning problem, we only have access to an empirical estimate of the risk,
L̂E(f) = 1
n n∑ j=1 L̂pj (f), (6)
where we assume for ease of exposition that all n domains have the same number of examples.

heading: 3.1 BOUNDING THE GENERALISATION GAP
text: We next bound the generalisation gap between the observed empirical risk, L̂E , on the source domains and the expected risk, LE , on unseen domains that holds uniformly for all hypotheses in F . Theorem 1. For a 1-Lipschitz loss, `(·, ·), taking values in [0, 1], with confidence at least 1− 2δ for all f ∈ F we have that
LE(f) ≤ L̂E(f) + 2Rmn(F) + 2Rn(F) + 3 √
ln(2/δ) 2mn + 3
√ ln(2/δ)
2n ,
where n is the number of training domains andm is the number of training examples in each training domain.
The proof can be found in Appendix A.
Discussion Theorem 1 tells us that expected risk on unseen domains is bounded by the empirical risk (training loss) on seen domains, plus Rademacher complexity terms and sampling error terms that decay with the number of domains and training instances per domain. As with typical singledomain bounds, the latter sampling error terms are not under control of the model designer. The former Rademacher terms describe the complexity of the chosen model class and govern how much it could possibly overfit to the seen domains while minimising empirical risk. In the case of linear models, these terms depend on weight norms, while in the case of deep models they further depend on properties of the chosen network architecture. Mirroring conventional generalisation in standard i.i.d. learning, a very simple model may minimise the Rademacher terms, R, while producing high
empirical risk, L̂E , and vice-versa. Thus good generalisation critically depends on a carefully chosen empirical risk vs model complexity trade-off. The difference between Theorem 1 and single domain bounds (e.g., Equation 3) is the additional dependence on the number of domains n and additional Rademacher complexity term. This implies that when the goal is to generalise to new domains, the risk of overfitting is higher. Therefore we expect a lower complexity model to me optimal for held out domain performance compared to seen domain performance in standard i.i.d. learning.

heading: 3.2 BOUNDING THE EXCESS RISK OF ERM
text: As a second theoretical contribution, we next bound the excess expected risk between the ERM solution f̂ and the best possible model f∗ within the function class F . Note that bounding excess risk, as opposed to the generalisation gap, overcomes some of the known issues with theoretically analysing the generalisation properties of deep networks (Belkin et al., 2018).
Corollary 1. With probability as least 1 − 2δ, the excess risk of the empirical risk minimiser in F is bounded as
E[LE(f̂)− LE(f∗)] ≤ 2Rmn(F) + 2Rn(F) + 2 √
ln(2/δ) 2mn + 2
√ ln(2/δ)
2n ,
The proof (in Appendix B) uses the same technique as the usual proof for excess risk (see, e.g., Pontil & Maurer (2013)), and some of the intermediate results required for Theorem 1.
Discussion Corollary 1 tells us that the gap between ERM and the best possible predictor in the function class depends on the same complexity terms observed in Theorem 1. In particular, for any typical hypothesis class, ERM converges to the optimal classifier at a rate of O(1/ √ mn) + O(1/ √ n). To justify itself theoretically, any future DG method that claims to be better than ERM should either: (1) demonstrate a faster convergence rate than this—at least by an improved constant factor; or (2) formally show that the chosen hypothesis class is composed of models that can extrapolate to new domains without additional data. The latter would likely involve making specific assumptions about the underlying data generation process, coupled with analysis of a specific hypothesis class using methods from causal inference. An example of such analysis is given by Janzing (2019). Methods based on causal inference have the potential to give bounds with much better convergence rates than the rate given above. However, because one must make assumptions about the underlying family of structural equation models, the applicability of such bounds is much more restricted than our Rademacher complexity technique, which does not require these assumptions.

heading: 4 EXPERIMENTS
text: Based on our previous theoretical analysis, we conduct experiments on DomainBed (Gulrajani & Lopez-Paz, 2021). In particular we aim to address the following questions: (1) Theorem 1 shows that novel domain generalisation performance is governed by empirical-risk complexity trade-off. Can we directly demonstrate the dependence of generalisation on complexity by controlling for model complexity? (2) Can the erratic performance of state of the art methods previously observed on DomainBed be explained in terms of model complexity? (3) Given that model complexity is a crucial determinant of generalisation, what is the best objective for tuning regularisation strength?

heading: 4.1 DOMAIN GENERALISATION PERFORMANCE DEPENDS ON MODEL COMPLEXITY
text: To directly investigate the impact of model complexity on domain generalisation performance, we first work with Linear SVM applied to pre-computed deep features1. In this function class model complexity can be directly controlled by a scalar hyper-parameter, the objective is convex so confounding factors in deep network training (optimiser choice, early stopping, etc) disappear, and training is fast enough that we can densely and exhaustively evaluate a wide range of complexities.
1Note that when a fixed feature extractor, or any other preprocessing is used, it does not impact the model complexity or associated generalisation bound.
Setup We use DINO (Caron et al., 2021) pre-trained models, such as DINO-ViTB8 and DINOViTS8 to extract features, and then train LinearSVC classifiers. We experiment on six different DG benchmarks, including RotatedMNIST (Ghifary et al., 2015), PACS (Li et al., 2017), VLCS (Fang et al., 2013), OfficeHome (Venkateswara et al., 2017), SVIRO (Dias Da Cruz et al., 2021) and Terra Incognita (Beery et al., 2018). Different trials have different numbers of training instances in practice, so we used a linear SVM objective of the form Cn ∑n i `(fw(xi), yi)+‖w‖2, with parameter C controlling the complexity of model w through loss-regularisation trade-off. We searched a wide range of log2 C in {−10, . . . , 10}. We then conduct two experiments, holding training and test split size constant across both: (i) Training on the train splits of all domains, and testing on the test splits of all domains (i.e., standard i.i.d. learning). (ii) Training on the train splits of three domains, and testing on the test splits of a held out domain (i.e., DG performance).
Results The results in Fig 1 average over 5 random seeds for dataset splitting, and all choices of hold-out target domain. From these we can see that: (i) all experiments exhibit the classic trade-off between fitting the data well and constraining hypothesis class complexity appropriately. We observe underfitting for high regularisation (small C), and overfitting at low regularisation (large C). (ii) Comparing the within- and across-domain evaluation: across-domain leads to lower performance— which is to be expected, due to the distribution shift. A more noteworthy observation is that, the optimal regularisation for novel-domain performance is stronger than for seen-domain performance (red vertical lines left of blue). This corroborates our theoretical result that the ideal model complexity is lower for DG than for conventional i.i.d. learning. Note that these results are using an exhaustive oracle to explore mode complexity, and do not constitute a complete algorithm, which would need to chose a specific complexity. We discuss an algorithm in Sec 4.3.

heading: 4.2 EXPLAINING DOMAINBED DG PERFORMANCE IN TERMS OF COMPLEXITY
text: Our experiment in Section 4.1 showed that linear models exhibit a very clean trade-off between complexity and generalization. However there are many subtle factors that influence effective model complexity in neural networks besides architecture: learning rate, learning rate schedule, weight decay, early stopping, etc; and the repeatably of learning is hampered by non-convexity, stochastic initialization, and stochastic mini-batches, etc. The previous evaluation study of Gulrajani & Lopez-Paz (2021) attempted some degree of control over these factors for state of the art neural DG methods by applying a common hyperparameter search strategy that aimed to find the best tuning (cf: Fig 1) for each competitor. They nevertheless found existing methods to perform unreliably. Our conjecture is that the number of seed samples (3) and hyper-parameter search trials (20) used was far too few to reliably tune the deep networks evaluated, and therefore the tuning of each model
was inaccurate and performance estimates unreliable. Since dense and accurate hyper-parameter tuning for neural networks is more challenging than our linear models in Section 4.1, we take a different approach. Rather than trying to control complexity directly, we take trained DomainBed methods and measure their complexity retrospectively.
Setup To ensure that complexity can be measured accurately, we work with 2-layer MLPs. Specifically, we take fixed ImageNet pre-trained ResNet-18 features, and feed them to MLPs, which are then trained using the DomainBed framework. 2-layer MLPs are sufficient to instantiate many of the state of the art DG algorithms in DomainBed. We train and compare ERM, CORAL (Sun & Saenko, 2016), Mixup (Wang et al., 2020), MMD (Li et al., 2018), RSC (Huang et al., 2020), SD (Pezeshki et al., 2020), VRex (Krueger et al., 2020), and IRM (Arjovsky et al., 2019) with two hyperparameter choices. We also report the results of an ERM model, checkpointed at a range of training iterations.
Measuring Model Complexity Because we have limited our attention to 2-layer MLPs, we can take advantage of a model capacity metric that is specialised for this class of models. We retrospectively determine the complexity of a trained network using the measure proposed by Neyshabur et al. (2019), who also use this measure to bound the Rademacher complexity of a 2-layer MLP hypothesis classes. More concretely, the expression used for computing complexity is
C(fU,V ) = ‖V ‖F (‖U − U0‖F + ‖U0‖2), (7)
where U is the weight matrix of the first layer, U0 is its random initialisation, and V is the weight matrix of the second layer. We use ‖·‖F to denote Frobenius norm, and ‖·‖2 to indicate the spectral norm. Note that for simplicity we have omitted constant factors that depend only on the architecture and problem setting, and not the learned weights, as we use the same architecture for all methods we investigate.
Results The results in Figure 2 summarise the trade-off between measured model complexity (xaxis), and held-out domain test accuracy (y-axis), averaged over all choices of held out domain for each dataset (See Supplementary for full breakdown across all held-out domains). The top plot compares several of the published neural DG methods implemented in DomainBed. The main message of the top plot is that results are consistent with the hypothesis that the resulting complexity of the models trained by various DG methods is a key factor in determining domain generalisation accuracy (compare Fig. 2 with the clean result for linear where models we are able to intervene and control complexity directly in Fig. 1)—thus explaining the previously erratic behaviour observed in domain-bed.
To provide a different view of the same issue, the bottom plot reports a vanilla untuned ERM model check-pointed every 300 training iterations between (up to a total of 15,000) but expressed in the same complexity units as above. Because neural models can gain complexity with iterations (see, e.g., Prechelt (1998); Hardt et al. (2016)) we also see typical overfitting-underfitting trade-off curves. This shows that, as expected, proper choice of early stopping criterion is important. It also shows that over a similar dynamic range of complexity (0.5-3), ERM (below) and alternative models (above) span a similar dynamic range of accuracy (e.g., 6% for PACS). This suggests that complexity, as controlled by whatever mechanism, is a key determinant of DG performance.
How Do DG Models Control Complexity? By introducing different modifications to standard ERM, DG models explicitly or implicitly modify the bias and variance of the function class to be learned. Gulrajani & Lopez-Paz (2021) highlight neural models as being dependent on learning rate, batch size, dropout rate, and weight decay; with other factors being choice of optimiser and weight initialiser, etc. For example, higher dropout rate and weight decay tend to reduce complexity, while some other factors influence complexity in a less transparent way. RSC introduce more sophisticated dropout-like mechanisms, which would be expected to reduce complexity. Meanwhile alignment-based methods like CORAL and MMD effectively add auxiliary losses, which will implicitly affect complexity, but are hard to explicitly link to it. Consistency based methods like IRM and VRex penalise loss variance, which also tends to reduce the generalisation gap in the single task case (Maurer & Pontil, 2009). The specific setting of all the corresponding hyper-parameters (e.g., regulariser strength, dropout rates) influence final model complexity, which we argue is the key determinant of performance.

heading: 4.3 EVALUATING LINEAR MODELS ON DOMAINBED
text: Having demonstrated control of generalisation with linear model regularisation (Sec. 4.1), and explained DomainBed performance post-hoc via measuring complexity of neural models (Sec. 4.2), we next evaluate algorithms for practical complexity tuning. From Fig. 1 we saw that within-domain and cross-domain evaluation have different optimal tuning. If we consider automating the search for a good regularisation parameter, these two final evaluation criteria correspond respectively to hyperparameter selection based on a validation set from the seen source domains, vs based on a validation set drawn from a held out source domain. The latter validation criterion corresponds to a unbiased estimator of expected cross-domain generalisation performance RE(f), which our theorem bounds.
Setup We performed DG evaluation on DomainBed using ERM with linear models using the same DINO features as Section 4.1. For each held out domain, we performed hyperparameter tuning with either instance-wise cross-validation (where validation folds are drawn from the same source domains used for training) or domain-wise cross-validation (where validation folds are drawn from held-out domains not seen during training).
Results The results in Table 1 report the average accuracy across held out domains, and the average selected logC regularisation strength (See Supplementary for the full breakdown of results for each held-out domain). We can see that the domain-wise cross-validation objective leads to similar or better accuracy, and similar or smaller C value selection (i.e., stronger regularisation). This outcome is opposite to the observation made by Gulrajani & Lopez-Paz (2021). Given the theoretical support for our domain-wise objective, and our clear empirical outcome when freed of confounding factors such as stochasticity in neural network training, we consider our result to be decisive and attribute the different observation Gulrajani & Lopez-Paz (2021) to the inaccuracy and stochasticity of hyperparameter tuning in neural networks.

heading: 4.4 DISCUSSION
text: At the start of this section we set out to address three questions, which can be answered as: (1) The dependence of cross-domain generalisation on complexity can be directly and precisely when using linear models. (2) The erratic performance of state of the art methods in DomainBed can be largely explained in terms of implied model complexity. (3) If the goal is to optimise for domain generalisation, then then domain-wise validation is preferred to instance-wise validation as a modelselection objective.
Our analysis suggests that several existing methods that tried to tune learnable DG hyper-parameters by performance on a held-out domain (Balaji et al., 2018; Li et al., 2019) were broadly on the right track, and concurs with Gulrajani & Lopez-Paz (2021) that those methods with underspecified hyperparameter and model selection procedures are unhelpful. However, given that most neural methods have many more complexity hyperparameters than the single hyperparameter that we were able to carefully control for linear models, obtaining accurate tuning and reliable performance evaluation is likely to be a challenge. Gradient-based hyper-parameter estimation methods, as initially attempted in Balaji et al. (2018); Li et al. (2019), together with efficient methods for long-inner loop hypergradient calculation (Lorraine et al., 2020), may benefit the former problem by making search in larger numbers of hyperparameters more feasible. Alternatively, using general purpose pre-trained features (Caron et al., 2021) as we did here, and focusing on learning shallow models that can be accurately tuned for DG may be another promising avenue in practice. Although achieving state of the art performance is not our focus, we note that our results in Table 1 are quite competitive with end-to-end trained state of the art (Gulrajani & Lopez-Paz, 2021), despite using fixed features and shallow models.

heading: 5 CONCLUSION
text: In this paper we explained the performance of domain generalisation methods in terms of model complexity (bias-variance trade-off) from both theoretical and empirical perspectives. Both perspectives show that complexity impacts cross-domain generalisation in a way that closely mirrors the bias-variance trade-off in conventional i.i.d. learning – but where stronger regularisation is required if optimising for cross-domain generalisation than if optimising for conventional within-domain generalisation. We clarified the preferred model selection criterion in each case. This analysis demystifies the problem being posed by the DG problem setting, why existing algorithms succeed or fail to work, and sets the bar for future theoretical theoretical studies to surpass in terms of convergence rates, as well as for future empirical studies to surpass in terms of strong baselines.

heading: A PROOF OF THEOREM 1
text: We use a slightly modified version of the standard empirical Rademacher complexity bound on generalisation error, as stated by Mohri et al. (2018) but originally shown by Bartlett & Mendelson (2002), where the modification is to weaken the i.i.d. assumption to be only an independence assumption—i.e., allow instances to be drawn from different distributions. The proof is exactly the same (because McDiarmid’s inequality requires only independence, and not identical distributions), but we re-state it here for completeness. Theorem 2. For p1, ..., pn independent samples from E , and 1-Lipschitz loss `(·, ·) taking values in [0, 1], the following holds with confidence at least 1− δ,
1
n n∑ j=1 Lpj (f) ≤ 1 n n∑ j=1 L̂pj (f) + 2Rmn(F) + 3 √ ln(2/δ) 2mn , (8)
where L̂pj (f) is measured on Spj = {(~xij , yij)}mi=1, a collection of m i.i.d. samples from pj .
Proof. Let S = Sp1 ⋃ ... ⋃ Spn and define
Φ(S) = sup f∈F
1
n n∑ j=1 (Lpj (f)− L̂pj (f)). (9)
Note that Φ(S) satisfies the bounded differences property required by McDiarmid’s inequality: i.e., if we construct S ′ by replacing any one of the (xij , yij) in S with another random variable also drawn from pj , then |Φ(S) − Φ(S ′)| ≤ 1mn . Therefore McDiarmid’s inequality implies that with confidence at least 1− δ2
Φ(S) ≤ ESp1:n∼p1:n [Φ(S)] + √ ln(2/δ) 2mn . (10)
We continue by bounding the expected value of Φ(S),
ESp1:n∼p1:n [Φ(S)] (11)
= ESp1:n∼p1:n [ sup f∈F 1 n n∑ j=1 (Lpj (f)− L̂pj (f)) ] (12)
= ESp1:n∼p1:n [ sup f∈F 1 n n∑ j=1 ( ES′pj∼pj [ 1 m m∑ i=1 `(f(~x′ij , y ′ ij) ] − 1 m m∑ i=1 `(f(~xij , yij) )] (13)
≤ ESp1:n∼p1:nES′p1:n∼p1:n [ sup f∈F 1 n n∑ j=1 1 m m∑ i=1 (`(f(~x′ij), y ′ ij)− `(f(~xij), yij)) ] (14)
= ESp1:n∼p1:nES′p1:n∼p1:nE~σ [ sup f∈F 1 n n∑ j=1 1 m m∑ i=1 σij(`(f(~x ′ ij), y ′ ij)− `(f(~xij), yij)) ] (15)
≤ ES′p1:n∼p1:nE~σ [ sup f∈F 1 n n∑ j=1 1 m m∑ i=1 σij`(f(~x ′ ij), y ′ ij) ] (16)
+ ESp1:n∼p1:nE~σ [ sup f∈F 1 n n∑ j=1 1 m m∑ i=1 −σij`(f(~xij), yij) ] (17)
= 2ESp1:n∼p1:nE~σ [ sup f∈F 1 n n∑ j=1 1 m m∑ i=1 σij`(f(~xij), yij) ] (18)
= 2ESp1:n∼p1:n [Rmn(F)], (19)
where the first inequality is from moving the supremum inside the expectation and the second is from subadditivity of suprema. Observing that the absolute difference of computing Rmn(F) on S and
S ′ cannot exceed 1mn , another application of McDiarmid’s inequality tells us that with confidence at least 1− δ2
2ESp1:n∼p1:n [Rmn(F)] ≤ 2Rmn(F) + 2 √ ln(2/δ) 2mn . (20)
Combining Equations 10 and 20 with the union bound concludes the proof.
We now prove Theorem 1.
Proof. Theorem 2 tell us that with confidence at least 1− δ,
1
n n∑ j=1 Lpj (f) ≤ L̂E(f) + 2Rmn(F) + 3 √ ln(2/δ) 2mn . (21)
Thus, we must provide a (high confidence) upper bound on
LE(f)− 1 n n∑ j=1 Lpj (f) (22)
that holds uniformly for all f ∈ F . We can use the same idea the proof for Theorem 2 to show how Rademacher complexity controls generalisation to novel domains, rather than novel instances within the same domain. Begin by letting P = {p1, ..., pn} be an i.i.d. sample of n domains from E , and define
Φ(P ) = sup f∈F LE(f)− 1 n n∑ j=1 Lpj (f). (23)
If we construct P ′ by replacing any pj ∈ P with p′j ∼ E , then we have |Φ(P ) − Φ(P ′)| ≤ 1n , so McDiarmid’s inequality tells us that with confidence at least 1− δ2
Φ(P ) ≤ Ep1:n∼E [Φ(P )] + √
ln(2/δ) 2n . (24)
We proceed by bounding the expected value of Φ(P ),
Ep1:n∼E [ sup f∈F ( Eq∼E [Lq(f)]− 1 n n∑ j=1 Lpj (f) )] (25)
= Ep1:n∼E [ sup f∈F Eq1:n∼E [ 1 n n∑ j=1 ( Lqj (f)− Lpj (f) )]] (26)
≤ Ep1:n,q1:n∼E [ sup f∈F 1 n n∑ j=1 ( Lqj (f)− Lpj (f) )] (27)
= Ep1:n,q1:n∼EE~σ [ sup f∈F 1 n n∑ j=1 σj ( Lqj (f)− Lpj (f) )] (28)
≤ 2Ep1:n∼EE~σ [ sup f∈F 1 n n∑ j=1 σjLpj (f) ] (29)
= 2Ep1:n∼EE~σ [ sup f∈F 1 n n∑ j=1 σjE(~x,y)∼pj [`(f(~x), y)] ] (30)
≤ 2Ep1:n∼EE(~xj ,yj)∼pjE~σ [ sup h∈F 1 n n∑ j=1 σj`(f(~xj), yj) ] (31)
= 2Ep1:n∼EE(~xj ,yj)∼pj [Rn(F)], (32)
where the first inequality comes from moving the supremum inside the expectation, ~σ is a vector of Rademacher random variables, the second inequality is due to the subadditivity of suprema, and the final inequality comes from moving the expectation outside of the supremum. Noting that replacing one of the (~xj , yj) pairs in the final equality will result in Rn(F) changing by at most 1n , McDiarmid’s inequality can be used to say with confidence 1− δ2 that
2Ep1:n∼EE(~xj ,yj)∼pj [Rn(F)] ≤ 2Rn(F) + 2 √
ln(2/δ) 2n . (33)
Combining Equations 21, 24, and 33 using the union bound completes the proof.

heading: B PROOF OF COROLLARY 1
text: Proof. We begin with the expected excess risk, which can be bounded from above by
ES [LE(f̂)− LE(f∗)] = ES [LE(f̂)− L̂E(f̂)] + ES [L̂E(f̂)− L̂E(f∗)] + ES [L̂E(f∗)− LE(f∗)]
(34)
≤ ES [LE(f̂)− L̂E(f̂)] + ES [L̂E(f∗)− LE(f∗)] (35) = ES [LE(f̂)− L̂E(f̂)] (36)
= ES [ LE(f̂)− 1
n n∑ j=1 Lpj (f̂)
] + ES [ 1
n n∑ j=1 Lpj (f̂)− L̂E(f̂)
] , (37)
where the inequality arises because, by definition, the empirical risk of f̂ must be less than or equal to the empirical risk of the optimal model. The second equality comes from the fact that f∗ is determined independently of the particular training set that we sample, so ES [L̂E(f∗)] = LE(f∗). For the final equality: the first term can be bounded from above (with confidence 1 − δ) using the bound for the expected value of Φ(S) derived in the proof of Theorem 2; and the second term can be bounded from above (with confidence 1 − δ) using the bound for the expected value of Φ(P ) derived in the proof for Theorem 1. Combining these two high confidence bounds using the union bound yields the result.

heading: C DETAILED RESULTS
text: Complexity Measurement for DomainBed Competitors In Figure 2 we illustrated the performance of DomainBed competitors in terms of their resulting model complexity by averaging over held-out domains for each dataset. In Figure 3, we present detailed results broken down by each held out dataset.
Detailed results on each DG benchmark In Table 1 we reported results of our linear model competitors on DomainBed summarised over choice of held out domain. In Tables 2-7, we report the detailed results of accuracy and choice of C paramater for each held out domain.

Review summaries:
This paper considers the problem of domain generalization (DG), wherein predictors are trained on a related set of training domains and evaluated on an unseen test domain.  The authors first present a learning-theoretic bound on the performance of an average-case formulation for DG, and then present a set of experiments that consider the trade-off between complexity and out-of-distribution (OOD) performance.  The experiments indicate that such trade-offs exist for linear models, and there is also evidence that the trade-off persists for shallow neural networks.

In domain generalization, recent work has shown that ERM has comparable out-of-domain accuracy to state-of-the-art DG methods. The paper aims to explain this result through model complexity. The main argument is that ood generalization requires a smaller model complexity. The upshot is that DG methods can utilize cross-domain validation to obtain better generalizing models.

This paper presents a theory of domain generalization based on statistical learning theory (Rademacher complexity) and demonstrates a trade-off between training loss and model complexity. They show that existing methods are actually controlling the model complexity. Based on the analysis, the authors argue that proper model selection is critical for complexity control. Instead of hyper-parameter search, they propose to use domain-wise cross-validation as the model selection strategy. Experiments on the DomainBed benchmark show the effectiveness of the proposed method.

This paper has several findings taking a bias-variance trade-off of DG performance, that explains existing DG algorithm performance variability. (ii) The complexity control strategy used to determine bias-variance trade-off is crucial in practice, with peak DG performance achieved when optimizing model complexity based on domain-wise validation. (iii) Regularisation required for optimal DG is greater than for conventional optimization for within-domain performance.