Seeking Consistent Flat Minima for Better Domain Generalization via Refining Loss Landscapes

Aodi Li, Liansheng Zhuang, Xiao Long, Minghong Yao, Shafei Wang · OpenReview

Abstract

Domain generalization (DG) aims to learn a model from multiple training domains that can generalize to unseen test domains. Recent theory suggests that seeking flat minima in the loss landscape can significantly reduce out-of-domain generalization error. However, existing methods often neglect the consistency of these landscapes across different domains, leading to models that are not simultaneously optimal in all domains. This paper proposes an iterative Self-Feedback Training (SFT) framework to seek consistent flat minima by progressively refining loss landscapes. SFT alternatively generates a feedback signal by measuring landscape inconsistency and refines the landscapes for greater consistency using dynamic soft labels. Extensive experiments on DomainBed demonstrate that SFT achieves superior performance compared to state-of-the-art sharpness-aware methods and other DG baselines.

Introduction

In deep learning, the assumption that training and testing data share the same distribution is frequently violated in real-world applications. This challenge, known as Domain Generalization (DG), requires models to perform reliably on unseen "out-of-distribution" data. A promising direction in DG research involves the geometry of the loss landscape. It has been observed that models residing in "flat minima"—regions where the loss is low and stable over a wide range of parameter values—generalize significantly better than those in "sharp minima."

The Challenge of Inconsistent Landscapes

While seeking flat minima is beneficial, the multi-domain nature of DG introduces a unique complication. A parameter region that is flat and optimal for one domain may be sharp or suboptimal for another. Standard techniques like Sharpness-Aware Minimization (SAM) focus on finding flat regions within the training set but often fail to ensure that these regions are consistent across all source domains. If the "valleys" of low error do not align, the model's ability to generalize to a completely new domain remains limited.

Comparison between inconsistent loss landscapes (a) and consistent flat minima (b) across multiple domains.

As illustrated in the figure above, the goal is to move from a state where each domain has its own disparate minimum to a state where a single, consistent flat minimum is shared across all domains.

Self-Feedback Training (SFT)

To address the alignment problem, we introduce the Self-Feedback Training (SFT) framework. SFT is an iterative approach designed to refine the loss landscapes of training domains to promote consistency. The framework consists of two alternating phases:

  1. The Feedback Phase: The system measures the discrepancy between the loss landscapes of different domains. By using one domain as a training set and another as a validation set, it calculates a feedback signal based on the difference in sharpness and error.
  2. The Refinement Phase: This feedback signal is used to update a "Landscape Refiner." Rather than modifying the model architecture, the refiner generates dynamic soft labels. These labels are mathematically optimized to "smooth out" the loss landscape, effectively deepening and widening the basins of low error while aligning them across domains.

To maintain the integrity of the learning process, the authors developed the Projection Cross-Entropy (PCE) loss. This loss function ensures that the generated soft labels remain close to the original ground-truth labels while still achieving the desired landscape flattening effect.

Visualizing the Refined Landscape

The impact of SFT is most evident when visualizing the loss surfaces. In 2D projections of the parameter space, standard training often results in scattered basins of low loss for different domains. After applying the SFT framework, these basins merge into a single, broad, and consistent valley.

2D loss surfaces for four domains before (top) and after (bottom) applying SFT, showing improved alignment of the minima.

This alignment ensures that the model parameters are located in a region that is robust to the distribution shifts encountered in unseen test domains.

Experimental Results

The SFT framework was rigorously tested on the DomainBed benchmark, which includes datasets such as PACS, VLCS, OfficeHome, TerraIncognita, and DomainNet. The results demonstrate a clear advantage over both Empirical Risk Minimization (ERM) and Sharpness-Aware Minimization (SAM):

  • ResNet-50 Backbone: SFT improved average accuracy across five benchmarks by 3.8% over ERM and 2.6% over SAM. On the PACS dataset, it reached a state-of-the-art accuracy of 88.3%.
  • Vision Transformers (ViT): When applied to ViT-B/16, SFT outperformed SAM by 1.5%. It also showed strong performance when combined with large-scale pre-trained models like CLIP.

Furthermore, the custom PCE algorithm proved to be highly efficient, operating approximately 10 times faster than standard convex optimization libraries, making the refinement process feasible for large-scale deep learning tasks.

Conclusion

Seeking consistent flat minima represents a significant step forward in domain generalization. By focusing on the alignment of loss landscapes across domains rather than just individual flatness, SFT provides a more robust foundation for out-of-distribution generalization. Future work may explore combining SFT with more advanced sharpness-aware variants or investigating the use of more efficient refiner architectures to further enhance performance and scalability.

Summary updated

BibTeX
@inproceedings{li2025seeking,
  author = {Aodi Li and Liansheng Zhuang and Xiao Long and Minghong Yao and Shafei Wang},
  title = {{Seeking Consistent Flat Minima for Better Domain Generalization via Refining Loss Landscapes}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01430},
}
Figure