Gradient Descent
Volume I, Chapter 2 — Part I. Derivation of gradient descent from the first-order Taylor expansion, convergence proofs for convex and strongly convex objectives, momentum, Adam, and learning rate schedules.
Prerequisites
Table of Contents
- Learning Objectives
- Prerequisites
- Notation
- Core Intuition
- First-Order Taylor Expansion
- The Steepest Descent Direction
- The Gradient Descent Update Rule
- Smoothness and the Sufficient Decrease Lemma
- Convergence for Convex Functions
- Strong Convexity and Linear Convergence
- Stochastic Gradient Descent
- Momentum and Nesterov Acceleration
- Adam: Adaptive Moment Estimation
- Learning Rate Schedules
- Connection to the Eigenbasis
- Common Pitfalls and Misconceptions
- Research Perspective
- Summary of Takeaways
- Exercises
Learning Objectives
After reading this chapter, you should be able to:
- Derive the gradient descent update from the first-order Taylor approximation and the Cauchy–Schwarz inequality.
- State the -smoothness condition and prove the sufficient decrease lemma.
- Prove convergence for convex objectives and linear convergence for strongly convex objectives.
- Derive SGD as an unbiased gradient estimator and state its variance properties.
- Derive momentum as an exponential moving average of gradients and explain its effect on ravines.
- Derive Adam including bias correction, and interpret per-parameter adaptive learning rates.
- Analyze gradient descent convergence in the eigenbasis of a quadratic objective.
Prerequisites
- Eigenvalues & Eigenvectors: eigendecomposition, condition number, gradient descent on quadratics.
- Positive Definite Matrices: convexity via the Hessian, quadratic forms.
- Vectors, Spans & Linear Independence: inner products, Cauchy–Schwarz inequality.
Notation
- — Objective function
- — Gradient vector
- — Hessian matrix
- — Learning rate (step size)
- — Parameter iterate at step
- — Hessian condition number
Core Intuition
Training a machine learning model means finding parameters that minimize a loss function . For differentiable , the gradient points in the direction of steepest increase. Moving in the opposite direction — gradient descent — is the locally optimal first-order strategy for decreasing the loss.
This chapter derives gradient descent from the Taylor expansion, proves convergence under smoothness and convexity, and extends the basic algorithm to stochastic variants (SGD), momentum, and Adam. The condition number of the Hessian — developed in Eigenvalues & Eigenvectors — governs how difficult the optimization landscape is for first-order methods.
Series context. This opens Chapter 2 (Calculus & Optimization) in Volume I. It connects to Linear Regression in Volume II and Backpropagation in Volume II, Part III.
Gradient Descent Playground
Loss: $f(x, y) = x^2 + 4y^2 + 0.5\sin(3x)\cos(3y)$
Steps: 0
Click anywhere on the surface to set the starting point, then press Run.
First-Order Taylor Expansion
Definition 1. A function is differentiable at if there exists such that
The first-order Taylor approximation (linearization) is:
This approximation is accurate for small and captures the local linear behavior of .
Multivariate chain rule preview. When depends on parameters through a computational graph, is computed via backpropagation (Chapter 8). Here we treat as given.
The Steepest Descent Direction
Problem. Find with that minimizes the linear approximation:
Since is constant in , this minimizes .
Theorem 1 (Steepest Descent Direction). The unit vector minimizing is
Proof. By the Cauchy–Schwarz inequality:
with equality when .
Important equation. Equation (4) proves that the negative gradient is the direction of steepest descent — the geometric foundation of all first-order optimization.
The Gradient Descent Update Rule
Rescaling the step size, define the learning rate and the gradient descent update:
At each iteration:
- Compute the gradient .
- Update parameters in the negative gradient direction: .
- Repeat until a stopping criterion is met (e.g., or fixed iteration budget).
Visual description. Imagine standing on a hilly surface (the loss landscape). The gradient points uphill along the steepest slope. Taking a step downhill (opposite to the gradient) decreases elevation locally. Repeating this process traces a path toward a valley (local minimum), though the path may zigzag in narrow ravines.
Smoothness and the Sufficient Decrease Lemma
Definition 2 (-Smoothness). has -Lipschitz continuous gradients (is -smooth) if
Lemma 1 (Quadratic Upper Bound). If is -smooth, then for all :
Proof. Integrate the gradient along the line from to and bound using (7).
Theorem 2 (Sufficient Decrease). Under -smoothness, gradient descent with step size satisfies
Proof. Apply (8) with :
Descent condition. The factor requires .
Optimal fixed step size. Maximizing the guaranteed decrease per step:
Substituting into (9):
Important equation. Equation (12) guarantees progress proportional to the squared gradient norm. When , progress slows — characteristic of convergence to a stationary point.
Convergence for Convex Functions
Definition 3 (Convexity). is convex if for all and :
Equivalently (first-order condition): .
Theorem 3 ( Convergence). If is convex and -smooth, gradient descent with satisfies
where .
Proof sketch. Define the Lyapunov function . Using convexity and smoothness:
Telescoping over and using gives (14).
Interpretation. Halving the optimality gap requires doubling the iteration count — sublinear convergence.
Strong Convexity and Linear Convergence
Definition 4 (Strong Convexity). is -strongly convex if
Equivalently, when twice differentiable.
Theorem 4 (Linear Convergence). If is -strongly convex and -smooth, gradient descent with satisfies
Proof sketch. Strong convexity gives . Apply to the function value gap via smoothness.
The ratio is the condition number. Large means slow convergence — the loss landscape is a long narrow valley. This connects directly to the eigenvalue analysis in Eigenvalues & Eigenvectors.
Stochastic Gradient Descent
For empirical risk , computing requires all samples.
Definition 5 (Mini-batch SGD). Given a mini-batch :
Proposition 1 (Unbiasedness). The mini-batch gradient is an unbiased estimator of the full gradient:
Proposition 2 (Variance). If samples are i.i.d. and batch size is ,
Variance decreases linearly with batch size, trading compute for gradient stability.
Convergence requirement. For SGD to converge, the learning rate must satisfy and (Robbins–Monro conditions), typically .
Momentum and Nesterov Acceleration
Problem. In ravines (elongated level sets), gradient descent oscillates across the narrow direction while making slow progress along the valley.
Polyak Momentum. Maintain a velocity vector:
where (typically ).
Derivation as exponential moving average. Unrolling (21):
Recent gradients receive weight ; gradients from steps ago receive weight . The effective memory window is steps.
Effect. Consistent gradient directions accumulate (acceleration along the valley); oscillating directions partially cancel (damping across the ravine).
Nesterov Accelerated Gradient (NAG). Look ahead before computing the gradient:
For convex -smooth functions, NAG achieves convergence — optimal among first-order methods.
Adam: Adaptive Moment Estimation
Adam (Kingma & Ba, 2015) combines momentum with per-parameter adaptive learning rates.
Step 1 — Gradient:
Step 2 — First moment (momentum):
Step 3 — Second moment (squared gradient EMA):
where denotes element-wise squaring.
Step 4 — Bias correction. Since , early estimates are biased toward zero:
Derivation of bias correction. Taking expectations (assuming stationary ):
Dividing by yields an unbiased first-moment estimate.
Step 5 — Parameter update:
Interpretation. The denominator per parameter. Dividing by it normalizes step sizes — parameters with large historical gradients receive smaller steps. This is diagonal preconditioning that adapts to local curvature estimates.
Default hyperparameters: , , , .
Learning Rate Schedules
Fixed learning rates may be too large near convergence (oscillation) or too small early (slow progress). Schedules modulate over training.
Step decay:
where and is the period.
Cosine annealing:
Warmup. Linear increase from 0 to over the first steps:
Warmup stabilizes early training for large models where initial gradients may be large and Adam's bias correction is active.
Visual description. Learning rate schedules modulate step size over time: warmup gently ramps up to avoid early instability; step decay or cosine annealing gradually shrink steps for fine-grained convergence near the minimum.
Connection to the Eigenbasis
For quadratic with , write . In coordinates :
Each eigen-direction decouples with contraction rate .
Optimal step size: .
Convergence rate:
Adam and other adaptive methods attempt to reduce effective by per-coordinate scaling — approximating Newton's method, which uses the full Hessian for optimal preconditioning.
Common Pitfalls and Misconceptions
Pitfall 1: Using . The sufficient decrease lemma fails; gradient descent may diverge.
Pitfall 2: Expecting global convergence for non-convex . GD converges to stationary points (), which may be saddles or local maxima, not global minima.
Pitfall 3: Ignoring batch size effects in SGD. Small batches add noise (regularization benefit) but require smaller learning rates or warmup.
Pitfall 4: Treating Adam as always superior to SGD. For some tasks (especially with careful tuning), SGD with momentum matches or exceeds Adam. Adam's adaptive rates can generalize differently.
Pitfall 5: Confusing learning rate with momentum. Momentum () controls velocity accumulation; learning rate () controls step magnitude. Both affect convergence but serve different roles.
Research Perspective
Gradient descent dates to Cauchy (1847) and was systematized in convex optimization by Nesterov (1983), who proved the optimal rate for accelerated methods. Stochastic approximation (Robbins & Monro, 1951) laid foundations for SGD.
In deep learning, SGD with momentum dominated until Adam (2015) became the default for transformer pretraining. Recent research revisits SGD with careful learning rate schedules (large-batch training, warmup-decay) and questions whether adaptive methods' generalization properties match their optimization speed.
Gradient flow (continuous-time limit ) connects to neural tangent kernel theory and Bayesian inference — developed in the RBC Borealis series on machine learning from multiple viewpoints. Second-order methods (natural gradient, K-FAC) use curvature information beyond diagonal Adam approximations.
Summary of Takeaways
- Steepest descent — — Negative gradient is optimal direction
- GD update — — Basic optimization step
- Descent condition — — Step size bound for smooth
- Optimal fixed rate — — Maximizes guaranteed decrease
- Convex rate — — Sublinear convergence
- Strongly convex rate — — Linear convergence,
- SGD — Unbiased mini-batch gradient — Scalable to large data
- Momentum — EMA of past gradients — Ravine acceleration
- Adam — Per-parameter adaptive rates — Diagonal preconditioning
Next article: Bayes' Theorem — Chapter 3: probability foundations for statistical learning.
Exercises
Exercise 1. Prove Lemma 1 (quadratic upper bound) from -smoothness by integrating from to .
Exercise 2. For with , find the optimal learning rate and the convergence rate per iteration.
Exercise 3. Derive equation (28) for the bias in Adam's first moment estimate.
Exercise 4 (SGD). Show that with batch size and learning rate , the Robbins–Monro conditions for convergence are satisfied.
Exercise 5 (NAG). Explain intuitively why evaluating the gradient at (look-ahead) improves over standard momentum in ravines.
Exercise 6 (Convexity). Prove that is convex and compute its gradient and Hessian. When is it strongly convex?
Exercise 7 (Conceptual). Compare the per-iteration cost and convergence rate of gradient descent with exact line search versus fixed for a quadratic objective.