Regularization in Neural Networks
Regularization refers to methods that improve generalization by reducing a model’s effective capacity, variance, or sensitivity to noise. Unlike normalization layers, which stabilize optimization, regularizers shape the hypothesis space to avoid overfitting.
Regularization operates through different methods, including penalties on parameters and averaging hypotheses to reduce variance:
- Weight decay adds an L2 penalty to the loss, such that the loss and gradient descent update rule become
Weight decay shrinks weights toward zero, encouraging smoother, lower-norm solutions that reduce model complexity and avoid sharp minima.
- Statistically, it corresponds to MAP estimation under a Gaussian prior, lowering the variance of the estimator and improving generalization.
- Because models start with small weight values, stopping gradient descent early (i.e., when the validation error stops decreasing) implicitly acts as weight decay.
- Dropout randomly disables activations during training. For activation :
It increases generalization by forcing redundant representations and reduces effective model capacity. At inference, dropout uses the expected activation by averaging over all possible combinations of input neurons.
- Residual (skip) connections add the input of a layer directly to its output in-between blocks, such that , where is a learned transformation (e.g., a feedforward block or attention module). They stabilize optimization by improving gradient flow by reducing the frequency of vanishing/shattered gradients, allowing very deep networks to train effectively, and encouraging solutions that remain close to the identity mapping when needed.
- Model averaging reduces variance by combining multiple hypotheses rather than relying on a single model. It includes ensembling strategies and explicit averaging of parameters.
- Ensembling works by training multiple models and combining their predictions (usually by averaging). Ways to differentiate models are not specified, and the main goal is to reduce variance and improve generalization.
- Bagging is an ensembling method that samples bootstrap datasets, trains one model per dataset and then averages the predictions. It is very useful for smaller/noisier datasets and decorrelates models via resampling.
- Mixture-of-Experts (MoEs) route each input to a subset of expert networks, assigning learned gating weights (usually sparse) to each expert, such that
MoEs regularize by activating only a few experts per input, creating structured sparsity and specialized submodels that reduce overfitting.
Examples
Vanishing Gradients & ResNets
The deeper a neural network grows, the more likely it will suffer from vanishing gradients because downstream layers (i.e., earlier layers) are the product of many backpropagated gradients–any of which may be close to zero. This example explores one approach to address vanishing gradients.
For one, the vanishing gradient problem can arise from saturating activation functions, such as the sigmoid.
What’s the maximum gradient of the sigmoid function? Taking its derivative, we obtain Since , the maximum gradient occurs at .
The sigmoid function is expressed as
Why might ReLU be more preferable than the sigmoid function in deep networks? Its gradient is simply As such, the gradient takes its maximum value of 1 whenever x>0. In deeper networks, repeatedly multiplying gradients smaller than one can cause vanishing gradients, whereas ReLU preserves gradient magnitude in its active region. Note, however, that the dying ReLU problem can occur when neurons output zero for all inputs, causing their gradients to remain zero and preventing further learning.
The ReLU activation is expressed as
One common way to tackle vanishing gradients is by adding residual connections. The figure
below shows a simplified example of a residual block. Assume that the weights consist of an
affine layer with zero biases.

Write an expression for in terms of , and . We have two linear layers with a ReLU in between them. As such,
Assuming scalar variables, compute the gradient . Based on what you see numerically, why does a residual connection preserve gradient norms better? We have that When , the ReLU unit is inactive and its gradient is zero, meaning the neuron itself is still “dead.” However, due to the additive skip connection, the total gradient remains equal to , allowing gradients to propagate backward through the identity path. Thus, residual connections mitigate the effects of dying ReLU by preserving gradient flow, even though the ReLU unit itself remains inactive.
Dropout
In this example we explore dropout as a form of regularization.
Example