Flatness Improves Backbone Generalisation in Few-Shot Classification

Rui Li, Martin Trapp, Marcus Klasson, Arno Solin

Introduction

Multi-domain few-shot classification (FSC) presents a significant challenge: models must adapt to novel classes from diverse domains (e.g., satellite imagery or medical scans) using only a few labeled examples. While recent research has focused on complex adaptation modules and auxiliary networks, this paper argues that the quality of the feature extractor—the backbone—is a primary determinant of success. Specifically, the authors investigate how the "flatness" of the loss landscape during backbone training influences generalization across disparate domains.

The Importance of Loss Landscape Flatness

Standard training typically employs Empirical Risk Minimization (ERM), which seeks the global minimum of the training loss. However, ERM often converges to "sharp" minima that are highly sensitive to distribution shifts. In contrast, Sharpness-Aware Minimization (SAM) explicitly searches for "flat" minima—regions where the loss remains low even under small parameter perturbations.

Conceptual comparison of ERM (sharp) and SAM (flat) loss landscapes. Flat minima correlate with better generalization under distribution shifts.

Theoretically, the generalization gap on a target domain is upper-bounded by the difference between SAM and ERM loss on the source domain. This suggests that optimizing for flatness during the pre-training or fine-tuning phase can significantly improve performance on unseen tasks by making the model more robust to the variations encountered in new domains.

Methodology

The researchers propose a streamlined three-step protocol for robust backbone training:

  1. Flatness-Aware Training: Utilizing SAM instead of ERM to ensure the backbone converges to a flat region of the loss landscape. This requires two forward/backward passes per step but yields more generalizable features.
  2. Information Fusion via Fine-tuning: Instead of complex fusion architectures, the authors use simple fine-tuning or Low-Rank Adaptation (LoRA) to adapt a base ImageNet-trained backbone to specific domains. They found that simplicity often outperforms over-engineered adaptation schemes.
  3. Backbone Selection: For new tasks, the Pairwise Annotation Representation Comparison (PARC) metric is used to select the most relevant domain-specific backbone from a pre-trained bank of models.

Experimental Results

The framework was evaluated on the Meta-Dataset benchmark, the gold standard for multi-domain FSC, encompassing diverse "seen" domains (e.g., ImageNet, Omniglot, Aircraft) and "unseen" domains (e.g., MSCOCO, MNIST, Traffic Signs).

Test accuracy comparison between ERM and SAM across seen and unseen domains, demonstrating consistent gains from flatness-aware training.

The results demonstrate that the SAM-based approach (SAM+FT) outperforms state-of-the-art methods on 10 out of 13 domains in the benchmark. Switching from ERM to SAM consistently improved average test accuracy across various adaptation methods. For instance, on unseen domains, SAM provided a ~1.72% accuracy boost over the ERM baseline when paired with TSA adaptation. Furthermore, Hessian analysis confirmed that SAM indeed produces backbones with significantly lower curvature (flatter landscapes) compared to standard ERM.

Conclusion

This work highlights that the optimization strategy used during backbone training is as critical as the adaptation mechanism itself. By prioritizing flatness in the loss landscape through SAM, researchers can achieve superior generalization in multi-domain few-shot classification with simpler, more robust pipelines. While SAM increases computational cost during training, the resulting performance gains suggest that the community may benefit from focusing on basic optimization principles rather than increasingly complex adaptation modules.

Summary updated

BibTeX
@inproceedings{li2025flatness,
  author = {Rui Li and Martin Trapp and Marcus Klasson and Arno Solin},
  title = {{Flatness Improves Backbone Generalisation in Few-Shot Classification}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  doi = {10.1109/wacv61041.2025.00113},
}
Figure