Abstract
Weight decay is a simple yet powerful regularization technique that has been very widely used in training of deep neural networks (DNNs). While weight decay has attracted much attention, previous studies fail to discover some overlooked pitfalls on large gradient norms resulted by weight decay. In this paper, we discover that weight decay can unfortunately lead to large gradient norms at the final phase (or the terminated solution) of training, which often indicates bad convergence and poor generalization. To mitigate the gradient-norm-centered pitfalls, we present the first practical scheduler for weight decay, called the Scheduled Weight Decay (SWD) method that can dynamically adjust the weight decay strength according to the gradient norm and significantly penalize large gradient norms during training. Our experiments also support that SWD indeed mitigates large gradient norms and often significantly outperforms the conventional constant weight decay strategy for Adaptive Moment Estimation (Adam).
Introduction
In deep learning, weight decay is a standard regularization technique used to prevent overfitting. The conventional wisdom suggests that by penalizing large weights, the model is forced toward simpler, smoother solutions. However, this paper identifies a major overlooked pitfall: weight decay can actually increase the gradient norm at the final stages of training.
From an optimization standpoint, a large gradient norm at the end of training indicates that the model hasn't truly converged to a stable stationary point. From a generalization standpoint, large gradient norms are heavily correlated with "sharp" minima, which are known to perform poorly on unseen data. The authors investigate why weight decay causes this instability—especially when paired with learning rate schedules—and propose a method to suppress these exploding gradient norms while retaining the benefits of regularization.
Methods: Scheduled Weight Decay (SWD) and AdamS
The authors propose Scheduled Weight Decay (SWD). Instead of applying a constant weight decay factor ($\lambda$) throughout training, SWD dynamically scales the weight decay strength inversely to the gradient norm. This acts as a negative feedback loop: if the gradient norm starts to spike (a sign of instability or moving into a sharp minimum), the effective weight decay is reduced, stabilizing the stationary points at the end of training.
This approach is implemented in a new optimizer called AdamS. While standard AdamW updates weights using a fixed weight decay parameter, AdamS calculates the mean of the exponential moving average of the squared gradients (denoted as $\bar{v}_t$) and divides the weight decay term by $\sqrt{\bar{v}_t}$.
Key Results and Insights
The authors evaluated AdamS on standard benchmarks including CIFAR-10/100, ImageNet, and Penn TreeBank. Several key insights emerged:
- Superior Accuracy and Closing the SGD Gap: AdamS consistently outperformed Adam, AdamW, and other variants (AMSGrad, AdaBound, RAdam) across various CNN architectures. Historically, SGD with momentum has generalized better than Adam on computer vision tasks; AdamS effectively closes this gap. For example, on ResNet18 (CIFAR-10), AdamS achieved a 4.91% test error, beating SGD (5.01%) and AdamW (5.08%).
- Hyperparameter Robustness: Because SWD dynamically adjusts weight decay strength, AdamS is far less sensitive to the initial weight decay hyperparameter than AdamW, requiring significantly less tuning to achieve optimal results.
- Finding Flatter Minima: By penalizing large gradient norms, AdamS naturally steers the optimization process into wider, flatter basins in the loss landscape, which is a strong indicator of good generalization.
Conclusion and Future Work
While AdamS shows significant improvements in computer vision tasks, it is not a universal replacement. In tasks where standard $L_2$ regularization inherently outperforms decoupled weight decay—such as training LSTMs for language modeling—vanilla Adam with $L_2$ regularization remains competitive. The authors suggest that exploring dynamic schedules for standard $L_2$ regularization is a promising direction for future research.
Summary updated