Foundations
Gradient descent and the loss landscape
Gradient-based optimization navigates a high-dimensional, batch-observed landscape whose local geometry governs useful step sizes.
Updated
1
Concept
Training defines a loss over the model’s parameter vector . If there are millions or billions of parameters, the graph of this function lives in an impossibly high-dimensional space. Calling it a loss landscape is useful as long as we remember that every familiar valley drawing is a two-dimensional slice, projection, or toy function.
Basic gradient descent computes and updates . The negative gradient is the steepest local descent direction under Euclidean distance, and learning rate sets the step. The direction is local: curvature makes the linear approximation less accurate as the step grows. Decreasing loss is therefore not guaranteed for an arbitrary learning rate.
Full-batch gradient descent averages loss over the complete training set before every update. That direction is exact for the finite dataset but expensive. Stochastic gradient descent uses one example. In modern practice, “SGD” often means a minibatch: enough examples for efficient matrix operations and a useful gradient estimate, but far fewer than the dataset. Sampling, shuffling, and distributed batch construction become part of the algorithm.
Minibatch gradients are noisy estimates of the dataset gradient. Larger batches reduce sampling variance but cost more per update and can change optimization and generalization behavior. Doubling batch size does not automatically justify doubling the learning rate across all regimes. Effective batch size also includes gradient accumulation and data-parallel workers. Comparisons should match examples processed, updates, and compute, not merely epochs.
Curvature explains difficult ravines. In a steep direction, a moderate step overshoots from wall to wall; in a shallow direction, the same step advances slowly. The Hessian describes local second derivatives, but forming it explicitly is infeasible at large scale. Momentum and adaptive optimizers approximate useful geometric behavior from gradient history without solving the full second-order problem.
A zero gradient is not enough to identify a solution. It can occur at a local minimum, maximum, saddle point, or flat plateau. High-dimensional neural landscapes contain many flat and saddle-like directions. Parameter symmetries also create equivalent solutions: permuting certain hidden units can leave the function unchanged. Comparing two parameter vectors by straight-line distance may therefore say little about their behaviors.
Training curves are more informative than a beautiful surface alone. Plot training and validation loss against both updates and tokens or examples processed. Watch gradient norms, learning rate, overflow events, and throughput. A jagged batch loss can coexist with a healthy downward trend; a smooth training curve can coexist with overfitting. Repeated seeds reveal whether an apparent improvement exceeds optimization variance.
The landscape metaphor becomes operational when tied to evidence. Gradient gives a local direction, learning rate chooses reach, minibatches provide noisy observations, and curvature determines stability. Optimization does not “understand” the task; it follows the scalar objective provided. A well-designed model and loss reshape the landscape so useful solutions are accessible, while evaluation determines whether descending training loss produced the behavior that actually matters.
When an experiment diverges, preserve the first bad step. Record the batch identity, loss scale, gradient norm, optimizer state, and parameter statistics immediately before and after it. The earliest non-finite value identifies the failing operation far better than the cascade of NaNs seen many updates later.
2
Explain it like I am five
A night hiker descends a mountain using a headlamp and a slope meter. The lamp reveals only nearby ground; a minibatch is one noisy reading, not the full mountain. The hiker steps opposite the measured uphill direction. Tiny steps waste the night, huge steps cross the valley, and a narrow ravine causes bouncing from wall to wall. Momentum and adaptive methods change the walking rule, but none supplies an aerial map of the destination.
3
Teach it back
Explain full-batch, stochastic, and minibatch gradient descent, plus learning rate, curvature, saddle points, and why a 2D loss plot is only a slice.
Minimum: 80 characters and 15 words. Your text stays only in this browser.
Saved only on this device.
Show a model answer
Full-batch descent differentiates average loss over all training examples; SGD uses one example, and minibatch methods use a sample, producing cheaper noisy gradient estimates. The learning rate scales each step. High curvature can make one rate overshoot steep directions while moving slowly in shallow ones. Zero gradient may indicate a minimum, maximum, or saddle. A network has millions of dimensions, so a 2D plot shows a chosen projection or slice, not the whole landscape.
4
Check your understanding
Complete the teach-back and answer the quiz correctly to finish this lesson.
Sources
- Herbert Robbins and Sutton Monro (1951). A Stochastic Approximation Method.