Regularization in Deep Learning
🎯 Learning Objectives
- Explain dropout with its inverted scaling trick
- Describe batch normalisation (forward pass and learnable parameters)
- Distinguish L1 vs L2 weight decay
- Know common data augmentation strategies
- Understand early stopping as implicit regularisation
1. Dropout
Dropout (Srivastava et al., 2014)
During training:
maskj ~ Bernoulli(1 − p) for each neuron j
h' = mask ⊙ h / (1 − p) (inverted dropout)
During inference:
Use all neurons — no masking, no scaling.
With probability p (e.g., p=0.5), each neuron’s output is set to 0. The division by (1−p) ensures that expected output magnitude stays the same.
Why Dropout Works
- Prevents co-adaptation: neurons cannot rely on specific other neurons.
- Approximates an ensemble of 2n different thinned networks.
- Adds multiplicative noise, acting as a regulariser.
GATE Tip
Dropout is applied only during training. At test time, all neurons are active (with inverted dropout, no rescaling is needed at test time).
2. Batch Normalisation
Batch Norm (Ioffe & Szegedy, 2015)
For a mini-batch B = {x1, …, xB}:
μB = (1/B) ∑ xi
σB² = (1/B) ∑ (xi − μB)²
x̂i = (xi − μB) / √(σB² + ε) (normalise)
yi = γ · x̂i + β (scale and shift)
Learnable parameters: γ (scale) and β (shift) per feature.
ε ≈ 10−5 for numerical stability.
Benefits of Batch Norm
- Reduces internal covariate shift: each layer’s input distribution stays stable.
- Allows higher learning rates and faster convergence.
- Slight regularisation effect due to mini-batch noise in μ and σ².
- Reduces sensitivity to weight initialisation.
BatchNorm Parameter Count
For a layer with C output channels (or features): 2C learnable parameters (γ and β). For a conv layer producing 64 feature maps: 128 parameters from BatchNorm.
3. Weight Decay (L2 Regularisation)
Jreg = J + λ/2 · ‖w‖²
Gradient update:
w ← w − η(∇J + λw)
w ← (1 − ηλ)w − η∇J
The factor (1 − ηλ) shrinks weights toward zero each step.
L1 vs L2
| Property | L1 (Lasso) | L2 (Ridge / Weight Decay) |
|---|---|---|
| Penalty | λ ∑ |wi| | λ/2 ∑ wi² |
| Effect | Sparse weights (feature selection) | Small but non-zero weights |
| Common in DL? | Less common | Very common (default in most frameworks) |
4. Data Augmentation
Artificially increase dataset size by applying label-preserving transformations:
| Domain | Augmentation Techniques |
|---|---|
| Images | Random crop, horizontal flip, rotation, colour jitter, cutout, mixup |
| Text | Synonym replacement, random insertion, back-translation |
| Audio | Time stretching, pitch shifting, noise injection |
Data augmentation is one of the most effective regularisers in practice, especially for small datasets.
5. Early Stopping
Monitor validation loss during training. Stop when the validation loss starts increasing (while training loss continues to decrease).
- Patience: Number of epochs to wait for improvement before stopping (e.g., patience = 10).
- Restore the model weights from the epoch with the best validation loss.
- Acts as implicit regularisation by limiting model complexity (fewer effective training iterations).
6. Label Smoothing
Instead of hard targets y = [0, 0, 1, 0]:
ysmooth = (1 − α) · y + α / K
With α = 0.1 and K = 4 classes:
ysmooth = [0.025, 0.025, 0.925, 0.025]
Prevents the model from becoming overconfident, improving generalisation.
7. Regularisation Summary
| Technique | Where Applied | Training Only? | Extra Params? |
|---|---|---|---|
| Dropout | After activations | Yes | No |
| Batch Norm | Before/after activation | No (uses running stats at test) | Yes (2 per feature) |
| Weight Decay | Loss function | Yes (affects gradients) | No |
| Data Augmentation | Input data | Yes | No |
| Early Stopping | Training loop | Yes | No |
| Label Smoothing | Target labels | Yes | No |
Summary
- Dropout randomly zeroes neurons (train only); division by (1−p) keeps expected values.
- Batch Norm normalises layer inputs; has 2C learnable parameters per layer.
- Weight Decay = L2 penalty; shrinks weights by factor (1−ηλ) each step.
- Data augmentation is often the single most impactful regulariser.
- For GATE: know dropout mechanics (train vs test), batch norm formula, and L1 vs L2 differences.