TL;DR
This paper introduces Smoothness-Adaptive SAM (SA-SAM), a novel optimization technique that automatically tunes the step size for Sharpness-Aware Minimization (SAM). By adapting to the local smoothness of the loss landscape, SA-SAM simplifies hyperparameter tuning and enhances SAM's ability to find flatter minima, leading to improved out-of-distribution generalization.
What Problem Does This Paper Address?
In recent years, deep learning models have become increasingly complex and data-hungry. A critical challenge for practitioners, especially those with limited computational resources, is effectively training and fine-tuning these models. A key factor influencing a model's ability to generalize to unseen data is the "flatness" of the local minima it converges to. Flatter minima are generally more robust to small perturbations in the input data, leading to better performance on out-of-distribution (OOD) datasets.
Sharpness-Aware Minimization (SAM) is a popular technique that explicitly aims to find these flatter minima by optimizing a minimax objective. However, SAM introduces two crucial hyperparameters: the perturbation radius ($\rho$) and the learning rate ($\eta$). Tuning these parameters is notoriously difficult and significantly impacts SAM's effectiveness. This paper addresses the challenge of simplifying SAM's application by developing an adaptive step-size mechanism that reduces the need for manual hyperparameter tuning.
Methods
The core contribution of this paper is the Smoothness-Adaptive Sharpness-Aware Minimization (SA-SAM) algorithm. SA-SAM builds upon the standard SAM framework, which involves a two-step process: first, finding a perturbed point that maximizes the loss within a small neighborhood, and second, minimizing the loss at this perturbed point.
The novelty of SA-SAM lies in its smoothness-adaptive step size rule. Instead of relying on fixed or manually tuned learning rates, SA-SAM dynamically adjusts the step size ($\eta_t$) at each iteration based on the local smoothness of the objective function. This is achieved by estimating the local curvature of the loss landscape. The paper proposes a specific step-size rule inspired by prior work on adaptive step sizes for gradient descent, which aims to balance convergence speed with stability. This adaptive step size is then integrated into the SAM update rule.
The perturbation radius ($\rho$) is still a hyperparameter, but the authors follow a common practice of setting it proportional to the square root of the step size ($\rho_t \propto \sqrt{\eta_t}$), which is motivated by theoretical results.
Datasets
The experiments were conducted on the CIFAR10-C dataset. This dataset is specifically designed to evaluate out-of-distribution (OOD) generalization. It consists of CIFAR-10 images corrupted with 19 different types of noise, simulating real-world data shifts and disturbances. The paper uses this dataset to assess how well models trained with different optimizers perform under these corrupted conditions.
Key Insights and Ideas
- Adaptive Step Size Simplifies SAM: The most significant insight is that an adaptive step size, informed by the local smoothness of the loss landscape, can effectively replace manual tuning of the learning rate in SAM. This makes SAM more accessible and easier to use.
- Enhanced Flat Minima Convergence: SA-SAM not only simplifies tuning but also appears to reinforce SAM's inherent tendency to converge to flatter minima. This suggests that the adaptive step size mechanism has a synergistic effect with SAM's core objective.
- Robustness Across Hyperparameters: The experiments show that SA-SAM's performance is less sensitive to variations in learning rate and weight decay compared to other optimizers like MSGD, SAM, and Adam. This indicates a more stable and predictable optimization process.
- Correlation Between Flatness and OOD Generalization: The paper reinforces the well-established idea that flatter minima (indicated by lower trace and maximum eigenvalues of the Hessian) correlate strongly with better OOD generalization. SA-SAM's ability to achieve both is a key finding.
Key Results
- Superior OOD Generalization: SA-SAM consistently achieved the best test accuracy (OOD generalization) on the CIFAR10-C dataset across different model architectures (VGG-19 and ViT-Small) and hyperparameter settings. For instance, in Figure 1, SA-SAM achieved 69.29% test accuracy, outperforming SAM (68.47%) and other baselines.
- Lower Curvature: SA-SAM consistently resulted in lower curvature of the loss landscape, as measured by the trace (Tr(H)) and the maximum eigenvalue (λmax(H)) of the Hessian. In some extreme cases, the Tr(H) for SA-SAM was orders of magnitude smaller than for Adam (e.g., 10^2 times smaller).
- Reduced Hyperparameter Sensitivity: Heatmaps in Figure 3 demonstrate that SA-SAM and SA-SGD exhibit more consistent performance across a range of learning rates and weight decay values, unlike MSGD, SAM, and Adam, whose performance varies significantly.
Limitations and Future Work
- Perturbation Radius Tuning: While SA-SAM simplifies learning rate tuning, the perturbation radius ($\rho$) still requires some attention. The authors mention that their choice of $\rho \propto \sqrt{\eta}$ is based on theoretical guidance and that other choices might further improve SA-SAM's performance. Investigating the optimal choice of $\rho$ is left for future work.
- Mini-batch Sampling: The paper notes that different mini-batch sampling schemes could potentially lead to better OOD generalization performance with SA-SAM.
- Theoretical Understanding: The authors suggest further theoretical investigation into SA-SAM's properties, particularly its connection to the "edge of stability" and progressive sharpening, as well as its theoretical guarantees for OOD generalization.
- Downstream Task Performance: The paper highlights recent work showing a strong correlation between flatness and downstream task performance. Investigating SA-SAM's effectiveness in such scenarios is identified as an important future direction.
Summary updated