Dropout, Batch Norm & Early Stopping
Part of the Machine Learning Roadmap
In short
Deep networks are so powerful they can memorise the training set, labels and noise included. Dropout and batch norm help them generalise instead, and train more smoothly.
Dropout randomly switches off neurons during training so the network cannot rely on any single one. Batch normalisation keeps layer inputs at a stable scale for faster training, and early stopping halts training when validation loss stops improving.

Think of it like this
Random rest days at nets practice
A coach rests random players at each nets session. Nobody can rely on the star batter always being there, so everyone learns to contribute. On match day the whole team plays. That's dropout: random neurons sit out in training, and all play at prediction time.
Watch it happen
Dropout with p = 0.3 on six neurons
1/5A hidden layer with six neurons. During training, each batch drops about 30% of them at random.
The big ideas
What you need to know
Dropout breaks reliance
Neurons can't depend on one partner, so they learn more independent, useful features.
Batch norm steadies
BatchNorm rescales each layer's outputs within a batch. Training gets more stable and can use higher learning rates.
Train vs eval mode
Both layers behave differently in training and prediction. Always switch modes correctly.
Early stopping too
Stop training when validation loss stops improving. Weight decay, an L2 penalty, also helps.
See it in code
Walk through the code
1import torch2from torch import nn3 4model = nn.Sequential(5 nn.Linear(64, 128),6 nn.BatchNorm1d(128), # normalise each batch's activations7 nn.ReLU(),8 nn.Dropout(p=0.3), # randomly zero 30% during training9 nn.Linear(128, 10),10)11 12model.train() # dropout on, batch stats used13out_train = model(torch.randn(32, 64))14model.eval() # dropout off, running stats used15out_eval = model(torch.randn(1, 64))1/4BatchNorm rescales the 128 outputs using the current batch's mean and spread.
BatchNorm and Dropout inside a small PyTorch model, plus the mode switch that changes how both behave.
Save yourself the pain
Common mistakes
Oops
Forgetting model.eval() before making predictions.
Do this instead
Call model.eval() for validation and inference, and model.train() before going back to training.
Oops
Setting dropout to 0.8 everywhere to fight overfitting.
Do this instead
Start around 0.2 to 0.5 on large dense layers. Too much dropout makes the model underfit.
Your mission
Overfit, then fix it
Quick check
Why does dropout get switched off at prediction time?
Go deeper
- 1Add nn.Dropout to an overfitting network and compare validation loss.
- 2Add nn.BatchNorm1d and see how training speed changes.
- 3Remember model.train() and model.eval(), because both layers behave differently in each mode.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.