Training Deep Networks
The practical craft that makes deep networks learn: sensible initialisation, normalisation, learning-rate schedules, minibatches and watching validation loss.
Needs a step first: 42
Backpropagation and SGD say how to change the weights; making it work on a deep network takes more. Signals must neither explode nor fade as they pass through many layers, which fixes the scale of the starting weights and motivates normalisation layers and residual connections. Training is a loop, usually with a learning rate that is warmed up then decayed: sample a batch, compute the cross-entropy loss, backpropagate, take an optimiser step, and check validation loss for overfitting. Every modern model, convolutional, transformer or diffusion, is trained with this loop.
Where it shows up: This loop trains convolutional networks, transformers and diffusion models alike.
How to hold it: In your head
Read loss curves to tell a learning rate that is too high from one too low and from overfitting, and see why the scale of the starting weights keeps signals from exploding or fading.
What knowing it looks like
- Write a training loop from scratch: batches, forward pass, loss, backward pass, update, validation.
- Choose the initial weight scale that keeps a layer's output variance steady.
- Diagnose from loss curves whether the learning rate is too high, too low, or the model is overfitting.
Test yourself
A linear layer computes , where the inputs are independent with mean 0 and variance 1, and the weights are independent of them with mean 0 and variance . What keeps ? If instead and ten such layers are stacked with no activation, what is the variance at the end?
Show the worked answer
Needs a step first: 42
Learn it with an AI
Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.
Be my maths tutor. I'm learning "Training Deep Networks" (Frontier tier): The practical craft that makes deep networks learn: sensible initialisation, normalisation, learning-rate schedules, minibatches and watching validation loss.
I already know: Backpropagation, Stochastic Gradient Descent and Adam, Overfitting and Regularisation, Cross-Entropy and KL Divergence.
Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away.
Finish by testing me with this: A linear layer computes $z = \sum_{i=1}^{256} w_i x_i$, where the inputs are independent with mean 0 and variance 1, and the weights are independent of them with mean 0 and variance $\sigma^2$. What $\sigma$ keeps $\mathrm{Var}(z) = 1$? If instead $\sigma^2 = 2/256$ and ten such layers are stacked with no activation, what is the variance at the end?
Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.Needs first
- BackpropagationComputing the gradient of the loss with respect to every weight by applying the chain rule backwards through the network, layer by layer.Frontier · Machine Learning
- Stochastic Gradient Descent and AdamGradient descent using the gradient of a small random batch instead of all the data, plus momentum and per-parameter step sizes (Adam).Frontier · Optimisation & Information
- Overfitting and RegularisationA model that fits its training data too closely does worse on new data; regularisation trades a little training fit for better generalisation.Undergraduate II · Machine Learning
- Cross-Entropy and KL DivergenceCross-entropy measures how many bits a model needs to describe data really drawn from ; KL divergence is the excess over the minimum.Undergraduate II · Optimisation & Information
Leads to
- Convolutional NetworksNetworks that slide one small learned filter across an image, so the same pattern detector is reused at every position.Frontier · Machine Learning
- Attention and TransformersEach token builds its new representation as a softmax-weighted average of all tokens' values, weighted by how well its query matches their keys.Frontier · Machine Learning
- Diffusion and Generative ModelsModels that learn to produce new samples like their training data; diffusion models do it by learning to remove noise step by step.Frontier · Machine Learning
On the way to
Recommended
- Neural Networks: Zero to HeroAndrej Karpathy · VideosFree lectures that build backpropagation, a language model and a small GPT from scratch in Python, explaining every line.
- Understanding Deep LearningSimon J. D. Prince (MIT Press) · BookA clear, well-illustrated 2023 textbook covering networks, training, transformers, diffusion models and reinforcement learning, free as a PDF with Python notebooks.
- 动手学深度学习阿斯顿·张、李沐等 · Book · 中文The Chinese edition of Dive into Deep Learning: a free textbook in which every model, from linear regression to transformers, runs as code beside the maths.
- 跟李沐学AI李沐 · Videos · 中文Mu Li's own Bilibili channel: the video course for Dive into Deep Learning and paragraph-by-paragraph readings of key papers, including the Transformer paper.