Introduction
Domain Generalization (DG) aims to train models on multiple source domains such that they generalize effectively to unseen target domains. While the Adam optimizer is the de facto standard in benchmarks like DomainBed, it often converges to "sharp" minima—narrow valleys in the loss landscape that generalize poorly under distribution shifts. In contrast, "flatter" minima are known to be more robust. This paper introduces Flatness-Aware Minimization for Domain Generalization (FAD), a novel optimizer that jointly optimizes for zeroth-order and first-order flatness to enhance out-of-distribution (OOD) performance.
Methodology: The FAD Optimizer
FAD addresses the limitations of existing flatness-aware optimizers like SAM (zeroth-order) and GAM (first-order) by combining both objectives efficiently.
- Zeroth-order flatness: Ensures the loss remains low in a neighborhood around the optimum.
- First-order flatness: Ensures the gradient norm remains small, preventing abrupt changes in model behavior.
To avoid the prohibitive computational cost of second-order Hessian calculations, FAD utilizes a first-order approximation. It performs additional gradient steps per iteration to "scout" the local landscape, adjusting the update direction toward flatter regions without requiring full second-order information.
Experimental Setup
The authors evaluated FAD across a diverse set of DG benchmarks, including PACS, VLCS, OfficeHome, TerraIncognita, DomainNet, and NICO++. These datasets cover various challenges, from style changes (PACS) to large-scale OOD scenarios (DomainNet, NICO++).
Key Results and Insights
FAD consistently outperforms standard optimizers like Adam, AdamW, and SGD, as well as specialized optimizers like SAM and GAM.
Superior Generalization and Flatness
Empirical results show that FAD achieves significant accuracy gains. For instance, on the PACS dataset, FAD reaches an average accuracy of 88.2%, compared to 84.2% for Adam. Analysis of the Hessian spectra confirms that FAD finds significantly flatter minima, characterized by lower maximum eigenvalues ($\lambda_{max}$) and lower Trace values.
Efficiency and Synergy
While FAD involves more computation per step, it is iteration-efficient, reaching higher accuracy in fewer steps than competitors. The joint optimization of zeroth and first-order flatness provides a stronger penalty on sharpness than either method alone, leading to the discovery of exceptionally robust minima. As shown in the performance table, FAD trained for only 5,000 iterations can outperform other optimizers trained for 15,000 iterations.
Conclusion
FAD demonstrates that prioritizing loss landscape flatness is a powerful strategy for Domain Generalization. By efficiently approximating second-order properties, FAD offers a practical alternative to Adam for robust model training. Future work includes estimating the "discrepancy distance" between domains during training and developing automated optimizer selection tools.
Summary updated