F INDING LOST DG: E XPLAINING DOMAIN GENERALIZATION VIA MODEL COMPLEXITY
Anonymous authors
Paper under double-blind review
A BSTRACT
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 efﬁcacy – 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’ efﬁcacy 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.
I NTRODUCTION
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 signiﬁcance 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 difﬁcult 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 ﬁrst 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 overﬁtted 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 overﬁtting-underﬁtting 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 ﬁt-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 speciﬁc 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.
Speciﬁcally, 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 ﬁt 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.  R ELATED W ORK
Theoretical Analysis of the DG Setting and Algorithms The DG problem setting was ﬁrst analysed in Blanchard et al.
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 speciﬁc 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 ﬁnite 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 speciﬁc class of structural equation models, and the analysis is performed under the assumption that inﬁnite 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 ﬁnite 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 ﬁnite number of time-steps, but they assume each domain has an inﬁnite 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 ﬁnite number of pre-determined domains.
In contrast, our theoretical analysis is in the more realistic setting where one has a ﬁnite 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 ﬁnite 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 speciﬁcally: (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).
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 ﬁnd a model, f ∗ ∈ F , that minimises the expected loss (also called risk) on unseen data,
[Equation]
where p is the data distribution and (cid:96) ( · , · ) is the loss function.
In practice, we only have access to a ﬁnite set of data, S = { ( (cid:126)x i , y i ) } mi =1 , sampled i.i.d. from this distribution, so must minimise an empirical risk estimate,
[Equation]
where m 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
[Equation]
which holds with probability at least 1 − δ , and R ( F ) is known as the empirical Rademacher complexity of the hypothesis class, F .
This complexity term is deﬁned as
[Equation]
For a hypothesis class consisting of norm-constrained linear classiﬁers, one can achieve the following upper bound on the empirical Rademacher complexity (Shalev-Shwartz & Ben-David, 2014),
[Equation]
where we assume that each input, (cid:126)x , has a Euclidean norm of at most X .
There are a variety of ways to deﬁne hypothesis classes for neural networks, but most recent approaches take the view of ﬁxing 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, q supp ( E ) it could be the case that either p ( (cid:126)x ) (cid:54) =
q ( (cid:126)x ) , or p ( y | (cid:126)x ) (cid:54) =
q ( y | (cid:126)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,
[Equation]
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,
[Equation]
where we assume for ease of exposition that all n domains have the same number of examples.
3. B OUNDING THE G ENERALISATION G AP
We next bound the generalisation gap between the observed empirical risk, ˆ L E , on the source domains and the expected risk, L E , on unseen domains that holds uniformly for all hypotheses in
F .
Theorem 1.
For a 1-Lipschitz loss, (cid:96) ( · , · ) , taking values in [0 , 1] , with conﬁdence at least 1 − 2 δ for all f ∈ F we have that
[Equation]
where n is the number of training domains and m 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 overﬁt 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 overﬁtting 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.
3. B OUNDING THE E XCESS R ISK OF ERM
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
[Equation]
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 classiﬁer 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 speciﬁc assumptions about the underlying data generation process, coupled with analysis of a speciﬁc 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.
E XPERIMENTS
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?
Given that model complexity is a crucial determinant of generalisation, what is the best objective for tuning regularisation strength?
4. D OMAIN G ENERALISATION P ERFORMANCE D EPENDS ON M ODEL C OMPLEXITY
To directly investigate the impact of model complexity on domain generalisation performance, we ﬁrst work with Linear SVM applied to pre-computed deep features 1 .
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. [Figure] [Table] [Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
Setup We use DINO (Caron et al., 2021) pre-trained models, such as DINO-ViTB8 and DINOViTS8 to extract features
[Figure] and then train LinearSVC classiﬁers. We experiment on six different DG benchmarks, including RotatedMNIST (Ghifary et al., 2015), PACS (Li et al., 2017), VLCS (Fang et al., 2013), OfﬁceHome (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 (cid:80) ni (cid:96) ( f w ( x i ) , y i )+ (cid:107) w (cid:107) 2 , with parameter
C controlling the complexity of model w through loss-regularisation trade-off.
We searched a wide range of log 2 C in {− 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 ﬁtting the data well and constraining hypothesis class complexity appropriately.
We observe underﬁtting for high regularisation (small C), and overﬁtting 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 speciﬁc complexity.
We discuss an algorithm in Sec 4.3.
4. E XPLAINING D OMAIN B ED DG PERFORMANCE IN TERMS OF COMPLEXITY
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 inﬂuence 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 ﬁnd 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 ﬁxed ImageNet pre-trained ResNet-18 features, and feed them to MLPs, which are then trained using the DomainBed framework.
2-layer MLPs are sufﬁcient 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
[Equation]
where U is the weight matrix of the ﬁrst layer, U 0 is its random initialisation, and V is the weight matrix of the second layer.
We use (cid:107)·(cid:107) F to denote Frobenius norm, and (cid:107)·(cid:107) 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.
we also see typical overﬁtting-underﬁtting 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 modiﬁcations 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 inﬂuence 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 speciﬁc setting of all the corresponding hyper-parameters (e.g., regulariser strength, dropout rates) inﬂuence ﬁnal model complexity, which we argue is the key determinant of performance.
Complexity
A cc u r ac y
OfﬁceHome
CORALERMIRMMixupMMDRSCSDVRExIRM (alt) 0 .
Complexity
A cc u r ac y
PACS 0 .
Complexity
A cc u r ac y
VLCS 0 .
Complexity
[Figure]
ERMCheckpointsonOfﬁceHome 0 .
Complexity
A cc u [Figure] ac y
ERMCheckpointsonPACS 0 .
Complexity
[Figure]
ac
[Figure]
ERMCheckpointsonVLCS
4. E VALUATING L INEAR
M ODELS ON D OMAIN B ED
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 ﬁnal 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 R E ( 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 log C 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. [Table]
4. D ISCUSSION
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.
The erratic performance of state of the art methods in DomainBed can be largely explained in terms of implied model complexity.
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 underspeciﬁed 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.
; Li et al.
(2019), together with efﬁcient methods for long-inner loop hypergradient calculation (Lorraine et al., 2020), may beneﬁt 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 ﬁxed features and shallow models.
C ONCLUSION
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 clariﬁed the preferred model selection criterion in each case.
This analysis demystiﬁes 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.
A P ROOF OF T HEOREM
We use a slightly modiﬁed version of the standard empirical Rademacher complexity bound on generalisation error, as stated by Mohri et al. but originally shown by Bartlett & Mendelson (2002), where the modiﬁcation 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 p 1 , ..., p n independent samples from E , and 1-Lipschitz loss (cid:96) ( · , · ) taking values in [0 , 1] , the following holds with conﬁdence at least 1 − δ , [Equation] where ˆ L p j ( f ) is measured on S p
j = { ( (cid:126)x ij , y ij ) } mi =1 , a collection of m i.i.d.
samples from p j .
Proof.
Let S =
S p 1 (cid:83) ...
(cid:83)
S p n and deﬁne
[Equation]
Note that Φ( S ) satisﬁes the bounded differences property required by McDiarmid’s inequality: i.e., if we construct S (cid:48) by replacing any one of the ( x ij , y ij ) in S with another random variable also drawn from p j , then | Φ( S ) − Φ( S (cid:48) )
| ≤ 1 mn .
Therefore McDiarmid’s inequality implies that with conﬁdence at least 1 − δ
[Equation]
We continue by bounding the expected value of Φ( S ) ,
[Equation]
[Equation]
[Equation]
[Equation]
19) where the ﬁrst inequality is from moving the supremum inside the expectation and the second is from subadditivity of suprema.
Observing that the absolute difference of computing R mn ( F ) on S and
S (cid:48) cannot exceed 1 mn , another application of McDiarmid’s inequality tells us that with conﬁdence at least 1 − δ
[Equation]
Combining Equations 10 and 20 with the union bound concludes the proof.
We now prove Theorem 1.
Proof.
Theorem 2 tell us that with conﬁdence at least 1 − δ ,
[Equation]
Thus, we must provide a (high conﬁdence) upper bound on
[Equation]
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 = { p 1 , ..., p n } be an i.i.d.
sample of n domains from
E , and deﬁne
[Equation]
If we construct P (cid:48) by replacing any p j ∈ P with p (cid:48)
j ∼ E , then we have | Φ( P ) − Φ( P (cid:48) )
| ≤ 1 n , so
McDiarmid’s inequality tells us that with conﬁdence at least 1 −
[Equation]
[Equation]
We proceed by bounding the expected value of Φ( P ) ,
[Equation]
sup f ∈F (cid:32)
E q ∼E
[ L q ( f )] − 1 n n (cid:88) j =
L p j ( f ) (cid:33)(cid:35) (25) =
E p 1: n ∼E (cid:34) sup f ∈F E q 1: n ∼E (cid:34)n n (cid:88)
j = (cid:16) L q j ( f ) − L p j ( f ) (cid:17)(cid:35)(cid:35) (26) ≤ E p 1: n ,q 1: n ∼E (cid:34) sup f ∈F n n (cid:88)
j = (cid:16) L q j ( f ) − L p j ( f ) (cid:17)(cid:35) (27) =
E p 1: n ,q 1: n ∼E E (cid:126)σ (cid:34) sup f ∈F n n (cid:88)
j
= σ j (cid:16) L q j ( f ) − L p j ( f ) (cid:17)(cid:35) (28) ≤ 2 E p 1: n ∼E E (cid:126)σ (cid:34) sup f ∈F n n (cid:88)
j = σ j L p j ( f ) (cid:35) (29) =
2 E p 1: n ∼E E (cid:126)σ (cid:34) sup f ∈F n n (cid:88)
j = σ j E ( (cid:126)x,y ) ∼ p
j
[ (cid:96) ( f ( (cid:126)x ) , y )] (cid:35) (30) ≤ 2 E p 1: n ∼E E ( (cid:126)x j ,y j ) ∼ p
j E (cid:126)σ (cid:34) sup h ∈F n n (cid:88) [Equation] where the ﬁrst inequality comes from moving the supremum inside the expectation, (cid:126)σ is a vector of Rademacher random variables, the second inequality is due to the subadditivity of suprema, and the ﬁnal inequality comes from moving the expectation outside of the supremum. Noting that replacing one of the ( (cid:126)x j , y j ) pairs in the ﬁnal equality will result in R n ( F ) changing by at most 1 n ,
McDiarmid’s inequality can be used to say with conﬁdence 1 − δ 2 that [Equation] Combining Equations 21, 24, and 33 using the union bound completes the proof.
Proof.
We begin with the expected excess risk, which can be bounded from above by [Equation] where the inequality arises because, by deﬁnition, 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 E S [ˆ L E ( f ∗ )]
= L E ( f ∗ ) .
For the ﬁnal equality: the ﬁrst term can be bounded from above (with conﬁdence 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 conﬁdence 1 − δ ) using the bound for the expected value of Φ( P ) derived in the proof for Theorem 1.
Combining these two high conﬁdence bounds using the union bound yields the result.
C D ETAILED R ESULTS
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.
[Table]
[Table] [Table]
[Table] [Table]
[Figure]
Complexity
A cc u r ac y
OfﬁceHome(DomainR) 0 .
Complexity
A cc u r ac y
PACS(DomainS) 0 .
Complexity
A cc u r ac y
VLCS(DomainV) 0 .
[Figure]
Complexity
[Figure]
ac
[Figure]
OfﬁceHome
CORALERMIRMMixupMMDRSCSDVREx 0 .
[Figure]
[Figure] [Figure]
Complexity
[Figure]
PACS 0 .
[Figure] [Figure]
Complexity
[Figure] [Table]