To fit a model, measure how wrong it is, find which direction makes it less wrong, and take a small step that way. Repeat. Watch that happen on a real loss surface, then break it with a bad learning rate.
The gradient of the loss points in the direction of steepest increase. Gradient descent moves the parameters the opposite way by a distance set by the learning rate η. The loss curve shows how far above the best possible loss the optimiser is after each step (log scale); a grey dashed line shows plain batch gradient descent with the same learning rate for comparison.
Too small and progress crawls. Too large and each step overshoots, so the loss grows instead of shrinking. For this kind of loss (a quadratic bowl) there is an exact limit: batch gradient descent converges only if η < 2 / λmax, where λmax is the largest curvature. Click the chart to set η.
When x is far from zero, slope and intercept are strongly coupled and the loss becomes a long, narrow valley: steep across, shallow along. The learning rate must be small enough for the steep direction, so progress along the valley is slow. Tick Standardise x in the controls to centre and rescale x and the valley turns into a round bowl. The ratio κ = λmax / λmin measures how elongated it is.
Batch gradient descent uses all 60 points for every step. Mini-batch SGD uses a random subset (batch size 1 is classic SGD): each step is cheaper and unbiased on average, but noisy. The noise shrinks as the batch grows. With a constant learning rate, SGD keeps bouncing around the minimum instead of settling exactly. Try batch size 1, then 60.
Same start, same learning rate, same amount of data seen. One epoch = one pass over all 60 points. Batch makes 1 update per epoch, mini-batch (10) makes 6, SGD makes 60. More updates per epoch means faster early progress, but the smaller the batch, the higher the noise floor. Change η in the controls above and watch the curves.
Real loss surfaces are rarely round bowls. Here three optimisers start from the same point on three test functions: plain gradient descent (amber), momentum with β = 0.9 (pink), and Adam (cyan). By default all three start with the same nominal learning rate, but each optimiser responds to it differently. This is a comparison at a shared setting, not a guarantee of equal tuning. Switch Learning rates to “Tuned per optimiser” to give each one a rate that is stable for the chosen function. Click the map to move the start.
Numbers in A to D come from the linear-regression playground and update live.
Here σ²g is the total variance of the per-point gradients (the trace of their covariance), b the batch size and n = 60.
Set η just above the stability limit 2/λmax and watch the loss grow.
Compare how many steps batch gradient descent needs with and without standardising x, using the best learning rate each time.
Batch size 1 versus 60 with the same learning rate: how close to the optimum does each get?