Advanced Mathematics

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 z=∑i=1256wixiz = \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 σ2\sigma^2. What σ\sigma keeps Var(z)=1\mathrm{Var}(z) = 1? If instead σ2=2/256\sigma^2 = 2/256 and ten such layers are stacked with no activation, what is the variance at the end?
Show the worked answer
Each term has Var(wixi)=E[wi2]E[xi2]=σ2\mathrm{Var}(w_ix_i) = E[w_i^2]E[x_i^2] = \sigma^2, and the 256 independent terms add: Var(z)=256σ2\mathrm{Var}(z) = 256\sigma^2. So σ2=1/256\sigma^2 = 1/256, σ=1/16=0.0625\sigma = 1/16 = 0.0625. With σ2=2/256\sigma^2 = 2/256 the variance doubles at every layer, so after ten layers it is 210=10242^{10} = 1024: the signal's size has grown 32-fold. (With ReLU, which zeroes about half the signal, σ2=2/n\sigma^2 = 2/n is exactly what keeps it steady.)

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.

On the way to

Recommended