Preprint 1 Mention
Decoupled Weight Decay Regularization
Ilya Loshchilov2017
Frank Hutter
Top 5% · 95th Percentile
9,160 citations · Computational Mechanics
Open Access

TLDR

A small change to how computers train deep learning models makes them learn better and more reliably, especially when using a popular method called Adam.

Summary

1 Study Aim

The paper aims to investigate whether using L2 regularization (a method to prevent overfitting by penalizing large weights) or weight decay regularization (a method that shrinks weights during training) is better for training deep neural networks with both standard stochastic gradient descent (SGD) and adaptive gradient algorithms like Adam. The authors specifically want to find out why Adam often performs worse than SGD with momentum on image classification tasks and whether a simple change in how weight decay is applied can improve Adam's performance. The study wants to see if changing how regularization is done can help Adam work as well as other training methods.

2 Study Design

The authors compare the effects of L2 regularization and weight decay regularization in both SGD and Adam optimizers. They introduce a modified version of Adam, called AdamW, where weight decay is applied separately from the gradient update. The experiments use deep neural networks (ResNet architectures) on image classification datasets like CIFAR-10 and ImageNet32x32. They test different learning rate schedules (fixed, step-drop, cosine annealing) and analyze how the choice of regularization and learning rate affects model performance and hyperparameter tuning. Additional tests include longer training runs, normalized weight decay, and warm restarts to further improve results. The researchers tested their new method on popular image datasets using different training setups to see how well it works.

3 Findings

The research demonstrates that L2 regularization and weight decay are not the same for adaptive optimizers like Adam, even though they are equivalent for standard SGD. The authors show that decoupling weight decay from the gradient update (as in AdamW) leads to better generalization and lower test errors compared to using L2 regularization with Adam. AdamW also makes it easier to tune hyperparameters, as the best learning rate and weight decay values become more independent. The improvements are consistent across different datasets, network sizes, and training schedules. The paper recommends using decoupled weight decay (AdamW) for adaptive optimizers and suggests that this approach can close the performance gap between Adam and SGD with momentum on image tasks. The new way of applying weight decay helps models trained with Adam learn better and makes it easier to find good training settings.

Abstract

L$_2$ regularization and weight decay regularization are equivalent for standard stochastic gradient descent (when rescaled by the learning rate), but as we demonstrate this is \emph{not} the case for adaptive gradient algorithms, such as Adam. While common implementations of these algorithms employ L$_2$ regularization (often calling it "weight decay" in what may be misleading due to the inequivalence we expose), we propose a simple modification to recover the original formulation of weight decay regularization by \emph{decoupling} the weight decay from the optimization steps taken w.r.t. the loss function. We provide empirical evidence that our proposed modification (i) decouples the optimal choice of weight decay factor from the setting of the learning rate for both standard SGD and Adam and (ii) substantially improves Adam's generalization performance, allowing it to compete with SGD with momentum on image classification datasets (on which it was previously typically outperformed by the latter). Our proposed decoupled weight decay has already been adopted by many researchers, and the community has implemented it in TensorFlow and PyTorch; the complete source code for our experiments is available at https://github.com/loshchil/AdamW-and-SGDW

Referenced In