§8.5.3–8.6.1Adam · Choosing an Optimizer · Newton's Method

Part II DL pp. 308–312 · ~4 min read

  • adam

§8.5.3 Adam

Adam (“adaptive moments”) combines the two ideas we just met: momentum (a first-moment estimate of the gradient) and RMSProp (a second-moment estimate of the squared gradient) — plus a bias correction that RMSProp lacks:

Algorithm 8.7 — Adam (click lines)
  1. 1Require: step ϵ\epsilon (0.001); decay rates ρ1=0.9, ρ2=0.999\rho_1{=}0.9,\ \rho_2{=}0.999; δ=108\delta{=}10^{-8}; initial θ\boldsymbol{\theta}
  2. 2initialize moments s0, r0\boldsymbol{s}\leftarrow 0,\ \boldsymbol{r}\leftarrow 0; time t0t\leftarrow 0
  3. 3while stopping criterion not met do
  4. 4compute gradient g\boldsymbol{g};  tt+1\ t \leftarrow t+1
  5. 5first moment: sρ1s+(1ρ1)g\boldsymbol{s} \leftarrow \rho_1\boldsymbol{s} + (1-\rho_1)\boldsymbol{g}
  6. 6second moment: rρ2r+(1ρ2)gg\boldsymbol{r} \leftarrow \rho_2\boldsymbol{r} + (1-\rho_2)\boldsymbol{g}\odot\boldsymbol{g}
  7. 7bias-correct: s^s1ρ1t,r^r1ρ2t\hat{\boldsymbol{s}} \leftarrow \dfrac{\boldsymbol{s}}{1-\rho_1^t},\quad \hat{\boldsymbol{r}} \leftarrow \dfrac{\boldsymbol{r}}{1-\rho_2^t}
  8. 8update: Δθ=ϵs^r^+δ\Delta\boldsymbol{\theta} = -\epsilon\,\dfrac{\hat{\boldsymbol{s}}}{\sqrt{\hat{\boldsymbol{r}}}+\delta};  θθ+Δθ\ \boldsymbol{\theta} \leftarrow \boldsymbol{\theta} + \Delta\boldsymbol{\theta}

§8.5.4 Which optimizer?

There is no consensus. The adaptive-rate family is robust, but no single method wins across tasks — the choice often comes down to which one you know well enough to tune. Here is the lineage:

The optimizer family — what each one adapts
what it addsnotes
SGDnothing — step −ε·g with a decaying global εthe baseline; robust and cheap
SGD + momentuma velocity (a 1st-moment memory of gradients)accelerates down canyons; adds α
AdaGradper-parameter rate ∝ 1/√(Σ g²)convex-friendly, but the full-history sum shrinks the rate too early for deep nets
RMSPropper-parameter rate from an EMA of g²fixes AdaGrad's over-decay; a go-to method
Adam1st + 2nd moments (momentum + RMSProp) + bias correctionrobust defaults; a common first choice
Dotted-underlined cells have explanations — click one.

§8.6.1 Newton’s method

All those methods use only the gradient. Second-order methods use the curvature too. Newton’s method fits a quadratic (a second-order Taylor expansion) at the current point and jumps straight to its minimum:

Term by term

θ=θ0H1θJ(θ0)\boldsymbol{\theta}^* = \boldsymbol{\theta}_0 - \boldsymbol{H}^{-1}\,\nabla_{\boldsymbol{\theta}} J(\boldsymbol{\theta}_0)
H1J\boldsymbol{H}^{-1}\nabla Jrescale the gradient by the INVERSE Hessian — for a positive-definite quadratic this lands exactly on the minimum in a single step (no learning rate to tune)the jump
[H+αI]1[\boldsymbol{H} + \alpha\boldsymbol{I}]^{-1}danger: if H has NEGATIVE eigenvalues (near a saddle), the step points the WRONG way. Regularize by adding α to the diagonal (Levenberg–Marquardt)saddle fix
O(k3)O(k^3)the k×k Hessian must be formed AND inverted every iteration — with k in the millions this is infeasible, so we approximate it (CG, BFGS)the cost

You have already seen Newton’s one-jump behavior: in the optimizer widget, tick “show Newton’s method” — while gradient descent zig-zags down the canyon, Newton uses H1\boldsymbol{H}^{-1} to leap straight to the minimum:

Newton vs gradient descent on an ill-conditioned bowl — toggle "show Newton's method" to see the single H⁻¹ jump straight to the minimum
minimumstartcontours of f(x) = ½xᵀHx — eigenbasis at 45°, λmax = 1, λmin = 1/κ

step 0/80 · f = 93.10

Canyon regime: GD zigzags down the steep walls (λmax direction) while crawling along the floor (λmin direction) — ε must stay small for the walls, so progress along the floor is slow. Try the momentum optimizer.

Why Newton’s method does not scale to deep nets

Two problems. First, Newton’s method is only safe when the Hessian is positive definite — but deep loss surfaces are riddled with saddle points (§8.2.3), where negative eigenvalues make the update move uphill. The regularized [H+αI]1[\boldsymbol{H}+\alpha\boldsymbol{I}]^{-1} helps only if the negative eigenvalues are small; strong negative curvature forces α\alpha so large that Newton degrades to plain gradient descent with step 1/α1/\alpha. Second, the cost: the Hessian has k2k^2 entries and costs O(k3)O(k^3) to invert every iteration — with kk in the millions, hopeless. The next section’s methods (conjugate gradients, BFGS) chase Newton’s benefits while sidestepping the inverse Hessian.

Next: conjugate gradients, BFGS, and the meta-algorithms — conjugate gradients, BFGS & meta-algorithms.

Check yourself — Adam, optimizer choice, and Newton's method

1.What does Adam combine, and what does its bias correction fix?

2.Which statement about choosing an optimizer is accurate?

3.What does Newton's update θ* = θ₀ − H⁻¹∇J do on a positive-definite quadratic?

4.Why is Newton's method dangerous near saddle points, and what is the standard fix?

5.Why does Newton's method not scale to large neural networks, even setting saddles aside?

5 questions