Weight decay is one of the most common settings in neural network training. It steadily pulls the model’s internal numbers toward zero so that none of them grows too large. A model trained this way tends to settle on simpler patterns, and it usually does better on data it has never seen. The textbook story, that it simply stops overfitting, is being revised: recent work suggests its main job in today’s large networks is to change how training unfolds.
How Weight Decay Works Inside a Network
A neural network’s weights are millions or billions of adjustable numbers that set how strongly each input affects the output. Training adjusts these weights step by step to reduce the model’s errors on example data. Weight decay adds a second goal: keep the weights small, by charging a penalty for large ones. At each step every weight is shrunk a little, as if it were slowly decaying toward zero, which is where the name comes from.
You will most likely meet weight decay as a single number in a training library, often named weight_decay. Typical values are small, such as 0.01 or 0.0001, and setting it to zero turns it off completely. You choose it before training starts, alongside the step size.
A single update has two parts. One is a push from the data that says which direction reduces error. The other is a small multiplicative shrink that scales the weight down by a tiny fraction. A weight whose data push is near zero just drifts toward zero over many steps, which is why unused or redundant weights fade away. A weight with a steady, consistent push settles where the data’s pull and the shrink balance, so it ends up smaller than it would be without decay, but not zero.
Smaller weights tend to mean a better model because of overfitting, which is when a model memorizes quirks of its training examples instead of learning patterns that carry over to new data. Large weights let a model bend sharply around individual examples, including their noise. In simple networks, weight decay picks the smallest set of weights that still solves the task, removing parts that don’t matter.1Advances in Neural Information Processing Systems. A Simple Weight Decay Can Improve Generalization Set at the right strength, it also cuts down how much random noise in the training labels gets learned.1Advances in Neural Information Processing Systems. A Simple Weight Decay Can Improve Generalization
What Weight Decay Does to Training and Test Results
With substantial weight decay, the error on training data goes up while the error on held-out test data goes down.2d2l.ai. 3.7. Weight Decay The model gives up a bit of fit on examples it has already seen in exchange for doing better on new ones. Too much decay, though, makes the model too simple to learn the task well, so the strength has to be balanced.
In your training curves, expect the training loss line to sit a little higher than it would without decay, with the validation line ending lower or flatter. A big gap between the two, especially one that keeps widening, is one sign the model may be memorizing the training data.
The two failure modes look different. With too little decay, the model can look excellent on training data while validation results lag behind, because nothing discourages it from bending around individual examples. With too much, the weights are held so small that even training performance stays poor, so the model underfits. The right setting usually sits between these, and the validation curve is the thing to watch while searching for it.
The newer view is that weight decay changes how training behaves. For image-recognition networks trained over many passes through the data, it mainly helps by keeping training in a stable state that strengthens the natural tendency of training to find simple solutions.3Advances in Neural Information Processing Systems. Why Do We Need Weight Decay in Modern Deep Learning? For large language models that see their data about once, it instead balances noise in training, giving lower training loss and steadier runs.3Advances in Neural Information Processing Systems. Why Do We Need Weight Decay in Modern Deep Learning? One research view therefore holds that in modern deep learning, weight decay is useful mainly as a way to steer training in a good direction, not as a brake on overfitting.3Advances in Neural Information Processing Systems. Why Do We Need Weight Decay in Modern Deep Learning? In networks that use normalization layers, adding the weight penalty does not limit model complexity at all. It changes the scale of the weights and so the effective step size.4arXiv. L2 Regularization versus Batch and Weight Normalization Many tutorials say weight decay only prevents overfitting, yet large models trained once through their data barely overfit and still benefit.
To see what weight decay itself does, compare two runs that differ only in that setting, with the same data, seed, step size and number of passes. Run-to-run randomness can produce small differences, so a tiny gain in one comparison is weak evidence. Repeating with a different random seed makes the comparison more trustworthy.
Weight Decay, L2 Regularization and AdamW
L2 regularization adds the sum of the squared weights to the error the model is trying to reduce, and in neural networks this penalty is commonly called weight decay.5Neurocomputing. Group Sparse Regularization for Deep Neural Networks It is by far the most common way of regularizing a network.5Neurocomputing. Group Sparse Regularization for Deep Neural Networks The idea of penalizing squared values goes back to 1940s mathematics on unstable problems and was first studied systematically for neural networks in 1991.6OpenReview (NeurIPS 2024 / arXiv). Why Do We Need Weight Decay in Modern Deep Learning?
The two names stop meaning the same thing in one situation. The learning rate is the step size: how far the weights move at each training step. With standard stochastic gradient descent, adding the squared-weight penalty and directly shrinking the weights are the same thing once you adjust for the step size.7arXiv. Decoupled Weight Decay Regularization
Adaptive optimizers like Adam break this. Adam divides each weight’s update by a running estimate of how large that weight’s recent gradients have been, so weights with large gradients take smaller steps and weights with small gradients take larger ones. When the squared-weight penalty is added to the error, its contribution enters the gradient and gets divided by that same estimate. The shrinking becomes uneven, and weights with historically large gradients are shrunk less than intended, the opposite of a uniform pull toward zero.
AdamW fixes this by separating the shrinking from the rest of the update, applying weight decay directly to the weights.7arXiv. Decoupled Weight Decay Regularization The shrink happens after the adaptive update is computed, so it no longer passes through Adam’s per-weight scaling. Because the shrink is separate, the best decay value is much less tangled up with the best step size, which makes tuning each one easier. They still interact somewhat, so retuning one after changing the other is sensible. If you use Adam-style training, choosing AdamW is the usual way to get true weight decay.
In PyTorch, the weight_decay setting in Adam adds the squared-weight penalty, while AdamW applies decoupled decay. The same number can behave very differently in the two, so tutorials that copy values between them can give misleading results. AdamW is the default choice for most transformer models.
How Weight Decay Compares With L1 and Early Stopping
L1 regularization penalizes the absolute size of the weights rather than their squares.5Neurocomputing. Group Sparse Regularization for Deep Neural Networks It pushes many weights to zero, leaving a sparse model where fewer connections matter, which can be easier to interpret.8International Journal of Engineering Trends and Technology. A Comparative Analysis of L1, L2, and L1L2 Regularization Techniques in Neural Networks for Image Classification The cost is that L1 can over-penalize important features and lose some accuracy.8International Journal of Engineering Trends and Technology. A Comparative Analysis of L1, L2, and L1L2 Regularization Techniques in Neural Networks for Image Classification Weight decay shrinks weights smoothly without zeroing them, so it improves performance on new data but leaves the model fully connected.8International Journal of Engineering Trends and Technology. A Comparative Analysis of L1, L2, and L1L2 Regularization Techniques in Neural Networks for Image Classification Even with a cutoff that zeroes tiny weights, weight decay’s sparsity effect may be negligible, while L1’s is much higher.5Neurocomputing. Group Sparse Regularization for Deep Neural Networks
The reason lies in how each pull behaves near zero. The L1 penalty pulls each weight toward zero with a constant force no matter how small the weight already is, so a small weight can be driven all the way to zero. The squared penalty’s pull gets weaker as the weight gets smaller, so the weight shrinks toward zero but rarely lands exactly on it.
That affects which to pick. Choose L1 if you want a smaller model with many unused connections, and weight decay for the best accuracy in most deep networks. Some setups combine both, but for typical deep learning weight decay is the standard starting point.
Early stopping is a different kind of brake. It halts training when performance on held-out validation data stops improving, acting as an implicit limit on complexity rather than a penalty on the weights.9Machine Learning Mastery. A Gentle Introduction to Early Stopping to Avoid Over-training Neural Network Models In practice you track performance on held-out data during training and stop once it has not improved for a set number of checks, often keeping the best version seen. It limits how long the model has to fit the data, while weight decay limits how large the weights can become. Because they act on different parts of training, early stopping is often used together with weight decay rather than instead of it. It does need held-out data to monitor, so some of your data is set aside rather than used for learning.
Setting Weight Decay in Practice
A common recommendation is to apply weight decay only to the weights of linear and convolution layers.10PyTorch Forums. Weight decay only for weights of nn.Linear and nn.Conv* Biases for all layers, and the weights and biases of normalization layers such as LayerNorm, are usually excluded.10PyTorch Forums. Weight decay only for weights of nn.Linear and nn.Conv* Normalization layers make many weights’ size irrelevant to the output, so shrinking them mostly changes the effective step size instead of simplifying the model.4arXiv. L2 Regularization versus Batch and Weight Normalization
In PyTorch this usually means passing two parameter groups to the optimizer, one with decay and one with weight_decay set to zero. You loop over the model’s named parameters and sort each into one of two lists, with biases and normalization parameters in the no-decay list and the remaining layer weights in the decay list. A common shortcut is to treat any parameter with only one dimension as no-decay, since biases and normalization scales are one-dimensional while layer weight matrices have two or more.
Strength interacts with other settings. Weight decay and learning rate are linked, and with plain stochastic gradient descent plus normalization the effective step size can keep growing late in training, leading to overfitting.11arXiv. Weight Rescaling: Effective and Robust Regularization for Deep Neural Networks with Batch Normalization For AdamW in language-model training, the best weight decay rises in proportion to the batch size when model and data size are fixed.12Advances in Neural Information Processing Systems. Power Lines: Scaling laws for weight decay and batch size in LLM pre-training As models and datasets grow, the best setting follows a predictable pattern based on how many training tokens there are per parameter.12Advances in Neural Information Processing Systems. Power Lines: Scaling laws for weight decay and batch size in LLM pre-training Changing the strength during training according to the size of the gradients often beats a fixed value with Adam.13arXiv. On the Overlooked Pitfalls of Weight Decay and How to Mitigate Them: A Gradient-Norm Perspective
A practical routine is to start with a common default, such as 0.01 to 0.1 for AdamW, and try a few values spread by factors of ten. Judge them by validation performance, not training loss, and retune when you change the batch size or learning rate.
If validation keeps worsening while training improves, try stronger decay. If both losses stall high, try weaker decay. If training becomes unstable late on, check decay and step size together.
When scaling up a run, re-check decay rather than copying the old value. Short pilot runs at the new scale are a cheaper check than a full training run.
Weight Decay in Large Language Models and Fine-Tuning
Fine-tuning means taking an already trained model and training it further on a specific task. Models pretrained with stronger weight decay adapt better during fine-tuning and end up performing better on the new task.14Kempner Institute. Training Language Models That Can Continue to Learn A base model that looks worse right after pretraining can therefore come out ahead once it is fine-tuned.15arXiv. Weight Decay Improves Language Model Plasticity The reason is that weight decay encourages cleaner internal representations, regularizes attention, and reduces memorizing of training data.15arXiv. Weight Decay Improves Language Model Plasticity
The apparent paradox comes from what gets measured. Right after pretraining, the usual measure is how well the model predicts its own training-style text, and heavier decay can make that number look slightly worse. Fine-tuning tests something different: how readily the model reshapes itself for a new task, and cleaner representations help with that. Comparing base models only on pretraining loss can lead you to pick the wrong one.
Fine-tuning itself needs care. Optimizers like AdamW are built to explore widely, which helps when training from scratch.16Advances in Neural Information Processing Systems. Rethinking Weight Decay for Robust Fine-Tuning of Foundation Models When starting from a strong pretrained model, that exploration can pull the weights far from where they began, hurting robustness and performance on new data.16Advances in Neural Information Processing Systems. Rethinking Weight Decay for Robust Fine-Tuning of Foundation Models For fine-tuning, consider gentler settings that keep the model close to its starting point. Low learning rates and modest decay help keep a pretrained model’s knowledge, and it’s worth checking performance on both the new task and general tests.
Staying close to the start is not the same as shrinking toward zero. Ordinary weight decay pulls weights toward zero, but a pretrained model’s good values are not zero, so the pull can work against the knowledge it already holds. A different approach penalizes distance from the pretrained weights instead, keeping the model near where it began. Whether you need that depends on how different your task is from what the model was pretrained on.
Other Effects Researchers Have Found
Late in training, image classifiers often show a tidy pattern: examples of the same class end up at nearly the same internal point, with different classes evenly spaced apart.17arXiv. Towards Understanding Neural Collapse: The Effects of Batch Normalization and Weight Decay Weight decay strongly influences whether this pattern appears, and one analysis finds it is required for the pattern in certain networks.18ICASSP 2022 – 2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). Neural Collapse in Deep Homogeneous Classifiers and The Role of Weight Decay Wide networks trained with weight decay have been proven to show it.19International Conference on Learning Representations. Wide Neural Networks Trained with Weight Decay Provably Exhibit Neural Collapse
There are practical benefits too. Changing weight decay over training can steady convergence and lead to flatter, more forgiving solutions.20Emergent Mind. Scheduled Weight Decay in Deep Learning On a consumer GPU, AdamW with half-precision arithmetic cut training time per pass by about 30% and raised accuracy by 1.5 to 2.5 points compared with plain gradient descent at full precision.21Територія безпеки. COMPARATIVE ANALYSIS OF OPTIMIZATION ALGORITHMS AND MIXED-PRECISION TRAINING FOR MINIMIZING NEURAL NETWORK TRAINING TIME
That result combined several changes at once, a different optimizer and half-precision arithmetic, so it cannot be credited to weight decay alone. Half-precision arithmetic mainly saves time per pass, while the optimizer change likely accounts for more of the accuracy difference. It also comes from one consumer GPU setup, so treat it as an example of what is possible rather than a guarantee for your own project.

