Before this lesson:lesson 01 (the
gradient descent update and the 1D factor 1−ηλ),lesson 02(L-smoothness, strong convexity,
the descent lemma, the PL inequality and κ=L/μ), and
linear algebra 06 (a symmetric matrix has an
orthonormal basis of eigenvectors).
Time: about 70 minutes, plus the notebook.
Every optimizer you use is gradient descent plus something: SGD adds noise, momentum adds memory,
Adam adds a per-coordinate scale. The theory of plain gradient descent answers three practical
questions. How large can the learning rate be before training diverges? (η<2/λmax.)
How many steps are needed? (About κlog(1/ε) for strongly convex problems, about
1/ε for convex ones.) How do we choose the step without knowing L? (A line search.
It is standard in full-batch problems such as scientific fits, scipy.optimize.minimize and
L-BFGS. In stochastic deep learning, a hand-tuned schedule replaces it; see
lesson 07.)
Notation for the whole lesson: x⋆ is a minimizer, f⋆=f(x⋆), and
ek=xk−x⋆ is the error after k steps.
One dimension (lesson 01). For f(x)=2λx2, one step gives
xk+1=xk−ηλxk=(1−ηλ)xk. So xk=(1−ηλ)kx0. The
error shrinks exactly when ∣1−ηλ∣<1, that is, when 0<η<2/λ.
Two dimensions. Take f(x)=21x⊤Ax with a symmetric positive definite A. Write
its eigenvalues as μ=λ1≤λ2=L, with orthonormal eigenvectors q1 (the
flat direction) and q2 (the steep direction). Write the error in this basis:
ek=c1,kq1+c2,kq2. The gradient is Aek=λ1c1,kq1+λ2c2,kq2, so
one step gives
c1,k+1=(1−ημ)c1,k,c2,k+1=(1−ηL)c2,k.
The two components do not interact. Each one is a 1D problem from lesson 01, with its own factor.
Interactive figure: loading…
Press Play, then try the three presets (the slider η⋅L/2 is the step in units of 2/L). The contours belong to f=21x⊤Ax with
μ=1 and L=κ; the dashed lines are the eigen-directions q1
(flat) and q2 (steep). The blue path is
gradient descent. The bars show the two error components with their sign. With η=1/L the
steep component dies in one step, and the flat one shrinks by only 1−1/κ per step. With
η=0.97⋅2/L the steep component flips sign at every step (zig-zag). On the log chart,
the blue curve ∥ek∥ always ends up parallel to the slower dashed line.
One step size for all directions. The total error shrinks only as fast as the slowest component.
So the factor per step is the larger of the two:
ρ(η)=max(∣1−ημ∣,∣1−ηL∣).
Plot both terms against η: each is a V shape. ∣1−ημ∣ has its tip at η=1/μ,
and ∣1−ηL∣ has its tip at η=1/L. A small η makes the flat factor close to 1
(slow). A large η makes the steep factor larger than 1 (divergence). The best compromise is where
the two V's cross.
Interactive figure: loading…
Drag on the chart to move the step size η (or use the slider η⋅L/2, the step in units of 2/L). The aqua V is
∣1−ημ∣, the magenta V is ∣1−ηL∣, and the thick dark curve is
their maximum ρ(η). Above the dashed line ρ=1 there is no convergence: this starts at
the yellow line 2/L. The lowest point of the thick curve is the best step
η⋆=2/(μ+L). Change μ and L: the best factor depends only on κ=L/μ.
From a factor to a number of steps. If ∥ek∥≤ρk∥e0∥, then ∥ek∥≤ε∥e0∥
as soon as ρk≤ε, that is, after
k≥ln(1/ρ)ln(1/ε) steps.
For ρ=0.9 and ε=10−6 this is 13.8/0.105≈131 steps. For ρ close to 1,
ln(1/ρ)≈1−ρ, so the number of steps is about ln(1/ε)/(1−ρ).
Quick check
f is a quadratic with κ=L/μ=100. With the best fixed step 2/(μ+L), about how many steps reduce ∥ek∥ by a factor 106?
Why.
The factor is (κ−1)/(κ+1)=99/101, and ln(106)/ln(101/99)≈690.8, so 691 steps. In short: 1−ρ≈2/κ, so about 2κln(106)≈50⋅13.8. "About 70" is the order of magnitude for momentum (lesson 04), which scales with κ=10 instead of κ.
Quick check
A quadratic has μ=1 and L=10. You choose η=1/μ=1, the step that solves the flat direction in one step. What happens?
Why.
The flat factor is 1−1⋅1=0, but the steep factor is 1−1⋅10=−9. Any error along q2 grows like 9k and flips sign. The stability limit is η<2/L=0.2, set by the steep direction, not by the flat one.
Throughout this section μ and L are the strong convexity and smoothness constants of
lesson 02, and κ=L/μ. For a
quadratic with Hessian A, they are μ=λmin(A) and L=λmax(A).
A sequence of errors converges linearly with factor ρ<1 if it is bounded by Cρk. On a
log scale this is a straight line going down. Every digit of accuracy costs the same number of steps,
ln10/ln(1/ρ). A sequence converges sublinearly if it goes to zero more slowly than every
Cρk, for example like C/k. On a log scale the curve bends and flattens: with C/k, each new digit
costs ten times more steps than the one before.
Let f(x)=21x⊤Ax−b⊤x with A symmetric and all eigenvalues in [μ,L],μ>0. Gradient descent with a fixed step η satisfies ∥ek∥≤ρ(η)k∥e0∥ with
ρ(η)=max(∣1−ημ∣,∣1−ηL∣).
It converges from every x0 if and only if 0<η<2/λmax(A). The best fixed step is
η⋆=2/(μ+L), with factor ρ⋆=(κ−1)/(κ+1). The step 1/L gives
ρ=1−1/κ.
Proof.
The minimizer solves Ax⋆=b. So ∇f(xk)=Axk−b=A(xk−x⋆)=Aek, and
ek+1=ek−ηAek=(I−ηA)ek.
Write A=QΛQ⊤ with orthonormal eigenvectors qi and eigenvalues λi. The
component of the error along qi is multiplied by 1−ηλi at every step. Because the
qi are orthonormal, ∥ek∥2=∑i(1−ηλi)2kci,02≤maxi∣1−ηλi∣2k∥e0∥2.
Equality holds when e0 lies along the worst qi.
∣1−ηλ∣ is a convex function of λ (a V shape), so its maximum over
[μ,L] is at an end point. This gives ρ(η).
Every component goes to zero for every start exactly when ∣1−ηλi∣<1, that is,
0<ηλi<2, for all i. The strictest of these conditions is the one for λmax.
For η≤1/L,ρ=1−ημ, which decreases with η. For η≥1/μ,ρ=ηL−1, which increases. In between, ρ is the larger of the decreasing 1−ημ
and the increasing ηL−1. It is smallest where they are equal: 1−ημ=ηL−1
gives η=2/(μ+L) and ρ=(L−μ)/(L+μ)=(κ−1)/(κ+1).
For η=1/L:ρ=max(1−μ/L,0)=1−1/κ.■
Iteration counts. For large κ,lnκ−1κ+1≈2/κ. So the best step
needs about 2κln(1/ε) steps, and the step 1/L about κln(1/ε).
Both are O(κlog(1/ε)).
κ
best step: ⌈ln106/lnκ−1κ+1⌉
step 1/L:⌈ln106/lnκ−1κ⌉
10
69
132
100
691
1,375
1,000
6,908
13,809
The function value converges twice as fast in the exponent:
f(xk)−f⋆=21ek⊤Aek=21∑iλi(1−ηλi)2kci,02, so it
decays like ρ2k.
Does the rate depend on the dimension? No. Theorem 1 uses only the two extreme eigenvalues. A
quadratic with a million variables and κ=10 needs the same 69 steps for a factor 106 as a 2D
one (each step costs more, of course).
Beyond quadratics. For any L-smooth, μ-strongly convex f, the step 2/(μ+L) still gives
∥ek∥≤(κ+1κ−1)k∥e0∥ (Nesterov, Lectures on Convex Optimization,
Thm 2.1.15; Bubeck, Thm 3.12). The quadratic shows that no fixed step does better on the whole
class. Near a minimizer of a smooth f, gradient descent behaves like gradient descent on the
quadratic model with A=∇2f(x⋆). So local convergence needs
η<2/λmax(∇2f(x⋆)).
Quick check
Problem P has 106 variables and Hessian eigenvalues in [1,10]. Problem Q has 2 variables and eigenvalues 1 and 100. Both are quadratics and use their best fixed step. Which needs more steps to reduce ∥ek∥ by 106?
Why.
The bound of Theorem 1 depends only on κ: P has κ=10 (69 steps), Q has κ=100 (691 steps). The dimension changes the cost of one step, not the number of steps.
Let f be L-smooth and μ-strongly convex. Gradient descent with η=1/L satisfies
f(xk)−f⋆≤(1−Lμ)k(f(x0)−f⋆).
Proof.
The descent lemma of lesson 02 with y=x−L1∇f(x) gives
f(y)≤f(x)−L1∥∇f(x)∥2+2L⋅L21∥∇f(x)∥2. So one step decreases f by at least
∥∇f(xk)∥2/(2L):f(xk+1)≤f(xk)−2L1∥∇f(xk)∥2.
Strong convexity implies the PL inequality (lesson 02): ∥∇f(xk)∥2≥2μ(f(xk)−f⋆).
Put step 2 into step 1 and subtract f⋆:f(xk+1)−f⋆≤(1−μ/L)(f(xk)−f⋆).
Apply step 3 k times. ■
Since (1−1/κ)k≤e−k/κ, after k≥κln((f(x0)−f⋆)/ε) steps we have
f(xk)−f⋆≤ε. The proof uses only the descent lemma and PL. So it also holds for
nonconvex functions that satisfy the PL inequality (Garrigos and Gower, Thm 3.9).
Theorem 3 (the O(1/k) rate for convex functions) #
Without strong convexity (μ=0) the linear rate disappears. Look at a 2D example first.
Example.f(x)=21(x12+μx22) with a small μ>0, so L=1. Use η=1 and
x0=(1,1). The first coordinate is solved in one step. The second one is (1−μ)k. So
f(xk)=2μ(1−μ)2k for k≥1. As μ→0 the factor 1−μ goes to 1: no linear
rate holds for all μ at once. But the gap stays small. At k=100 the worst μ is about 1/201,
with gap 9.2×10−4. This is below the bound of the theorem below, L∥x0−x⋆∥2/(2k)=2/200=0.01.
At the same time x100,2≈0.61: the iterate is still far from x⋆=0. Without strong
convexity, f(xk) converges like 1/k, but xk itself can converge very slowly.
Theorem 3. Let f be convex and L-smooth with a minimizer x⋆. Gradient descent with
η=1/L satisfies
f(xk)−f⋆≤2kL∥x0−x⋆∥2.
Why this is true. Each step decreases f (descent lemma). Convexity says: if f(x) is far above
f⋆, then the gradient points well toward x⋆, so the step brings x closer to x⋆.
The squared distance to x⋆ can only shrink a limited total amount, ∥x0−x⋆∥2. So the
sum of all gaps is bounded, and the last gap is at most the average.
Proof of Theorem 3 (5 steps)
Write x+=x−L1∇f(x) for one step from x, and g=∇f(x).
Descent lemma (step 1 of Theorem 2): f(x+)≤f(x)−2L1∥g∥2.
First-order condition of convexity (lesson 02), from x toward x⋆:f⋆≥f(x)+g⊤(x⋆−x), so f(x)≤f⋆+g⊤(x−x⋆).
Add the two inequalities and complete the square:
f(x+)−f⋆≤g⊤(x−x⋆)−2L1∥g∥2=2L(∥x−x⋆∥2−∥x+−x⋆∥2).
(Expand ∥x+−x⋆∥2=∥x−x⋆∥2−L2g⊤(x−x⋆)+L21∥g∥2 to check the equality.)
4. Apply step 3 to the steps xi→xi+1 for i=0,…,k−1 and add them. The right side
telescopes (each middle term appears once with + and once with −):
By step 1, f(xi) never increases. So the last gap is at most the average of the k gaps:
f(xk)−f⋆≤k1∑i=1k(f(xi)−f⋆)≤2kL∥x0−x⋆∥2.■
So accuracy ε needs O(L∥x0−x⋆∥2/ε) steps. This is not the best possible. For
every method that moves only along the gradients it has seen, and every k≤(n−1)/2, there are
L-smooth convex functions on Rn with f(xk)−f⋆≥3L∥x0−x⋆∥2/(32(k+1)2)
(Nesterov's lower bound; Bubeck, Thm 3.14). Accelerated methods reach this O(1/k2) rate:
lesson 04.
Line search: choosing the step along a direction #
Fix a point x and a descent directiond, that is, a direction with ∇f(x)⊤d<0 (for
gradient descent, d=−∇f(x)). Look at f only along the ray from x:
φ(α)=f(x+αd).
Its slope is φ′(α)=∇f(x+αd)⊤d, and φ′(0)=∇f(x)⊤d<0.
A line search chooses the step lengthα>0. We use α for this step and keep η
for a fixed step. A good step is not too long (the value must drop enough) and not too short (the slope
must have become flatter). The Armijo and Wolfe conditions make these two words precise.
Armijo condition (sufficient decrease). With a constant 0<c1<1:
φ(α)≤φ(0)+c1αφ′(0).
The right side is the tangent line at 0, with its slope made less steep by the factor c1. Near
α=0 the curve lies below this line (because c1<1). Steps that are too long go above it.
Backtracking. Choose α0>0 and a shrink factor 0<τ<1 (often τ=1/2). Try
α0,τα0,τ2α0,… and accept the first trial that satisfies Armijo.
Interactive figure: loading…
Press Next trial to run backtracking one trial at a time. The black curve is φ(α), the
grey dashed line is the tangent at 0, and the yellow line is the Armijo line.
The violet circles are the trials α0,τα0,…; the filled
one is accepted. The bands below show where Armijo holds, where the curvature condition holds, and
where both hold (the Wolfe set); c2 is the curvature constant defined below. Try the wavy slice: the Wolfe set has several pieces. Move c1 toward
0.5 and see the Armijo set shrink.
On a quadratic first. Along d=−g with g=∇f(x), a quadratic gives
φ(α)=f(x)−αg⊤g+2α2g⊤Ag. Armijo asks
−αg⊤g+2α2g⊤Ag≤−c1αg⊤g. Divide by α>0:
it holds exactly when
α≤2(1−c1)g⊤Agg⊤g=2(1−c1)α⋆,
where α⋆=g⊤g/g⊤Ag is the exact line search step (the minimizer of φ).
Since g⊤Ag≤Lg⊤g, every α≤2(1−c1)/L passes.
Theorem 4 (backtracking stops, with a step that is not too short) #
Let f be L-smooth, d=−∇f(x)=0,α0>0,τ∈(0,1) and c1∈(0,1).
Backtracking stops after finitely many trials, and the accepted step satisfies
α≥min(α0,2τ(1−c1)/L).
Proof.
Descent lemma with y=x−α∇f(x):f(x−α∇f)≤f(x)−α(1−Lα/2)∥∇f∥2.
Armijo asks f(x−α∇f)≤f(x)−c1α∥∇f∥2. By step 1 this holds when
1−Lα/2≥c1, that is, for every α≤2(1−c1)/L.
The trials α0τj go to 0. So after finitely many trials one is below 2(1−c1)/L, and the
search stops there or earlier.
If the accepted α is not α0, the trial before it, α/τ, failed. By step 2 it was
larger than 2(1−c1)/L. So α>2τ(1−c1)/L. Either way,
α≥min(α0,2τ(1−c1)/L).■
Consequence. Each accepted step decreases f by at least c1αmin∥∇f∥2, with
αmin=min(α0,2τ(1−c1)/L), and we never needed to know L. With PL this gives the
factor 1−2μc1αmin per step, a linear rate like Theorem 2. Where f is flatter, the search
accepts longer steps.
Armijo alone accepts tiny steps: every small enough α passes. The curvature condition rules
them out. With a second constant c2:
weak Wolfe curvature condition:φ′(α)≥c2φ′(0). The slope has risen from
φ′(0)<0 to at least c2φ′(0), so the step went far enough to flatten the descent.
strong Wolfe curvature condition:∣φ′(α)∣≤c2∣φ′(0)∣. Also, the slope may
not be large and positive: the step may not overshoot far onto the other side of the valley.
The (weak or strong) Wolfe conditions are Armijo plus one of these, with 0<c1<c2<1. The
order c1<c2 guarantees that such steps exist when f is smooth and bounded below along the ray
(Nocedal and Wright, Lemma 3.1). Usual values (Nocedal and Wright, §3.1): c1=10−4;c2=0.9 for Newton and quasi-Newton methods, c2=0.1 for nonlinear conjugate gradient.
scipy.optimize.line_search and PyTorch's LBFGS(line_search_fn="strong_wolfe") use c1=10−4
and c2=0.9.
Quick check
A line search accepts the step α=10−9 on a problem where α≈0.1 would be good. Which condition would have rejected this step?
Why.
For a tiny α,φ′(α)≈φ′(0), which is more negative than c2φ′(0) (since c2<1). So the curvature condition fails. Armijo cannot help: near 0 the curve is always below the Armijo line, so tiny steps always pass it, whatever c1<1 is.
Let dk be a descent direction at xk and xk+1=xk+αkdk with αk>0 satisfying
the weak curvature condition with c2<1. Then sk=xk+1−xk and
yk=∇f(xk+1)−∇f(xk) satisfy yk⊤sk>0.
Proof.
sk=αkdk, so yk⊤sk=αk(∇f(xk+1)⊤dk−∇f(xk)⊤dk).
The curvature condition says ∇f(xk+1)⊤dk≥c2∇f(xk)⊤dk.
So yk⊤sk≥αk(c2−1)∇f(xk)⊤dk>0, because c2−1<0 and
∇f(xk)⊤dk<0.■
Why quasi-Newton methods need it. BFGS (lesson 10)
builds a matrix Bk+1≈∇2f that satisfies the secant equation Bk+1sk=yk. If
Bk+1 is positive definite, then sk⊤yk=sk⊤Bk+1sk>0. So positive curvature along the step
is necessary, and the BFGS update keeps its matrix positive definite exactly when y⊤s>0. Then
the next direction −Bk+1−1∇f is a descent direction. For strictly convex f,y⊤s>0 holds
for every step. For nonconvex f, Armijo alone does not guarantee it; the curvature condition does.
The Rosenbrock function f(x,y)=(1−x)2+100(y−x2)2 has its minimizer at (1,1), at the end
of a long, curved, narrow valley. At the minimizer the Hessian eigenvalues are about 1001.6 and 0.399
(κ≈2508). So a fixed step must be below 2/1001.6≈0.0019968 to converge to (1,1).
Interactive figure: loading…
Compare the fixed step (blue) with Armijo backtracking
(violet, dashed), both started at (−1.2,1). Try the three presets for η. With
η=0.0021, just above 2/λmax at the minimizer, the fixed step never settles: it stays
near the minimizer and bounces across the valley. Look at the long violet jump: with α0=1,
backtracking sometimes accepts a long step across the bend of the valley, because it lowers f enough.
Then switch α0 to "2 × last step" and compare the number of function evaluations.
From (−1.2,1), counting steps until f(xk)≤10−10 (checked in the notebook):
Method
Steps
Function evaluations
fixed η=0.001
26,593
(none needed)
fixed η=0.0019
13,966
(none needed)
fixed η=0.0021
does not converge
backtracking, α0=1,τ=0.5,c1=10−4
10,616
105,522
backtracking, α0=2× last step
11,966
23,940
Backtracking found a step close to the best fixed step without knowing L: most accepted steps are
2−9≈0.00195. But it does not remove the ill-conditioning. It still needs about ten thousand
steps, because the problem has κ≈2508. Starting each search from the last step
(warm start) cuts the cost from about 10 to about 2 function evaluations per step.
Answers to section 1. (1) About 350. Here κ=50, the best factor is 49/51≈0.961, and
ln(106)/ln(51/49)≈345.3, so 346 steps. The step 1/L needs 684 by the same formula.
(2) It fails. With η=2.1/L the factor on x2 is ∣1−2.1∣=1.1, so that error grows like 1.1k.
There is a hard wall at 2/L, not a gradual slowdown.
f(x)=21x⊤Ax with A=(5335), so x⋆=0 and f⋆=0.
The eigenvalues are μ=2 with q1=(1,−1)/2 and L=8 with q2=(1,1)/2. So κ=4.
(a) Three step sizes. Steps to shrink ∥ek∥ by 106:⌈ln(106)/ln(1/ρ)⌉.
Step η
factor on q1:∣1−2η∣
factor on q2:∣1−8η∣
ρ
steps
1/L=0.125
0.75
0
0.75
⌈48.02⌉=49
2/(μ+L)=0.2
0.6
0.6
0.6=(κ−1)/(κ+1)
⌈27.05⌉=28
0.26>2/L=0.25
0.48
1.08
1.08
diverges
(b) Iterates with η=0.2 from x0=(1,0).∇f(x0)=Ax0=(5,3), so
x1=(1,0)−0.2(5,3)=(0,−0.6). Then ∇f(x1)=(−1.8,−3) and
x2=(0,−0.6)−0.2(−1.8,−3)=(0.36,0). In the same way x3=(0,−0.216). Why so regular? Since
x0=(q1+q2)/2, we get xk=0.6k(q1+(−1)kq2)/2: the norm shrinks by exactly 0.6
per step, and the q2 component flips sign at every step.
(c) Theorem 2 with η=1/L.f(x0)=21⋅5=2.5. After one step only the q1 component is
left, and f(xk)=0.5⋅0.5625k for k≥1: 0.281, 0.158, 0.089, … The bound 2.5⋅0.75k
gives 1.875, 1.406, 1.055, … It holds, but it is loose: on a quadratic the gap decays like
ρ2=0.5625 per step, while the general bound has 1−μ/L=0.75.
(d) Backtracking from x0=(1,0) with α0=1,τ=0.5,c1=10−4. Here g=(5,3),g⊤g=34 and g⊤Ag=260. So φ(α)=2.5−34α+130α2, and the Armijo line is
2.5−10−4⋅34α=2.5−0.0034α.
α
φ(α)
Armijo line
accepted?
φ′(α)=−34+260α
1
98.5
2.4966
no
226
0.5
18
2.4983
no
96
0.25
2.125
2.49915
yes (first pass)
31
0.125
0.28125
2.49958
(would pass too)
−1.5
Backtracking accepts α=0.25=2/L. This is allowed: Armijo holds for every
α≤2(1−c1)α⋆≈0.2615, where α⋆=34/260≈0.1308 is the exact step.
Theorem 4 guarantees only α≥min(1,2⋅0.5⋅0.9999/8)≈0.125. One step of length 2/L is
fine; the limit 2/L is about a fixed step repeated forever.
(e) Wolfe at α=0.25 with c2=0.9 and φ′(0)=−34. Weak: 31≥0.9⋅(−34)=−30.6 holds.
Strong: ∣31∣≤0.9⋅34=30.6 fails, just barely: the step overshoots the minimum of φ onto a
steep upward slope. At α=0.125,∣−1.5∣≤30.6, so strong Wolfe holds there.
scipy.optimize.line_search (strong Wolfe) returns α=0.1308=α⋆ here.
(f) The curvature pair of the step 0.25.s=x1−x0=−0.25(5,3)=(−1.25,−0.75),y=As=(−8.5,−7.5), and y⊤s=10.625+5.625=16.25>0. On a strictly convex quadratic,
y⊤s=s⊤As>0 for every step. The curvature condition matters for nonconvex f.
Quick check
In (d), you change only α0 from 1 to 0.3. Which step does backtracking accept now?
Why.
Armijo holds exactly for α≤2(1−c1)α⋆≈0.2615. The first trial 0.3 is above this, so it fails. The second trial 0.5⋅0.3=0.15 passes and is accepted. Backtracking never computes the exact step; it accepts the first trial that passes.
Learning rates in deep learning.η<2/λmax is why a learning rate that is too large
makes the loss explode within a few steps. In full-batch training of neural networks, the largest
Hessian eigenvalue (the sharpness) rises until it hovers near 2/η: the edge of stability
(Cohen et al. 2021; lesson 11).
Preconditioning beats tuning. Making κ ten times smaller saves about a factor 10 in steps,
however well the step is tuned. This is the reason for feature scaling (lesson 02), Adam
(lesson 06) and matrix preconditioners
(lesson 12).
Full-batch problems in science. With exact gradients (inverse problems, PDE-constrained fits,
the L-BFGS phase after Adam in physics-informed neural networks), quasi-Newton methods with a Wolfe
line search are the default: scipy.optimize.minimize(method="L-BFGS-B") or
torch.optim.LBFGS(line_search_fn="strong_wolfe"). There is no learning rate to tune. For a
discretized 1D Laplacian on N grid points, κ grows like N2, so plain gradient descent
needs O(N2) steps.
Why not in stochastic deep learning? Armijo compares function values. With minibatch noise
these values are noisy, and each trial costs a forward pass. Stochastic line searches exist for
models that interpolate the data (Vaswani et al., NeurIPS 2019), but learning-rate schedules are the
standard.
"1/L is the best step." It maximizes the guaranteed decrease of the descent lemma. On
quadratics 2/(μ+L) is better, and every η<2/L converges.
Mixing the two rates. On a quadratic, ∥xk−x⋆∥ decays like ρk and f(xk)−f⋆ like
ρ2k. And ρ=(κ−1)/(κ+1)≈1−2/κ means about
2κln(1/ε) steps, not ln(1/ε).
Reading the O(1/k) bound as convergence of xk. It bounds f(xk)−f⋆ only. The iterate
can still be far from x⋆.
Choosing the step from the flat direction.η=1/μ solves the flat direction and blows up
the steep one. The steep direction sets the limit.
A large c1. It rejects good steps; use c1=10−4. Newton-type methods also need
c1<1/2, so that the full step α=1 is accepted near the minimizer.
Weak Wolfe for nonlinear conjugate gradient. It can accept an overshooting step (the step
α=0.25 above). The convergence theory of nonlinear CG (Fletcher–Reeves) needs strong Wolfe
with c2<1/2. For BFGS weak Wolfe is enough, but most libraries use strong Wolfe.
Armijo alone for BFGS on a nonconvex f. Then y⊤s≤0 can happen, and the update loses
positive definiteness.
Floating point near the minimum. When c1α∥∇f∥2 is below the rounding error of
f (about 10−16∣f∣), Armijo cannot see the decrease, and the search stalls.
A quadratic has Hessian eigenvalues 0.5, 2 and 10. Give the stability limit, the best fixed step
and its factor, the factor of the step 1/L, and the steps to reduce ∥ek∥ by 106 with each.AnswerStability: η<2/10=0.2. Best step: 2/10.5≈0.190,ρ=19/21≈0.905,⌈138.04⌉=139 steps. Step 1/L=0.1:ρ=1−0.5/10=0.95,⌈269.3⌉=270 steps. The middle eigenvalue 2 does not matter.
In the proof of Theorem 3, where is convexity used, and where is the monotone decrease of
f(xi) used?AnswerConvexity in step 2, f(x)≤f⋆+∇f(x)⊤(x−x⋆). It turns the gap into a difference of squared distances, which telescopes. The monotone decrease in step 5, to bound the last gap by the average of all gaps.
f is convex and L-smooth with L=4 and ∥x0−x⋆∥=5. How many steps with η=1/L
guarantee f(xk)−f⋆≤10−3?AnswerL∥x0−x⋆∥2/(2k)≤10−3 gives k≥4⋅25/(2⋅10−3)=50,000 steps.
For L=8,α0=1,τ=0.5,c1=10−4: which step does backtracking guarantee along
−∇f? Can it accept a step larger than 2/L?Answerα≥min(1,2⋅0.5⋅0.9999/8)≈0.125. Yes: on a quadratic Armijo accepts every α≤2(1−c1)g⊤g/g⊤Ag. This is larger than 2/L when g lies mostly in flat directions. The limit 2/L is about a fixed step repeated forever, not about one step.
Why does BFGS need y⊤s>0, and which line-search condition gives it?AnswerThe secant equation Bs=y with B≻0 forces s⊤y=s⊤Bs>0, and the BFGS update keeps B positive definite exactly when y⊤s>0. The (weak or strong) Wolfe curvature condition gives y⊤s≥α(c2−1)∇f(x)⊤d>0.
Recall cardsAnswer in your head first, then reveal. Add the cards to your review deck to see them again just before you would forget.
Convergence factor of gradient descent with step η on a quadratic with eigenvalues in [μ,L]?
ρ(η)=max(∣1−ημ∣,∣1−ηL∣), and ∥ek∥≤ρk∥e0∥.
For which fixed steps does gradient descent converge on a quadratic, from every start?
Exactly for 0<η<2/λmax. The steepest direction sets the limit.
Best fixed step on a quadratic, and its factor?
η⋆=2/(μ+L), with ρ⋆=(κ−1)/(κ+1).
About how many gradient descent steps does κ=100 need for a factor 106, with the best step?
About 2κln106≈691.
Rate of gradient descent with step 1/L on an L-smooth, μ-strongly convex f?
f(xk)−f⋆≤(1−μ/L)k(f(x0)−f⋆); proof: descent lemma plus PL.
Rate of gradient descent with step 1/L on an L-smooth convex f?
f(xk)−f⋆≤L∥x0−x⋆∥2/(2k), a sublinear O(1/k) rate.
State the Armijo condition.
f(x+αd)≤f(x)+c1α∇f(x)⊤d with 0<c1<1: the value must drop by at least a fraction c1 of what the tangent predicts.
State the weak and the strong Wolfe curvature conditions.
Weak: φ′(α)≥c2φ′(0). Strong: ∣φ′(α)∣≤c2∣φ′(0)∣. Both with c1<c2<1.
Usual line-search constants for quasi-Newton methods?
c1=10−4 and c2=0.9 (as in SciPy and PyTorch's L-BFGS).
Why do quasi-Newton methods need the curvature condition?
It gives y⊤s>0, and the BFGS update keeps its matrix positive definite exactly when y⊤s>0.
"Which learning rate makes gradient descent diverge on a quadratic?" — η>2/λmax. At
exactly 2/λmax the steepest component bounces forever without shrinking.
"What is the convergence rate of gradient descent?" — Convex and L-smooth: O(1/k) in f.
Strongly convex: linear, (1−μ/L)k, so O(κlog(1/ε)) steps. Best fixed step on a
quadratic: 2/(μ+L), factor (κ−1)/(κ+1).
"κ=104: how many steps for six digits?" — About 2κln106≈69,000 with the
best step, and κln106≈138,000 with 1/L.
"What are the Wolfe conditions, and why does L-BFGS need them?" — Sufficient decrease plus
curvature. The curvature condition gives y⊤s>0, which keeps the BFGS matrix positive definite.
"Why don't we use line searches to train neural networks?" — Minibatch losses are noisy and each
trial costs a forward pass; schedules are cheaper and work well.
Strang runs gradient descent with exact line search on f=21(x2+by2) and finds the factor (1−b)/(1+b) per step, the same factor as the best fixed step of Theorem 1.
Open on YouTube · the player loads from youtube-nocookie.com when you press play
Watch for backtracking line search and the convergence proofs for convex and strongly convex functions.
Open on YouTube · the player loads from youtube-nocookie.com when you press play
The two conditions explained on the 1D function φ(α), as in the Armijo figure above.
Open on YouTube · the player loads from youtube-nocookie.com when you press play
Lieven Vandenberghe, ECE236C, lecture "Gradient method"
(slides): the O(1/k) proof, backtracking, the strongly convex case and the lower bound.