MAI5063 Advances in Deep Learning · Week 3 learning resource

Optimization, explained

A guided tour of how a network learns. Each part explains one idea in a few lines, then lets you change the numbers and watch what happens. Read it before the lab, or come back to it when a training curve looks wrong.

Parts 7, read in order or jump Time about 40 min Setup none, works offline

What you will be able to explain

  • What a loss function and a gradient are, and why the update subtracts the gradient.
  • How learning rate and batch size change the path a training run takes.
  • What momentum, RMSProp and Adam remember, and why that helps.
  • How schedules, weight decay and normalisation make training steadier.

How to read this page

  • In an equation, select a highlighted symbol to see what it means.
  • Make a prediction before you move a slider. Then check it.
  • Every curve here is a mathematical teaching simulation, not a measured neural-network result.
  • Part 7 has a short self-check. The labs let you test the same ideas on real data.
Part 1 · The objective

What are we trying to minimise?

Training repeats one loop: predict, measure the error, compute the gradient, update the parameters. The error is a single number called the loss. Everything in this resource is about making that loop converge faster and more reliably.

In short. The loss is a landscape over the parameters. The gradient is the local slope, so stepping against it goes downhill. A zero gradient can also be a saddle or a maximum, so it does not prove you reached a good minimum.
Part 2 · Step size and gradient noise

How big a step, estimated from how much data

The learning rate η scales every update. Too small is slow, too large overshoots. The gradient itself is usually estimated from a mini-batch, which adds noise that shrinks as the batch grows.

In short. On L(θ) = θ² the update multiplies θ by (1 − 2η). Stability needs |1 − 2η| < 1, so η must stay below 1. Larger batches average out noise but cost more per update.
Part 3 · Memory in the update

Give the optimiser a velocity

In a narrow valley the gradient points mostly across it, so plain gradient descent zig-zags. Momentum keeps a decaying memory of earlier steps. Nesterov momentum checks the slope at the point momentum is about to reach.

In short. Momentum cancels sideways zig-zags and builds speed along consistent directions. High η together with high α can overshoot, and Nesterov is not guaranteed to win.
Part 4 · Adaptive step sizes

Let each parameter set its own pace

AdaGrad, RMSProp and Adam divide the step by a running estimate of how large each parameter's gradients have been. Real networks do this for every parameter at once. Here one scalar gradient lets you see the internal state after each update.

In short. AdaGrad adds up squared gradients forever, so its steps keep shrinking. RMSProp forgets old magnitudes. Adam adds a smoothed direction and bias correction on top of RMSProp.
Part 5 · Schedules and weight decay

Start boldly, finish carefully, stay small

A large learning rate makes quick early progress. A smaller one lets the weights settle. Weight decay adds a steady pull towards zero that discourages very large weights.

In short. Schedules change η over time. Weight decay changes the parameters directly. Lower training loss is not always a better model, so watch validation loss when you tune λ.
Part 6 · Scale and geometry

Change the scale, change the landscape

Features on very different scales stretch the loss surface into the narrow valley from Part 3. Standardising inputs, and normalising activations inside the network, rounds it out again.

In short. BatchNorm normalises each feature across the batch. LayerNorm normalises the features within one sample, so it does not depend on batch size. Both then apply a learned scale γ and shift β.
Part 7 · Check and apply

Predict, experiment, explain

When training goes wrong, form a hypothesis before changing the architecture. Use the table as a starting point, then test it with a controlled run.