Investigating the Role of Weight Decay in Enhancing Nonconvex SGD

Tao Sun, Yuhao Huang, Li Shen, Kele Xu, Bao Wang

Introduction

Weight Decay (WD) is a ubiquitous technique in deep learning, often implemented as $L_2$ regularization to prevent overfitting. Despite its widespread use, a rigorous theoretical understanding of its impact on nonconvex optimization—the regime of modern neural networks—has remained elusive. Traditional intuition suggests that WD helps by keeping weights small, but practitioners have observed that "decoupled" weight decay (as seen in AdamW) often outperforms standard $L_2$ regularization. This paper investigates whether WD actually accelerates convergence or if its primary benefit lies elsewhere, specifically in improving the generalization capabilities of Stochastic Gradient Descent (SGD).

Theoretical Framework: SGDW and SignSGDW

The authors establish a convergence theory for SGD with Weight Decay (SGDW) under relaxed assumptions. Unlike previous studies that required globally bounded gradients, this framework accommodates more realistic nonconvex landscapes. The analysis extends to SignSGDW, a variant that utilizes only the sign of the gradient. This is particularly relevant for communication-efficient distributed training and newer optimizers like LION.

A key contribution of the paper is the introduction of a geometric parameter, $\delta$. This parameter measures the alignment between the gradient $\nabla f(w)$ and the weight vector $w$. Specifically, $\delta$ captures the non-linearity of the optimization path. The authors demonstrate that the benefit of weight decay is intrinsically tied to the fact that gradients and weights are typically not linearly dependent ($\delta < 1$).

Evolution of the geometric parameter $\delta$ across different architectures and datasets, showing how alignment changes during training.

Algorithmic Stability and Generalization

The core finding of the research is that weight decay acts as a mechanism to enhance "algorithmic stability." Using the concept of uniform stability—which quantifies how much a model's output fluctuates when a single training sample is changed—the authors provide the first theoretical proof that weight decay improves generalization in nonconvex optimization.

While weight decay might slow down the reduction of training loss (acting as a "speed bump" rather than a "turbo"), it significantly reduces the stability bound of the algorithm. This leads to a tighter generalization error bound, proven to be $O(1/n^{1/4})$ under specific conditions where the decay rate is proportional to the learning rate.

Empirical Results

The theoretical insights were validated using VGG16 on CIFAR-10, ResNet20 on CIFAR-100, and ResNet18 on ImageNet. The experiments confirmed a clear trade-off: while models with no weight decay (wd=0) reached the lowest training loss the fastest, they consistently exhibited higher test loss and lower test accuracy compared to models with moderate weight decay.

Test loss and test accuracy across different epochs for various weight decay settings. Moderate weight decay leads to superior generalization despite slower initial progress.

As shown in the empirical data, setting the weight decay hyperparameter too high can be detrimental, potentially preventing convergence altogether (as seen with wd=5e-2 in some VGG16 trials). However, the "sweet spot" of weight decay consistently yields models that generalize better to unseen data.

Conclusion and Limitations

This work clarifies the role of weight decay in nonconvex SGD, shifting the focus from convergence acceleration to algorithmic stability. By proving that WD improves generalization bounds, the authors provide a solid theoretical foundation for a common practice.

However, some limitations remain. The generalization proofs for high decay rates currently require specific Lipschitz constraints on the loss function. Additionally, while the study covers SGD and SignSGD, extending these rigorous stability proofs to fully adaptive methods like Adam remains a challenge for future research. Determining the theoretically optimal weight decay for a given architecture and dataset also remains an open question.

Summary updated

BibTeX
@inproceedings{sun2025investigating,
  author = {Tao Sun and Yuhao Huang and Li Shen and Kele Xu and Bao Wang},
  title = {{Investigating the Role of Weight Decay in Enhancing Nonconvex SGD}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01424},
}
Figure