Skip to main content
QUICK REVIEW

[Paper Review] SWAD: Domain Generalization by Seeking Flat Minima

Junbum Cha, Sanghyuk Chun|arXiv (Cornell University)|Feb 17, 2021
Domain Adaptation and Few-Shot LearningComputer Science60 references4 citations
TL;DR

This paper proposes SWAD, a novel domain generalization method that enhances model robustness by seeking flat minima in the loss landscape. By introducing dense, overfit-aware stochastic weight averaging, SWAD achieves state-of-the-art performance across five major DG benchmarks, improving average out-of-domain accuracy by 1.6 percentage points over prior SOTA methods.

ABSTRACT

Domain generalization (DG) methods aim to achieve generalizability to an unseen target domain by using only training data from the source domains. Although a variety of DG methods have been proposed, a recent study shows that under a fair evaluation protocol, called DomainBed, the simple empirical risk minimization (ERM) approach works comparable to or even outperforms previous methods. Unfortunately, simply solving ERM on a complex, non-convex loss function can easily lead to sub-optimal generalizability by seeking sharp minima. In this paper, we theoretically show that finding flat minima results in a smaller domain generalization gap. We also propose a simple yet effective method, named Stochastic Weight Averaging Densely (SWAD), to find flat minima. SWAD finds flatter minima and suffers less from overfitting than does the vanilla SWA by a dense and overfit-aware stochastic weight sampling strategy. SWAD shows state-of-the-art performances on five DG benchmarks, namely PACS, VLCS, OfficeHome, TerraIncognita, and DomainNet, with consistent and large margins of +1.6% averagely on out-of-domain accuracy. We also compare SWAD with conventional generalization methods, such as data augmentation and consistency regularization methods, to verify that the remarkable performance improvements are originated from by seeking flat minima, not from better in-domain generalizability. Last but not least, SWAD is readily adaptable to existing DG methods without modification; the combination of SWAD and an existing DG method further improves DG performances. Source code is available at https://github.com/khanrc/swad.

Motivation & Objective

  • Address the challenge of domain shift in machine learning, where training and test data distributions differ significantly.
  • Overcome the limitations of standard empirical risk minimization (ERM), which often converges to sharp minima and generalizes poorly under domain shift.
  • Theoretically and empirically demonstrate that flat minima lead to better generalization in domain generalization (DG) scenarios.
  • Develop a simple yet effective method—Stochastic Weight Averaging Densely (SWAD)—that enhances flatness and generalization without architectural changes.
  • Verify that performance gains stem from flatness, not improved in-domain generalization, by comparing with data augmentation and consistency regularization methods.

Proposed method

  • Propose a robust risk minimization (RRM) formulation that upper bounds the domain generalization gap using worst-case empirical risks within parameter space neighborhoods.
  • Theoretically show that flatter minima yield smaller domain generalization gaps by bounding the worst-case risk in a neighborhood around the optimal solution.
  • Modify stochastic weight averaging (SWA) by sampling weights densely at every training iteration to better explore flat regions of the loss landscape.
  • Introduce an overfit-aware strategy to determine the optimal start and end iterations for averaging, using validation loss to avoid overfitting.
  • Apply SWAD as a plug-in to existing DG methods without architectural changes, enabling consistent performance gains.
  • Leverage CPU memory to store intermediate weights, minimizing GPU memory overhead while maintaining training efficiency.

Experimental results

Research questions

  • RQ1Can seeking flat minima significantly reduce the domain generalization gap in non-convex, complex deep learning landscapes?
  • RQ2Does the generalization improvement from flat minima hold under domain shift, where distribution shifts are more severe than in i.i.d. settings?
  • RQ3Can a simple, flatness-aware optimization method like SWAD outperform complex, task-specific DG methods without architectural modifications?
  • RQ4Are the performance gains of SWAD due to improved in-domain generalization or due to better out-of-domain robustness?
  • RQ5How does SWAD compare to other flatness-aware methods (e.g., SAM, SWA) and in-domain generalization techniques (e.g., Mixup, CutMix) in the context of domain generalization?

Key findings

  • SWAD achieves state-of-the-art performance on five major DG benchmarks: PACS (+2.6pp), VLCS (+1.6pp), OfficeHome (+4.1pp), TerraIncognita (+3.9pp), and DomainNet (+5.6pp) over ERM.
  • On average, SWAD improves out-of-domain accuracy by 1.6 percentage points over the best existing SOTA method, with a 3.6pp gain over the ERM baseline.
  • Combining SWAD with a previous SOTA method (SOTA [31]) yields further improvement, achieving 67.3% average accuracy—0.4pp higher than SWAD alone.
  • SWAD consistently finds flatter minima than vanilla SWA, as confirmed by loss landscape visualization and flatness metrics.
  • Data augmentation and consistency regularization methods (e.g., Mixup, CutMix) do not improve out-of-domain generalization, while flatness-aware methods (SWA, SAM) do, confirming that flatness is the key factor.
  • SWAD incurs only a 1.07x to 1.27x runtime overhead compared to ERM, with no additional GPU memory cost, making it practical for real-world deployment.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.