Gradient Descent

Problem: minimise $L(\theta)$, $\theta\in\mathbb{R}^n$. We can't see the landscape, only $L$ and $\nabla L$ where we stand.

1/2

1The picture: contours of $L$

$L(\theta)=\theta_1^2+3\theta_2^2$  · each ellipse = one value of $L$

Notice: $\nabla L$ is ⟂ to the contour through $\theta_t$, and it does not point at the minimum.

2Why step along $-\nabla L$?

$L(\theta+\Delta)\approx L(\theta)+\nabla L^{\top}\Delta$
Taylor, small $\Delta$
$\nabla L^{\top}u=\lVert\nabla L\rVert\cos\varphi$
slope along unit $u$

$\varphi=0$ → steepest ascent
$\varphi=90^\circ$ → slope 0 = along contour (⇒ ⟂)

choose $\Delta=-\eta\nabla L$:

$\;\Rightarrow L(\theta+\Delta)\approx L(\theta)-\eta\lVert\nabla L\rVert^2$

→ goes down if $\nabla L\neq 0$ and $\eta$ small enough

$$\theta_{t+1}=\theta_t\;\underbrace{-\;\eta}_{\text{how far}}\;\underbrace{\nabla L(\theta_t)}_{\text{uphill dir.}}$$
  • $\nabla L$: direction + rate of fastest increase
  • minus: go downhill (green arrow)
  • $\eta$: how far we trust a local slope
  • stops when $\nabla L=0$ (min, max or saddle)

3One step by hand

$\nabla L=(2\theta_1,\;6\theta_2)^{\top}$,   $\theta_t=(2,1)$,   $\eta=0.1$

$\nabla L(\theta_t)=(4,6)$

$\theta_{t+1}=(2,1)-0.1\,(4,6)=\color{#2c7a3f}{(1.6,\;0.4)}$

$L:\; 7 \;\to\; 3.04$ ✓ decreased

Notice: step dir. $(-4,-6)$ vs. straight to min $(-2,-1)$: the steep $\theta_2$-direction gets a 3× bigger push.

different curvatures → unequal gradient components → curved / zig-zag path (p. 2)


4Where it stops: $\nabla L=0$ is not always a minimum

$L=\theta_1^2-\theta_2^2$: at the origin $\nabla L=0$, yet $\theta_2$-direction goes down.

  • saddle: GD started exactly on the $\theta_1$-axis never leaves it; tiny noise escapes
  • local min (non-convex $L$): GD stays; no global guarantee
  • plateau: $\nabla L\approx0$ far from any min → tiny steps

Important assumption for "GD finds the min": $L$ convex (+ suitable $\eta$, p. 2).

Key idea: $-\nabla L$ is the fastest decrease right here. Gradient descent is greedy and local; it is not the shortest path to the minimum.

Step size $\eta$ & when GD struggles

2/2

51-D: the whole story in one line

$L(\theta)=\tfrac{a}{2}\theta^2,\quad L'(\theta)=a\theta$
curvature $a>0$
$\theta_{t+1}=\theta_t-\eta a\theta_t=(1-\eta a)\,\theta_t$
plug into update
$\theta_t=(1-\eta a)^t\,\theta_0$
unroll

converges ⟺

$$|1-\eta a|\lt 1 \iff 0\lt\eta\lt \tfrac{2}{a}$$
  • $\eta a\lt1$: monotone, from one side
  • $\eta a=1$: lands on the min in one step
  • $1\lt\eta a\lt2$: overshoots, but oscillates inward
  • $\eta a\gt2$: overshoots more each step → diverges
$\eta a=0.15$: too small → crawls $\eta a=0.7$: good → fast $\eta a=2.2$: too large → $|\theta|$ grows ×1.2 per step

6n-D: the tightest curvature limits $\eta$, the flattest sets the speed

$L=\tfrac12(\theta_1^2+10\,\theta_2^2)$,  $\eta=0.18$

$L=\tfrac12\theta^{\top}H\theta$, eigenvalues $\lambda_{\min}\le\dots\le\lambda_{\max}$:

each eigen-direction is the 1-D case with $a=\lambda_i$

  • stability needs $\eta\lt 2/\lambda_{\max}$ (steep dir.)
  • slowest factor: $1-\eta\lambda_{\min}$ (flat dir.)

So: speed is set by $\kappa=\lambda_{\max}/\lambda_{\min}$. Big $\kappa$ → zig-zag across the valley, crawl along it.

Assumption behind "$\eta\lt 2/L$" in general: $L$-smooth, i.e. curvature $\le L$ everywhere.

Fixes for big $\kappa$ (beyond these notes)

momentum (damps the zig-zag), Adam / preconditioning (rescale directions so $\kappa\to$ smaller)

Remember

  1. $\nabla L$ ⟂ contours; $-\nabla L$ = steepest local descent.
  2. 1-D: $\theta_t=(1-\eta a)^t\theta_0$ → need $\eta\lt 2/a$.
  3. Steepest curvature caps $\eta$, flattest sets the speed: $\kappa$ matters.

Test your understanding

  1. Why must the gradient be perpendicular to the contour line? Answer with the $\cos\varphi$ argument.
  2. For $L=\tfrac{a}{2}\theta^2$, which $\eta$ reaches the minimum in one step? Why does that trick fail in n-D when $\lambda_{\max}\neq\lambda_{\min}$?
  3. You double the scale of $\theta_2$ (units change). What happens to $\kappa$, the zig-zag, and the largest stable $\eta$?
  4. GD stopped with $\nabla L=0$. Name three things this point could be, and say how you would tell them apart.