Sharpness-Aware Minimization (SAM) has emerged as a powerful technique for improving the generalization of deep learning models. By seeking parameters in "flat" regions of the loss landscape, SAM helps models remain robust to small perturbations. However, a fundamental design flaw exists in its standard formulation: it uses the same surrogate loss (typically cross-entropy) for both updating model weights and finding the "worst-case" perturbations. This paper introduces BiSAM (Bilevel SAM), a novel approach that decouples these objectives to find significantly stronger perturbations and achieve better generalization.
The Flaw in Symmetric Objectives
In standard SAM, the goal is to solve a minimax problem where the model tries to minimize a loss that has been maximized by an adversary within a small neighborhood. While we ultimately care about the misclassification error (0-1 loss), we optimize cross-entropy because it is differentiable. Cross-entropy acts as an upper bound on the 0-1 loss.
The authors identify a critical logical gap: maximizing an upper bound does not guarantee that you are maximizing the actual error. In many cases, an adversary maximizing cross-entropy might focus on "distraction" points that are already correctly classified but have high cross-entropy, rather than points near the decision boundary that are truly at risk of misclassification. This results in "weak" perturbations that fail to provide sufficient regularization.
BiSAM: Decoupling the Adversary
BiSAM addresses this by treating the problem as a bilevel optimization task with asymmetric objectives:
- The Minimizer (Weights): Continues to use an upper bound (cross-entropy) to minimize the overall error.
- The Maximizer (Perturbation): Uses a newly derived differentiable lower bound of the 0-1 loss to find perturbations that are more likely to cause actual misclassifications.
To make the non-differentiable 0-1 loss usable for gradients, the authors employ smooth surrogate functions $\phi$ (such as $\tanh$ or a specialized log-exponential function). They also utilize a log-sum-exp trick to ensure the perturbation considers all potential misclassifications across multiple classes. By applying a first-order Taylor expansion, BiSAM maintains the same $O(1)$ computational overhead as standard SAM, requiring only two forward/backward passes per update.
Key Insights
- Stronger Adversaries Lead to Better Regularization: As shown in the figure above, BiSAM consistently identifies more misclassified samples during training. By forcing the model to defend against these "truer" worst-case scenarios, the resulting minima are flatter and more robust.
- The "-log" Advantage: While a simple $\tanh$ lower bound is effective, it can suffer from vanishing gradients for points that are very correctly classified. The authors' proposed
-logversion maintains informative gradients, allowing the adversary to effectively push even "safe" points toward the decision boundary for better margin maximization. - Plug-and-Play Compatibility: BiSAM is a reformulation of the SAM objective rather than a completely new algorithm. It can be easily integrated into existing variants like Adaptive SAM (ASAM) or Efficient SAM (ESAM).
Experimental Results
The researchers evaluated BiSAM across a wide range of benchmarks, including CIFAR-10/100, ImageNet-1K, and the GLUE benchmark for NLP.
Key performance highlights include:
- Computer Vision: BiSAM (-log) outperformed standard SAM across all tested architectures on CIFAR datasets and achieved a statistically significant improvement on ImageNet-1K (75.96% vs 75.83%).
- NLP Breakthroughs: On the GLUE benchmark using BERT-base, BiSAM showed dramatic improvements, particularly on difficult tasks like WNLI, where accuracy rose from 41.20% (SAM) to 49.53%.
- Robustness to Noise: In extreme scenarios with 80% label noise, BiSAM maintained 50.00% accuracy, significantly higher than standard SAM's 44.68%.
Conclusion
By rethinking the optimization formulation of SAM and introducing asymmetric objectives, BiSAM provides a more principled way to find flat minima. The use of a differentiable lower bound for the adversary ensures that the model is regularized against true misclassification risks, leading to state-of-the-art generalization performance without increasing training time.
Summary updated