Lesson 8.5 · 8 min read · about 55 min to master at a very slow pace
Hyperparameters and a Training Recipe
What hyperparameters are, how to search them, how to read a learning rate from the loss curve, and a seven-step procedure for training a network that works.
Hyperparameters
Everything not learned by gradient descent: the number of layers and units, activations, learning rate, batch size, number of epochs, regularisation strength , dropout rate and initialisation. Choose them on the validation set.
- Grid search: every combination; cost grows exponentially with the number of hyperparameters.
- Random search: usually better once you have more than two or three hyperparameters.
- Bayesian optimisation, or by hand guided by learning curves.
- Search and on a log scale (0.001, 0.01, 0.1, …).
Reading the learning rate from the loss curve
A training recipe
- Data: shuffle; split train/validation/test; normalise with training statistics; encode categories.
- Task: pick the output layer and loss (Section 6).
- Sanity check: a reasonably sized network should drive the training cost near zero on about 100 examples. If it can't, there's a bug in the code or data.
- Train with mini-batch gradient descent or Adam, recording training and validation curves every epoch.
- Underfitting (both errors high): bigger network, longer training, higher ; check normalisation and activations.
- Overfitting (large gap): more data or augmentation, weight decay, dropout, early stopping, or a smaller network.
- Select hyperparameters on validation, evaluate once on the test set, and report that number.
Stuck? Common doubts
Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.
First passWhy should a network be able to overfit 100 examples?
Because memorising a tiny dataset is the easiest thing a network can do. If it can't even do that, the problem isn't generalisation: it's a bug (wrong labels, a broken gradient, a learning rate far off). It's a quick test that saves hours of tuning.
Going deeperWhat did the lab show matters most for training a small XOR network?
Width had the largest effect: 2 hidden units converged in about 80% of random starts, 3 or more in all of them. The learning rate barely mattered within 0.3–3, but a huge one (300) pushed every unit into saturation on the first step and training stalled at loss 0.25. Very small initial weights (0.1) left all hidden units identical, on a plateau.
Cheatsheet
Training recipe
Learning-rate diagnosis
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.