3.5 Training in practice
1. Learn
Section titled “1. Learn”- Understanding Deep Learning (Prince)chapter 9 Regularization, §9.3 Heuristics to improve performance (pp. 143–154)
- Karpathy, A Recipe for Training Neural Networkswhole post
2. Bridge
Section titled “2. Bridge”Neural network bugs are silent. A wrong shape raises an error, but a shuffled label, a missing normalisation or a schedule that never steps just gives a model that is somewhat worse, and nothing tells you why. Karpathy’s recipe is built around that: become one with the data first, start from a model too simple to get wrong, check the loss at initialisation (about for balanced classes), and overfit a single batch to near zero before scaling up (Karpathy 2019). Only once the model can overfit do you add regularisation to win back validation performance.
Read the curves. Plot training and validation loss together, every time. Loss that spikes or goes NaN means the learning rate is too high. A slow, straight decline means it is too low. A widening gap with rising validation loss means overfitting, and both curves stuck high together mean underfitting. If training loss falls while validation loss stays near chance and then climbs, suspect the data, not the model: what it learns does not carry over. If training loss is stuck near chance too, suspect the model first (CS231n, babysitting the learning process). The clinic below has one real run of each.
Dropout zeroes each hidden unit with probability during training, a different random set for every example and every step. No unit can rely on a particular partner, and the network is in effect training an exponentially large family of thinned sub-networks that share weights (Srivastava et al. 2014; UDL §9.3.3). Inverted dropout divides the kept units by during training, so the expected activation is unchanged and evaluation simply turns dropout off. The full network then approximates the average of all sub-networks. Forgetting to turn it off at evaluation gives random predictions, which is one of the bugs in the lab.
3. Explore
Section titled “3. Explore”First write inverted dropout and its backward pass. Then the lab: train_a to train_f are six complete training scripts, each with exactly one planted bug, the kind that cost real people days. Run the tests, read which one fails and how, then find and fix the bug in place. Every fix is a one- or two-line change, and the helper functions are correct.
stubs/m3_5_spot_the_bug.pyLoading starter file…
Prefer your own editor? Edit exercises/stubs/m3_5_spot_the_bug.py and run mlc check 3.5. The tests are identical; import the results on the progress page.
Locally: mlc check 3.5.
5. Check
Section titled “5. Check”- not yet: All tests pass (0/?)
- not yet: Checkpoint quiz ≥ 80%
Learner log: time spent and points of confusion
Every confusion you note becomes a fix before the module is marked stable. Export it from the progress page and attach it to an issue.