An unbiased estimate of a gradient nobody can afford
The true gradient is the average over every training example, so one exact step costs a full pass through the dataset.
- : a batch of examples drawn at random.
A batch gives an estimate that is correct on average and wrong on any particular step, which is the trade the method is named after.
A thousand noisy steps make far more progress than one exact step, because the loss surface does not require precision to descend.
The noise scales with the batch
Quadrupling the batch halves the gradient noise, and it quadruples the cost of a step. The returns are square root while the price is linear.
Because the noise falls with , the learning rate is usually scaled up with it. The linear scaling rule holds well up to a batch size in the thousands and breaks after that.
The noise is not purely a cost. It is also what lets SGD escape sharp minima, and models trained with very large batches generalise measurably worse for that reason.
Momentum, which is what is actually run
- : the decay, usually 0.9.
The update becomes a running average of past gradients rather than the latest one, which cancels the noise in directions that keep changing sign.
That average spans roughly ten gradients at , so momentum builds speed along a consistent slope and damps oscillation across a narrow valley.
Plain SGD without momentum is rarely the right choice, and almost no published result uses it.
One step, in order
- Draw a batch at random from the training set.
- Forward the batch and compute the loss.
- Backward to get the gradient of that batch.
- Update the velocity, then the parameters.
- Zero the gradients and take the next batch.
Why it still beats Adam on some problems
SGD applies one global learning rate, so a parameter with a small gradient takes a small step and the geometry of the loss is respected.
Adam rescales each parameter by its own gradient history, which converges faster and often lands in a sharper minimum.
On image models trained to convergence, SGD with momentum and a cosine schedule still produces the best test accuracy, and that result has survived a decade of attempts to overturn it.