{
  "File Number": "1109",
  "Title": "Ensemble of Averages: Improving Model Selection and Boosting Performance in Domain Generalization",
  "Limitation": "Further discussions along with limitations of our work are provided in Appendix E.",
  "Reviewer Comment": "Reviewer_2: Strengths\nFigure 1 explains the motivation and intuition of what authors want to do.\nPaper is clearly written and even though idea is simple, authors show the effectiveness of the proposed method.\nWeaknesses\nComplexity and run times compared to existing methods should be discussed\nSummary of limitations should be discussed in the paper\nQuestions:\nSMA - Line # 54 SMA abbreviation is used before actually defining it.\nResults on datasets: Take an example of PACS. Authors show average results on PACS dataset. But in appendix results on per domain show substantially worse results on Photos. Is it surprising or expected? Some discussion on this will be really helpful.\nWhat is the time complexity difference between SMA and EoA? It looks like EoA may have much higher complexity but performance gains are not much over SMA. Can authors comment?\nWould using SMA or EoA on top of some existing methods (e.g. MIRO) improve the performance further? Is there anything that stops us from combining SMA with other methods too?\nHow would one scale the current approach when number of domains are really large? Do authors see any issue in this?\nRight y-axis of Figure 1: \"trainig\" → training\nLimitations:\nNA\nEthics Flag: No\nSoundness: 3 good\nPresentation: 3 good\nContribution: 3 good\n\nReviewer_3: Strengths:\nClear, well-written paper.\nComprehensive and insightful experiments: There has been a recent trend of cherry-picking DG datasets, so I appreciated the wideness of the evaluation here, with only CMNIST and RMNIST left out of DomainBed (understandably so).\nSimple and effective: Averaging models, or simply decaying the learning rate (see below), is a very simple idea. Despite being well-explored outside of DG, its effectiveness for model selection in DG is quite surprising, and should perhaps become the standard in DG benchmarks where reliable model selection hinders fair comparison.\nWeaknesses:\nThe simple moving average (SMA) is just learning rate decay and this connection is not made.\nLet\nθ\nt\n=\nθ\n^\nt\n−\n1\n−\nη\n∇\nθ\nL\n, with\nη\nthe learning rate, and\nt\n0\n=\n0\n. Then we can rewrite Eq. 1 of the paper as:\nθ\n^\nt\n=\nt\nt\n+\n1\n⋅\nθ\n^\nt\n−\n1\n+\n1\nt\n+\n1\n⋅\nθ\nt\n=\nt\nt\n+\n1\n⋅\nθ\n^\nt\n−\n1\n+\n1\nt\n+\n1\n⋅\n(\nθ\n^\nt\n−\n1\n−\nη\n∇\nθ\nL\n)\n=\nθ\n^\nt\n−\n1\n−\nη\nt\n+\n1\n∇\nθ\nL\nThus, a simple moving average of model weights is equivalent to a linear learning rate decay.\nAdding back in t_0 allows a standard warm-up period before decaying the learning rate, and corresponds to tail averaging.\nIndeed, the stochastic weight averaging paper (SWA, [1]) discussed the importance of learning rate scheduling, and in fact they decay the learning rate for the first 75% of training, then set the learning rate to a high constant value for the remaining 25% of the time in order to increase the diversity of the solutions / optima found. This paper essentially removes this diversity-seeking trick, which is also employed in the DG follow-up paper SWAD [2], and reverts to decaying the learning rate until the end of training. The diversity for model ensembling then comes from different initializations.\nMain issue: Model averaging, and “ensembles of averages”, takes center stage in this paper. However, it just translates to using linear learning rate decay when ensembling, and this connection is never made.\nPotential remedies:\nMake this connection clear throughout the paper, particularly in Section 2 and in the related work section. This could include a discussion of how SWA and SWAD deliberately avoid learning rate decay in the tails in order to arrive at more diverse solutions, which is perhaps undesirable for DG model selection.\nAn experiment where linear learning rate decay is employed instead of model averaging, as this should be equivalent.\nDiscuss works which explored the benefits of learning rate decay.\nI will increase my score if this can be adequately addressed.\nNot exactly hyperparameter-free, as claimed:\nThroughout the paper, it is stressed that the proposed approach is hyperparameter free, and that this is a major advantage over SWAD.\nHowever, the method still requires specification of a start iteration t_0 and an averaging frequency. For t_0, the authors “arbitrarily choose 100 as the start iteration”. While Appendix C demonstrates that the proposed method is not too sensitive to these values for the datasets and pretrained models explored in the paper, they likely still need to be selected for new datasets and models, particularly if the models are trained from scratch.\nRemedy: tone down the hyperparameter free claim/statement, particularly in the contribution list of the introduction. Can still say it is much less sensitive than SWAD, which it appears to be.\n[1] Izmailov, P., Podoprikhin, D., Garipov, T., Vetrov, D., & Wilson, A. G. (2018). Averaging weights leads to wider optima and better generalization. In 34th Conference on Uncertainty in Artificial Intelligence (pp. 876-885).\n[2] Cha, J., Chun, S., Lee, K., Cho, H. C., Park, S., Lee, Y., & Park, S. (2021). SWAD: Domain generalization by seeking flat minima. In Advances in Neural Information Processing Systems, 34, (pp. 22405-22418).\nQuestions:\nDoes SMA, or learning rate decay, reliably improve other DG methods? E.g. IRM, VREx, CORAL, etc.\nIf the model is trained from scratch without pre-training, would you expect a larger t_0 to be needed? How would you select this hyperparameter?\nPossible to move Table 7/8/9 into the main paper? In my opinion, these are the most insightful results.\n[Minor] Why do the authors choose the notation\nθ\n^\nt\nover say\nθ\n¯\nt\nfor the averaged parameters?\n[Minor, comment] Table 4: clarify in caption that training-domain validation set was used for model selection.\nLimitations:\nYes, in Appendix E.\nEthics Flag: No\nSoundness: 3 good\nPresentation: 3 good\nContribution: 3 good\n\nReviewer_4: Strengths:\nEnsembling MAs is novel to my knowledge and this model achieves SoTA results on the challenging DomainBed benchmark (yet, open question of fairness of comparison c.f. below). Authors performs thorough empirical validation (across datasets, architectures) and ablation studies. The stability of MA models w.r.t. online models OOD is interesting and well evaluated.\nSMA and the corresponding model selection procedure are not groundbreaking but have practical use: SMA removes hyperparameters in SWAD, the model selection procedure is more robust than in SWAD. It is thus more applicable than the original work SWAD that motivated this paper.\nIt also proposes some theoretical results for explaining the success of ensembling and MA OOD by adapting the bias-variance decomposition to domain generalization (yet with several limitations detailed below).\nThe paper is well written and easy to follow.\nWeaknesses:\nLimited novelty of some contributions:\nSMA is mostly based on related models (SWA and SWAD); it “simply” removes unnecessary hyperparameters but the principle of averaging models is unchanged. Ensembling SMAs is novel but this contribution is mostly empirical as a theoretical explanation of its success over standard ensembling is missing.\nThe change in the model selection procedure of SMA vs SWAD is also minor although useful in practice; it would be interesting to see if better stability with MA applies to other learning objectives (e.g. domain-invariance criterias) to better highlight this contribution.\nThe theoretical section simply applies the well-known bias-variance trade-off to domain generalization with minor consideration of the experimental setting (c.f. questions below). A big part of the theoretical results (Taylor expansion l198) tries to validate empirically an existing result (Izmailov2018). The novelty of this section would be improved if an explanation why EoA outperforms standard ensembling is provided, which is currently missing.\nTwo other weaknesses that justify my score:\nQuestion on applicability of theoretical results to practise and unjustified statements in the theoretical section (see questions below). Missing explanation of the sucess of EoA.\nFairness of the comparison to baseline models (see limitations below). In particular, EoA and the ensemble baseline see more training data than other baselines.\nIzmailov2018: Averaging wights leads to wider optima and better generalization.\nQuestions:\nHow realistic is the theoretical analysis w.r.t. experimental setup?\nthe proposed bias-variance decomposition does not account for different seeds and hyperparameters used in the experiments.\nl188 “the expected test domain error of an ensemble is strictly less than that of an individual model” + “that of ensembles is dominated by the bias term alone, and is thus strictly lower” l661: this analysis is valid only when the ensemble has infinite number of members. In practice, an ensemble has finite number of members, here 6 members for EoA, such that this analysis is unrealistic.\nAuthors mention that MA has less diversity than ensembles which consider different datasets, hyperparameters and seeds l678-679. This puts into question the validity of l195 “model averaging on the other hand has been shown to approximate an ensemble” and of the subsequent analysis.\nUnjustified statements in the theoretical section:\nwhy does EoA outperform traditional ensembling theoretically?\n“ensembles of larger size typically have better out-domain performance.\" l219-220; not explained by the analysis.\n“\nθ\n^\nT\n−\nθ\nt\nmay not behave similar to that in their case” l207-208. Could you clarify this statement? How valid is the second order approximation of Izmailov2018 for tail-averaging if the behavior is not the same?\n“the model averaging protocol used in our work behaves like an ensemble” l215-216: the outputs of the ensemble should be also plotted along the first and second terms to show that (or a distance between predictions). Here, only the first and second terms are plotted.\nAdditional experiments:\nHow does SMA compare to SWA or SWAD in-domain? Section 4.2 compares only SMA to ERM. Cha2021 already showed that SWAD improved ERM in-domain so these conclusions are not new.\nEoA should be evaluated on a same training / validation split to be fairer (cf limitation section).\nMIRO with RegNetY-16GF is reported at 74.1 and not. 70.1 in the original paper.\nCha2021: SWAD: Domain Generalization by Seeking Flat Minima\nLimitations:\nThe limitations highlited by the authors are interesting. Yet, several important limitations are not enough discussed / missing:\nHow realistic is the theoretical analysis w.r.t. experimental setup? C.f. question above.\nThe SoTA results are obtained with two major limitations which are not discussed. This puts into question the fairness of the comparison.\nhigh inference cost of EoA and ensembling: 6 times higher than the baselines; this important question is not discussed by the authors.\nthe ensembling and EoA models see more data than baselines as there are trained on different training/validation splits. It seems normal that the results are better than using a single training/validation split. A fairer evaluation would only consider a same training/validation split.\nEthics Flag: No\nSoundness: 3 good\nPresentation: 3 good\nContribution: 2 fair\n\nReviewer_5: Originality: The techniques used in the paper are not new and are well studied in other areas. The use of these techniques in domain generalization is however new. Related work is cited and discussed.\nQuality: The methods are used appropriate, the work is complete and I really like the fact that the authors are not overselling their work. However, I am not fully convinced by some of the arguments in the paper based on the experiment results. See Questions for details.\nClarity: The presentation needs some improvement.\nThere are a lot of cross references in the paper that makes the paper a bit difficult to follow. For example, in section 2.3 of the ablation study, the authors refer the readers to Appendix C for the experiment result where Appendix C refer the readers to Appendix B for experiment details. The reviewers find a lot of such references in the paper.\nThe paper cited a lot of reference for experimental details (see for example L150 for the protocol), it is therefore unclear to judge purely from this paper whether an expert is able to reproduce the paper. The code for the paper is submitted in the supplementary material, which is helpful for reproducing purposes.\nThe figures in the paper need to be presented in a different way. It is often the case that for the test accuracy the y-axis have only two ticks 0 and 50 and it is very hard to tell the information from the figure.\nSignificance: Based on the experiment result, the proposed ensemble method can beat the SOTA while the SMA has comparable performance with the SOTA. While the performance of SMA is not as good as the SOTA, the authors claim that the proposed method has computational efficiency. The results, while not earthshaking, may be of practical use in real applications.\nQuestions:\nAblation study 1) on the impact of the start iteration t0. The authors claim that “starting averaging close to initialization results in improved out-domain performance XXX”. The reviewer is not convinced by this statement based on the empirical results. It is true that there is an increase of test accuracy at iteration 100, but this does not imply the statement the authors have. If the statement is correct, does the method gives the best performance at iteration 10 or even 1? Finer grids and more solid experiment results are needed for the statement.\nIn the analysis on the ensemble in Section 3.2, in the Taylor expansion term, it is shown that the output of EoA is roughly the same as the model evaluated at\nθ\n^\nT\n,\nwhich is the average of the model parameters over time. Can you explain why\nf\n(\nθ\n^\nT\n)\nleads to a better performance?\nThe experiment in Appendix C.6 on cross-run rank correlation claims that “in-domain validation performance based model selection is not a reliable approach for selecting a model from a pool of multiple independently trained models.” The statement seems interesting. If the statement is true, then how do you choose your model in practice since conceptually we have a pool of models trained with different learning rates, batch size, etc. In this case, how do you perform model selection?\nIn Table 8 for the spearman correlation, in for example Photo dataset, with average leads to negative correlation. You have claimed that closer to 1 is better. However, -0.38 implies a stronger correlation between two outputs then 0.09. Can we claim that with average still make the early stopping reliable given that they are negatively correlated?\nThe paper needs to be better proofread:\nL76, \\cdot not \\ldot\nL87 reference needed for Polyak-Ruppert averaging\nL201, should not include “not”?\nLimitations:\nI really like that the authors have a full section discussing the limitations of their work. The limitations and questions of the paper the reviewer had is given in Questions section.\nEthics Flag: No\nSoundness: 2 fair\nPresentation: 1 poor\nContribution: 3 good",
  "Limitations_refined": "",
  "abstractText": "In Domain Generalization (DG) settings, models trained independently on a given set of training domains have notoriously chaotic performance on distribution shifted test domains, and stochasticity in optimization (e.g. seed) plays a big role. This makes deep learning models unreliable in real world settings. We first show that this chaotic behavior exists even along the training optimization trajectory of a single model, and propose a simple model averaging protocol that both significantly boosts domain generalization and diminishes the impact of stochasticity by improving the rank correlation between the in-domain validation accuracy and out-domain test accuracy, which is crucial for reliable early stopping. Taking advantage of our observation, we show that instead of ensembling unaveraged models (that is typical in practice), ensembling moving average models (EoA) from independent runs further boosts performance. We theoretically explain the boost in performance of ensembling and model averaging by adapting the well known Bias-Variance trade-off to the domain generalization setting. On the DomainBed benchmark, when using a pre-trained ResNet-50, this ensemble of averages achieves an average of 68.0%, beating vanilla ERM (w/o averaging/ensembling) by ∼ 4%, and when using a pre-trained RegNetY-16GF, achieves an average of 76.6%, beating vanilla ERM by 6%. Our code is available at https://github.com/salesforce/ ensemble-of-averages.",
  "1 Introduction": "Domain generalization (DG, [5]) aims at learning predictors that generalize well on data sampled from test distributions that are different from the training distribution. Currently, deep learning models have been shown to be poor at this form of generalization [10], and excel primarily in the IID setting [51].\nWhile a number of algorithms have been proposed to mitigate this problem (cf [51] for a survey), [18] demonstrate that models trained using empirical risk minimization (ERM, [43]) along with proper model selection (i.e. early stopping using validation set), using a subset of data from all the training domains, largely match or even outperform the performance of most existing domain generalization algorithms. This suggests that model selection plays an important role in domain generalization. Despite its importance, there has not been much investigation into the reliability of model selection. As we demonstrate in Figure 1, the out-domain performance varies greatly along the optimization trajectory of a model during training, even though the in-domain performance does not. This instability therefore hurts the reliability of model selection, and can become a problem in realistic settings where test domain data is unavailable, because it causes the rank correlation between in-domain validation accuracy and out-domain test accuracy to be weak.\nIn this paper, we first investigate a simple protocol for model averaging that both boosts DG within the ERM framework, and mitigates performance instability of deep models on out-domain data,\n36th Conference on Neural Information Processing Systems (NeurIPS 2022).\nspecifically with respect to in-domain validation data. This makes model selection more reliable. Next, taking advantage of our observation, we show that ensembling moving average models further boosts performance, making it a better choice for practical scenarios. Note that we do not claim that model averaging or ensembling can fully solve the problem of DG. The observation that model averaging can boost domain generalization performance is not new, and was exposed by SWAD [8], which inspired our work. Our contribution in this respect are as follows:\n1. Hyperparameter-free:In contrast to SWAD, which introduces three additional hyper-parameters for its model averaging algorithm that need tuning, we show that the simple strategy of maintaining a simple moving average (SMA) of the model parameters throughout the optimization trajectory, starting near initialization (Appendix Figure 5), works just as well (when a pre-trained model is used as initialization). Although model averaging technically requires two hyper-parameters– averaging frequency and starting iteration, through empirical analysis, we show that setting the frequency to 1 and setting the start iteration close to 0 works well on multiple datasets and architectures, making our proposal hyperparameter-free in practice.\n2. Computationally efficient:SWAD requires computing validation performance more frequently than is typically done (2x-6x on the DomainBed datasets), which is needed because it needs to find the start and end iteration between which model averaging is done. This increases compute requirements. This segment is selected based on the validation performance computed using the model being trained. Our proposal to instead use the SMA model to perform early stopping and inference, side-steps this need and does not require frequent validation performance check. We show that the root cause for this difference is that the model being trained has unstable performance on OOD data, while the SMA model has a more stable OOD performance (see Figure 1 and Table 2). Thus this observation results in our hyperparameter-free and more efficient model averaging strategy.\n3. EoA: Taking advantage of our efficient model averaging protocol (section 2.2), we find that an ensemble of moving average models (EoA) outperforms a traditional ensemble of unaveraged models (Table 4). We also show ablation analysis that the rank correlation between in-domain validation performance and out-domain test performance is better for the ensemble of average models (Table 3).\n4. Theoretical explanation: To explain why both model averaging and ensembling improve OOD performance under a unified theoretical framework, we adapt the well known Bias-Variance decomposition to the domain generalization setting, and argue that the expected OOD loss for individual models comprises of both the bias and the variance term, while the expected OOD loss for ensembles and averaged models comprises mainly of the bias term only, and is thus strictly lower (section 3.2). Our explanation is in contrast with SWAD, which uses flat minima to explain the improved OOD\ngeneralization, which applies to model averaging, but is less straight forward for explaining the boost by ensembles.\n5. Benchmarking: For benchmarking, we experiment with three different pre-trained models as initializations for DG training, with increasing pre-training dataset size and model size. In these experiments we find that EoA provides a larger gain over the corresponding ERM baseline with increasing dataset and model size. These gains range from 4%− 6% (Table 4). Notice that this claim is different from existing work [20], which states that the baseline ERM performance improves with larger pre-training data and model size.",
  "2.1 Terminology": "Online Model: For a given supervised learning objective function, let fθ(.) denote the deep network being optimized using gradient based optimizer, where θ denotes the parameters of this model. We refer to fθ as the online model, or unaveraged model. The output of fθ(.) is a vector of K logits corresponding to the K classes in the supervised task.\nMoving Average (MA) Model: While the online model is being trained, we maintain a moving average of the online model’s parameters. This process is sometime referred to as iterate averaging in existing literature. The deep network whose parameters are set to be this moving average is referred to as the moving average model, or more specifically simple moving average (SMA) model because of its use in our work. We denote the parameters of this model by θ̂.",
  "2.2 Model Averaging Protocol": "We use a simple moving average (SMA) of the online model. Instead of calculating the moving average starting from initialization (as done in Polyak-Ruppert averaging), we instead start after a certain number of iterations t0 during training (tail averaging), and maintain the moving average until the end of training. As we discuss in the next section, t0 is chosen to be close, but not equal to the initialization when a pre-trained model is used as initialization. At any iteration t, we denote:\nθ̂t = { θt, if t ≤ t0 t−t0\nt−t0+1 · θ̂t−1 + 1 t−t0+1 · θt, otherwise (1)\nwhere θt is the online model’s state at iteration t. Note that effectively, θ̂t := 1t−t0+1 · ∑t t′=t0 θt′ . Further, at iteration t, if we need to calculate validation performance, we use θ̂t to do so, and not θt. As we show in the next section, the benefit of doing so is that the rank correlation between in-domain validation accuracy and out-domain test accuracy is significantly better when predictions are made using θ̂t. This makes model selection more reliable for domain generalization. Finally, for a given run, model selection selects θ̂t∗ for making test set predictions, such that θ̂t∗ achieves the best validation performance. We discuss some theoretical perspectives on why model averaging can help domain generalization in section 5.1.",
  "2.3 Ablation Analysis": "Here we perform four ablation studies: 1) impact of the start iteration t0 used in our SMA protocol in Eq. 1; 2) the frequency of model averaging; 3) instability reduction of SMA model compared to the online mode along the optimization trajectory on out-domain data; 4) correlation between in-domain and out-domain accuracy across independently trained models.\nDue to space limitation, we show experiments for 1,2 and 4 in Appendix section C. In summary, we find that: 1) starting averaging close to initialization results in improved out-domain performance (Figure 5 in Appendix) when the parameters are initialized used a pre-trained model; 2) the frequency of SMA does not have a significant impact on performance, unless sampling is done at too large intervals (Figure 6 in Appendix); 4) the rank correlation is poor between validation and test accuracy of independently trained models (Figure 8 in Appendix). An implication of this is that it is difficult to discover the best model (for out-domain performance) from a pool of independently trained models, based only on their in-domain validation performance (echoing the findings of [10]).\nTable 1: Spearman correlation (closer to 1 is better) between within-run in-domain validation accuracy and out-domain test accuracy on multiple datasets. Model averaging improves rank correlation for both individual models (left) and ensemble of averages (right).\nTable 2: Individual Models\nTerraIncognita w/o avg w/ avg L100 0.21 ± 0.07 0.90 ± 0.05 L38 0.12 ± 0.13 0.83 ± 0.05 L43 0.30 ± 0.06 0.67 ± 0.18 L46 0.03 ± 0.11 0.52 ± 0.14\nTable 3: Ensembles\nTerraIncognita w/o avg w/ avg L100 0.48 1 L38 0.17 0.95 L43 0.59 0.38 L46 0.08 0.61",
  "2.3.1 Instability Reduction: Rank Correlation": "We study the reliability of model selection for domain generalization when using online models vs moving average models, using rank correlation (see Appendix C.4 for definition). To do so, we train models on a dataset, both with and without model averaging, and compute Spearman correlation between the in-domain validation accuracy and out-domain test accuracy sampled at regular intervals during the training process. Since there are multiple runs where a given domain acts as the test domain, we calculate the mean and standard error of these values over these runs.\nThe rank correlations are shown in Table 2 (and Table 8 in Appendix) for the PACS, VLCS, OfficeHome, TerraIncognita and DomainNet datasets. We find that in majority of the cases, using model averaging results in a significantly better rank correlation compared to using the online model. These experiments therefore suggest that the reliability of model selection is significantly higher within a run when using model averaging.",
  "3 Ensemble of Averages (EoA)": "[18] propose a rigorous framework for evaluation in the domain generalization setting which accounts for randomness due to seed and hyper-parameter values, and recommend reporting the average test accuracy over all the runs computed using a model selection criteria. However, in practice, it is desirable to have a single predictor that has a high accuracy. An ensemble combines predictions from multiple models, and is a well known approach for achieving this goal [11] by exploiting function diversity [14]. However, as we show, even ensembles suffer from instability in the domain generalization setting. Building on the observations of the previous section, we investigate the behavior of ensemble of moving average models and find that it mitigates this issue. We begin by describing the EoA protocol below.\nEoA Protocol: We perform experiments with ensemble of multiple independently trained models (i.e., with different hyper-parameters and seeds). When each of these models are moving average models from their corresponding runs, we refer to this ensemble in short as the ensemble of averages (EoA). Identical to how we make predictions for traditional ensembles (specifically the bagging method [6]), the class ŷ predicted by an EoA for an input x is given by the formula:\nŷ = argmax k\nSoftmax( 1\nE E∑ i=1 f(x; θ̂i))k (2)\nwhere E is the total number of models in the ensemble, θ̂i denotes the parameters of the ith moving average model, and the sub-script (.)k denotes the kth element of the vector argument. Finally, the state θ̂i of the ith moving average model used in the ensemble is selected from its corresponding run using its in-domain validation set performance (described in section 2.2). We now investigate the behavior of EoA compared with ensembles of online models on domain generalization tasks.",
  "3.1 Analysis": "Qualitative visualization: For the purpose of contrasting the behavior of traditional ensembles vs ensemble of averages, we begin by qualitatively studying the stability of out-domain performance of these two ensembling techniques during the training process. To do so, we use the TerraIncognita\ndataset, and fix one of its domains as the test domain while using the others as training/validation data. We then train 6 different models independently for 5, 000 iterations with different seeds, hyper-parameters and training-validation splits identical to the [18] protocol. We also maintain moving average models corresponding to each of these 6 models. At every 300 iterations, we form an ensemble of the 6 online models from their corresponding runs and compute the out-domain test accuracy. Since, each run has a different training-validation split, we calculate the mean validation accuracy of each of these online models at that iteration. We follow an identical procedure for the moving average models and plot these performances in Figure 2. We find that the ensemble of averages has a better stability on out-domain test set compared to the ensemble of online models.\nFor clarity, note that this procedure for calculating test accuracy at regular intervals is different from what we proposed earlier for EoA for practical purposes. This experiment is only meant to highlight the fact that making predictions on out-domain data using an ensemble of online models suffers from instability along the optimization trajectory, while an ensemble of averages mitigates this issue. For plots on other domains of TerraIncognita, see Figure 10 in the Appendix.\nRank correlation: We now measure the rank correlation between in-domain validation accuracy and out-domain test accuracy for a quantitative evaluation. The details of the metric and motivations behind this experiment are same as those described in section 2.3.1. Here we use the same experimental setup described in the qualitative analysis above. But in addition, we also conduct experiments on VLCS, OfficeHome and DomainNet datasets. The results are shown in Table 3 (and Table 9 in Appendix). We find that in majority of the cases, using EoA results in a significantly better rank correlation compared to using the online model ensemble. These results show more concretely the fact that predictions by an ensemble of online models on out-domain data suffers from instability along the optimization trajectory, and EoA mitigates this problem.",
  "3.2 Why does Ensembling and Model Averaging Improve Performance?": "We explain the performance boost achieved by ensemble of averages (see next section) by adapting the Bias-Variance decomposition [17] to the domain generalization setting. For classification tasks with one-hot labels, the Bias-Variance decomposition is given as [49],\nEx,yET [CE(y, f(x; T ))] = Ex,y[CE(y, f̄(x))]︸ ︷︷ ︸ Bias2 +Ex,T [KL(f̄(x), f(x; T ))]︸ ︷︷ ︸ Variance\nwhere CE denotes the cross entropy loss, KL denotes KL divergence, T = {(xini , yini )}Ni=1 are N IID samples drawn from the in-domain training distribution Pin, f(x; T ) denotes the prediction of the model f on sample x such that the model is trained on the dataset T , and f̄(x) = ET [f(x; T )]. Finally (x, y) ∼ Pout where Pout is the out-domain distribution. Notice how T and (x, y) come from different distributions. For instance, in PACS dataset, Pin could be the union of art, cartoon and photo domains, and Pout could be the sketch domain. The L.H.S. of the above equation is the expected cross entropy loss on the out-domain distribution achieved by individual models, i.e., when we train an individual model on a particular instance of the training dataset T , the expected out-domain test loss is denoted by L.H.S. Importantly, the Bias term on the R.H.S. denotes the expected cross entropy loss on the out-domain distribution achieved by the function f̄(.), which is essentially an ensemble. Finally, the variance term captures how much the\nprediction of individual models differs in expectation from the ensemble prediction, which makes this term strictly greater than zero.\nTherefore, the above decomposition tells us that the expected test domain error of an ensemble is strictly less than that of an individual model. This interpretation directly explains why a traditional ensemble of unaveraged models can be expected to perform better than individual unaveraged models. However, it is still not clear why EoA performs better that a traditional ensemble in practice. To establish this connection, we note that in practice, we typically train a small number of independent models to form a traditional ensemble due to computational constraints. Thus such ensembles do not behave identically to the expected ensemble f̄(.) described above. Model averaging on the other hand has been shown to approximate an ensemble [23]. To see this, consider without any loss of generality that the ensemble contains models with parameters {θ1, θ2 . . . θT }, and denote θ̂T := 1T · ∑T t=1 θt. Then note that the second order Taylor’s expansion around θ̂T of each model’s kth dimension’s prediction is given by,\n1 T · T∑ t=1 f(θt)k ≈ f(θ̂T )k + 1 T · T∑ t=1 (θ̂T − θt)T ∂f(θ̂T )k ∂θ̂T + 0.5(θ̂T − θt)T ∂2f(θ̂T )k ∂θ̂2T (θ̂T − θt)\nNotice that f(.) is the model output and therefore the first and second order terms are the derivatives of the model output and not the loss gradient and Hessian. The first order term is zero due to θ̂T := 1T · ∑T t=1 θt. A crucial difference of our analysis compared to [23] is that they average model states that lie near different loss minima, while we perform tail averaging. Therefore, the term (θ̂T − θt) may not behave similar to that in their case. To shed light on its behavior, we plot the histogram of the second order term and the moving average model’s logit f(θ̂T )k in Eq. 3 for the first dimension (k = 1) for test domain data in figure 4 (details and additional experiments provided in Appendix D). The histogram shows that the second order term\nconcentrates near zeros while the logit values span a wider range, which implies that under the second order approximation, the model averaging protocol used in our work behaves like an ensemble. Finally, to study the impact of ensemble size on out-domain performance, we plot the test domain accuracy as a function of ensemble size in figure 3. The plots show that i. EoA outperforms traditional ensembles for all ensemble sizes (left); and ii. ensembles of larger size typically have better\nout-domain performance. See a discussion on functional diversity of ensembles vs model averaging in Appendix E.",
  "4.1 DomainBed Benchmarking": "We now benchmark our model averaging protocol (SMA) and ensemble of averages against online models (ERM, without MA) and ensemble of online models (ensembles). Note that all these models are trained using the ERM objective as before. We evaluate on PACS [27], VLCS [13], OfficeHome [45], TerraIncognita [3] and DomainNet [35] datasets in DomainBed. The training-evaluation protocols are the same as described in section 2.3 for moving average and online models, and in section 3 for ensembles. Full details can be found in section B in the Appendix.\nComparison with existing results using ResNet-50 pre-trained on ImageNet: Here we compare existing methods with our runs. All methods use ResNet-50 (25M parameters) [19] pre-trained on ImageNet as initialization. Comparing ERM [18] and ERM (our runs), we find that they perform similarly, especially considering we have used a smaller hyper-parameter space (further discussion in Appendix E). A comparison between SWAD and SMA shows that SWAD is slightly better (by 0.4% on average). However, recall that our protocol retains the advantage of not tuning any hyperparameters while SWAD has 3 additional ones that they tune separately in addition to the optimization hyper-parameters. Interestingly, traditional ensembles and SMA achieve similar performance (66.8% and 66.5% respectively). Finally, EoA outperforms all the existing results: ERM by 4% and SWAD (previous SOTA) by 1.1%. Importantly, note that while all non-ensemble models report the average test accuracy of multiple models following the protocol of [18], EoA test accuracy is achieved by a single predictor that combines the output of multiple models.\nExperiments with larger pre-training datasets and larger models: In addition to ResNet-50 pre-trained on ImageNet, we now also experiment with ResNeXt-50 32x4d (25M parameters), that is pre-trained using semi-weakly supervised objective on Instagram 1B images and ImageNet labeled data [48], and RegNetY-16GF (81M parameters) pre-trained using Instagram 3.6B images. Note that both ResNet-50 and ResNeXt-50 32x4d have similar number of parameters, while RegNetY-16GF has more than 3x the number of parameters. On the other hand, also notice that the three architectures\nare respectively pre-trained on an increasing size of datasets. The rationale behind this choice is that recent trends in deep learning has shown that models pre-trained on larger datasets and architectures achieve better downstream transfer performance [12, 32, 20]. Therefore, we expect the latter models to improve the ERM baseline, and our goal is to investigate the out-domain performance gain by model averaging and EoA relative to the corresponding ERM baseline with increasing pre-training dataset size and model size.\nThe experimental results are shown in Table 4. To investigate models with the same size, but one pre-trained on a larger dataset, we compare the results of ResNet-50 and ResNeXt-50 32x4d. On average across all five datasets, the gain of SMA over ERM (our runs) is 2.5% for ResNet-50 and 3.9% for ResNeXt-50 32x4d. The gain of EoA over ERM is larger: 4% vs 5% respectively. This suggests that pre-training the model on a larger dataset increases the gain of model averaging and EoA over the corresponding ERM baseline, while the ERM performance itself improves.\nNext, to investigate the impact of both larger model size and larger pre-training dataset, we compare the results of ResNeXt-50 32x4d and RegNetY-16GF. On average across all five datasets, the gain of SMA over ERM (our runs) is 3.9% for ResNeXt-50 32x4d and 5% for RegNetY-16GF. The gain of EoA over ERM is again larger: 5% vs 6% respectively. This suggests that increasing both model size and pre-training dataset size allow model averaging and EoA to provide larger out-domain gains over the corresponding ERM baseline. Notice that these claims are different from existing work [20], which states that the baseline ERM performance improves with larger pre-training data and model size.",
  "4.2 In-domain Performance Improvement using Model Averaging": "We study the in-domain test accuracy on PACS and OfficeHome datasets using ImageNet pretrained ResNet-50 with and without our SMA protocol. In this experiment, we combine all the domains of PACS and split it into training/validation/test splits (0.8/0.1/0.1). We run 10\ndifferent runs with different seeds and randomly chosen splits for each dataset. The best model for each run is chosen using the validation set. The remaining optimization details are identical to those used in the previous section. The test accuracy mean and standard error using these best models are shown in Table 5. As expected, SMA outperforms models without averaging.",
  "5.1 Model Averaging": "A theoretical perspective: In our model averaging protocol, we compute a simple moving average of the model parameters starting early during training. This is known as tail-averaging [24], which is slightly different from Polyak-Ruppert averaging [36] in that the latter starts averaging from the very beginning of training. In the context of least square regression in the IID setting, [24] theoretically study the behavior of tail averaging and show that the excess risk of the moving average model is upper bounded by a bias and a variance term. This bias term depends on the initialization state of the parameter, but interestingly, it decays exponentially with t0, where t0 is the iteration at which model averaging is started. The variance term on the other hand depends on the covariance of the noise inherent in the data w.r.t. the optimal parameter, and is shown to decay at a faster rate when using model averaging, as opposed to a slower rate without averaging. This motivated them to propose tail-averaging.\nModel averaging has also been shown to have a regularization effect [34] similar to that of Tikhonov regularization [42]. This regularization has been classically used in ill-posed optimization problems (typically least squared regression), which are under-specified. This property provides an interesting connection between model averaging and the under-specification problem discussed in [10], where the authors perform large scale experiments showing that the performance of multiple over-parameterized deep models, trained independently with different hyper-parameters and seeds, have a high variance on out-domain data, even though their in-domain performances are very close together. Based on this connection, a simple intuition why one can expect model averaging to help in domain generalization is its Tikhonov regularization effect. However, this intuition requires a more thorough investigation.\nSWAD [8]: SWAD propose flat minima as a means for improving domain generalization. Following the intuition of stochastic weight averaging (SWA, [23]), they use model averaging to find flat minima. However, their proposal is different from sampling model states at regular intervals and towards the end of training (as done in SWA). SWAD selects contiguous model states along the optimization path for averaging, based on their validation loss. This is done to prevent including an under-performing state (determined using the in-domain validation set) in the moving average model. SWAD however adds additional hyper-parameters of its own: the validation loss threshold below which the the model states are selected, and patience parameters (number of iterations that determine the start and end of the averaging process). Note that this also requires computing validation loss more frequently during training. In this context, we show that instead of finding the start and end period for model averaging meticulously, we can simply start model averaging early during training and continue till the end. This difference arises from the fact that SWAD uses the online network to calculate validation performance while we use the SMA model in our protocol. This is explained further in section 2.2. The benefit our observations provide over SWAD is that they allow us to take advantage of model averaging without the additional hyper-parameters and compute required by SWAD.",
  "5.2 Domain Generalization": "Existing methods aimed at domain generalization can be broadly categorized into techniques that perform domain alignment, regularization, data augmentation, and meta-learning. Domain alignment is perhaps the most intuitive direction, in which methods aim to learn latent representations which have similar distributions across different domains [41, 30, 39, 37]. There are different variants of this idea, such as minimizing some divergence metric between the latent representation of different domains (E.g. DANN [16]), or less strictly, minimizing the difference between the latent statistics of different domains (E.g. DICA [33], CORAL [41]). In the meta learning category, source domains are typically split into 2 subsets to be used as the training and test domains in episodes to simulate the domain generalization setting [28, 29]. Data augmentation is also a popular tool used for improving domain generalization. It ranges from introducing various types of augmentations to simulate unseen test domain conditions (E.g. style transfer [50, 52]) to self-supervised learning involving matching the representations of an image with different augmentations (E.g. [1, 7]). Finally, different ways of regularizing models (implicit and explicit) have also been developed with the goal of encouraging domain-invariant feature learning [38, 47, 46]. For instance, invariant risk minimization [2] propose a regularization such that the classifier is optimal in all the environments. Representation SelfChallenging [21] propose to suppress the dominant features that get activated on the training data, which forces the network to use other features that correlate with labels. Risk extrapolation [26] propose a regularization that minimizes the variance between domain-wise loss, in the hope that it is representative of the variance including unseen test domains. See [51] for a survey on DG methods.\nOur investigation in this work is complementary to all these domain generalization methods. Additionally, one of our main focus is to also study and improve performance instability on out-domain data during training, which results in more reliable model selection. This aspect has not received much attention.",
  "6 Conclusion": "We investigated a hyperparameter-free and efficient protocol for model averaging in the ERM framework, and showed that it provides a significant boost to out-domain performance compared to un-averaged models. Building on this observation, we showed that an ensemble of moving average models performs better compared to an ensemble of un-averaged models. Importantly, we showed that in both cases, model averaging significantly improves the rank correlation between in-domain validation accuracy and out-domain test accuracy, which is crucial for reliable model selection using in-domain validation data. We experimented with three pre-trained models with increasing pre-training dataset and model size, and found that EoA provides a proportionally larger gain compared to the corresponding ERM baseline, and lies in the range of 4%− 6%. Finally, we explain the performance boost of EoA by adapting the Bias-Variance trade-off perspective to the domain generalization setting. Further discussions along with limitations of our work are provided in Appendix E.",
  "Reviewer Summary": "Reviewer_2: Authors point out the chaotic behavior exists even along the training optimization trajectory of a single model, and propose a simple model averaging protocol that both significantly boosts domain generalization performance. Authors also show that instead of simple moving average, ensembling moving average models from multiple runs can boost the performance even further. Authors show results on various popular datasets and show the effectiveness of proposed method.\n\nReviewer_3: This paper shows that simple model averaging over the course of training improves the rank correlation between in-domain validation accuracy and out-of-domain test accuracy. They also show that ensembling these averaged models further improves this rank correlation, more so than ensembling unaveraged models. Finally, they illustrate that this improved rank correlation translates to improved performance on DomainBed, given how crucial it is for model selection or early stopping in domain generalization.\n\nReviewer_4: This paper proposes two different models for OOD generalization, evaluated on the DomainBed benchmark across pretrained encoders and compared to representative baselines. First, it introduces a new hyperparameter free model averaging (MA) strategy during training called SMA, inspired by tail-averaging in optimization. SMA averages all parameters from a pre-defined starting point. Second, it proposes to ensemble several SMAs (EoA); EoA achieves SOTA results on DomainBed and mitigates instability in OOD performance across training.\nIn addition to these two models, it proposes a new model selection procedure for MA that performs early stopping and inference with SMA instead of the online model. This model selection procedure is justified by an extensive study of OOD performance stability throughout training and rank correlation between validation and test performance.\nFinally, it explains the success of ensembling and MA using the Bias-Variance decomposition, adapted to a domain generalization setting.\n\nReviewer_5: This paper proposes an approach to improve the test accuracy of the model when evaluated on a test dataset from a different domain. The methods used for this purpose include the moving average of model weights and the ensemble of moving averaged models. Empirical experiments are conducted to show the effectiveness of the proposed method."
}