“What does gradient descent do, and why might training fail?”
Gradient descent changes model parameters to reduce an objective. The gradient points toward the steepest local increase under the usual Euclidean geometry, so a basic update moves in the opposite direction.
01. Read the update rule
The learning rate controls the step size. A small step can make training slow; a large step can overshoot, oscillate, or diverge. A gradient is local information, not a map of the entire loss surface.
For a differentiable convex objective, suitable optimization conditions can support convergence to a global optimum. General neural-network objectives are nonconvex; the same guarantee should not be claimed without additional assumptions.
02. Calculate one step
Take the toy loss L(w) = (w − 3)². Its derivative is 2(w − 3). At w = 0, the gradient is −6.
| Learning rate | New w | New loss |
|---|---|---|
| 0.1 | 0.6 | 5.76 |
| 0.5 | 3 | 0 |
| 1.1 | 6.6 | 12.96 |
The initial loss was 9. The final row made it worse. The exact optimum at rate 0.5 is a special property of this quadratic, not a universal setting.
03. Distinguish batches, steps, and epochs
Full-batch gradient descent uses all training examples for an update. Stochastic training uses small samples; mini-batches trade computation efficiency against noisy gradient estimates. One epoch is a pass through the training set, while one step is one parameter update.
With 1,024 examples and batches of 128, a complete epoch contains eight updates if all examples are used exactly once. Changing batch size changes both update frequency and gradient statistics, so comparisons should state their training budget.
Momentum accumulates a moving direction from previous gradients. Adaptive optimizers also adjust updates using gradient statistics. They do not eliminate the need to check learning rate, numerical stability, and generalization.
04. Debug the training process
- Verify labels, loss implementation, and tensor shapes. Try fitting a tiny clean subset.
- Inspect feature scales, gradient magnitudes, and invalid values. Compare against a simple model.
- If loss explodes, test a lower learning rate and investigate unstable operations. Gradient clipping bounds updates but does not repair a bad objective.
- If training improves while validation worsens, investigate overfitting and early stopping.
Compare repeated runs where randomness matters. A single noisy batch does not establish a trend, and a flat training curve can indicate an implementation problem rather than insufficient model capacity.
05. Explain the practical trade-off
“Will more epochs always help?”
No. Optimization can plateau, and continued fitting can damage generalization. Monitor the selected validation criterion and restore the chosen checkpoint.
Calculate the gradient and one update for a toy objective. Then explain why reducing training loss is only one part of building a useful model.
Sources & further reading
Google Developers: gradient descent. The quadratic and batch-count examples are illustrative.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.