Deep Learning

Follow the computations inside a network, then diagnose a training run.

Follow the computations inside a network, then diagnose a training run.

Before you start. Machine Learning and multivariable derivatives.

Use Python 3.12 for the examples. Install the dependencies with python -m pip install numpy torch. Run each week as a separate script. Try the worked example on paper first, then change one assumption in the lab and explain the result. All datasets are small or generated locally.

The 12 weeks

WeekLessonWhat you’ll do
1Tensors, shapes, and the forward passTrace a batch through two layers and catch a silent broadcast.
2Backpropagation and autodiffDerive one gradient, then check it with both autodiff and finite differences.
3Losses and output layersMatch output shape and loss to the meaning of the target.
4Initialization and gradient flowMeasure how repeated multiplication suppresses or amplifies gradients.
5Minibatches, momentum, and AdamCompare optimizers at the same update count and see why learning rate still matters.
6Regularization and training diagnosticsCompare weight decay, dropout, and validation-based checkpoint selection.
7Convolutions and residual connectionsCalculate a receptive field and compare a stack with an identity path.
8Recurrent sequence modelsLearn a delayed copy task and relate the delay to repeated Jacobians.
9Attention and transformersImplement scaled attention and verify that future tokens stay invisible.
10Transfer learning and fine-tuningCompare a frozen encoder with partial and full adaptation.
11Generative models and denoisingLearn the direction from a noisy input toward its training distribution.
12Capstone · Diagnose a neural network with an ablationTrain a nonlinear model and reproduce a failed run with one change.

Further reading · Goodfellow, Bengio, and Courville · Deep Learning