Deep Learning

Optimizers from momentum to Adam

This lecture compares paths down the error surface from gradient descent to Adam. It covers momentum, Nesterov lookahead, batch and minibatch updates, Adagrad, RMSprop and second-order methods. After this page you can run one update step of each optimizer by hand.

Paths down the error surfaceSearch on YouTube

Optimization moves the parameter vector from high loss to low loss. The slides use Zoey at height A. Zoey must reach point B below. Four routes exist: inclined slide, spiral slide, direct jump and staircase. Each route gives a different arrival time and cost. Training behaves the same way. Different update rules trace different paths to the minimum.

Think of Zoey on a hill. A steep slide is fast but rough. A spiral slide is longer but smoother. Small stairs are safe but slow.

The route decides convergence speed and stability. A good optimizer reaches low loss in fewer updates. It also avoids wild oscillations and long stalls.

θt+1=θt−η∇J(θt)\theta_{t+1} = \theta_t - \eta \nabla J(\theta_t)

θt\theta_t is the parameter vector at iteration tt. η\eta is the learning rate. ∇J(θt)\nabla J(\theta_t) is the gradient of the loss at iteration tt. The step size scales with the slope. Steep regions give large steps. Gentle regions give small steps.

Gradient sign and sizeSearch on YouTube

The gradient sign shows the direction of rise. The gradient size shows the rate of change. A positive slope means the function rises as xx rises. A negative slope means the function falls as xx rises. To descend, move opposite to the gradient.

Worked example. Check f(x)=x2+1f(x) = x^2 + 1 with f′(x)=2xf^\prime(x) = 2x at x=1x = 1, x=2x = 2 and x=−1x = -1.

Function values.

f(1)=12+1=2f(2)=22+1=5f(−1)=(−1)2+1=2f(0)=02+1=1\begin{aligned} f(1) &= 1^2 + 1 = \mathbf{2}\\ f(2) &= 2^2 + 1 = \mathbf{5}\\ f(-1) &= (-1)^2 + 1 = \mathbf{2}\\ f(0) &= 0^2 + 1 = \mathbf{1} \end{aligned}

Slope sign check.

f′(1)=2⋅1=2>0  ⇒  rises as x risesf′(2)=2⋅2=4>0  ⇒  rises faster, steeperf′(−1)=2⋅(−1)=−2<0  ⇒  falls as x rises\begin{aligned} f^\prime(1) &= 2 \cdot 1 = \mathbf{2 \gt 0} \;\Rightarrow\; \text{rises as } x \text{ rises}\\ f^\prime(2) &= 2 \cdot 2 = \mathbf{4 \gt 0} \;\Rightarrow\; \text{rises faster, steeper}\\ f^\prime(-1) &= 2 \cdot (-1) = \mathbf{-2 \lt 0} \;\Rightarrow\; \text{falls as } x \text{ rises} \end{aligned}

Descent sizes. Move xx from 2 to 1, then from 1 to 0.

f(2)−f(1)=5−2=3    large drop on steep partf(1)−f(0)=2−1=1    small drop on gentle part\begin{aligned} f(2) - f(1) &= 5 - 2 = \mathbf{3} \;\; \text{large drop on steep part}\\ f(1) - f(0) &= 2 - 1 = \mathbf{1} \;\; \text{small drop on gentle part} \end{aligned}

One gradient descent step. Start at x=2x = 2 with η=0.1\eta = 0.1.

xnew=2−0.1⋅4=2−0.4=1.6f(1.6)=1.62+1=2.56+1=3.56\begin{aligned} x_{\text{new}} &= 2 - 0.1 \cdot 4 = 2 - 0.4 = \mathbf{1.6}\\ f(1.6) &= 1.6^2 + 1 = 2.56 + 1 = \mathbf{3.56} \end{aligned}

Loss falls from 5 to 3.56 in one step.

Error surface and start positionSearch on YouTube

A 2D error surface needs a top view. Take a horizontal slice of the bowl. View the contours from above. The slide marks two paths from level J1 to level J2. Path BD crosses contours in a short distance. Path AC runs a longer way across the same levels. BD is steeper than AC. The steeper direction gives faster descent.

B to D A to C J2 J1
Top view of contours. BD is short and steep. AC is long and gentle. Both reach J2.

Gentle slopes cause slow progress with plain gradient descent. The start position then matters a lot. Start S1 may sit on a steep face and converge fast. Start S2 may sit on a flat plain and crawl. The same rule with the same learning rate gives very different times.

MomentumSearch on YouTube

Momentum accelerates gradient descent with memory of past steps. It adds a velocity term that accumulates past gradients. It gains speed when gradients point in one direction. It damps oscillations when gradients flip sign. It helps on steep valleys, small local minima and noisy gradients.

vt=βvt−1+∇J(θt)v_t = \beta v_{t-1} + \nabla J(\theta_t)θt+1=θt−ηvt\theta_{t+1} = \theta_t - \eta v_t

vtv_t is the velocity at iteration tt. β\beta is the momentum coefficient, often 0.9. η\eta is the learning rate. ∇J(θt)\nabla J(\theta_t) is the current gradient. θt\theta_t is the parameter vector.

Overshoot and valley oscillationsSearch on YouTube

Momentum can run past the goal. The stored velocity pushes the parameters forward. The profile view on the slides shows this overshoot risk. The top view shows oscillations across a narrow valley. Plain descent creeps down the valley floor. Momentum swings from side to side while moving forward. It still reaches the minimum faster despite larger swings.

The slides fit a sigmoid with weight ww and bias bb from start (w,b)=(2,6)(w, b) = (2, 6). Each update favours the downhill direction of the loss. The (w,b)(w, b) point shifts toward the valley floor. After several swings it settles at the best fitting pair.

Do not set β\beta near 1 without care. The stored velocity grows large. The updates then overshoot the minimum and oscillate hard.

Examiners accept β=0.9\beta = 0.9 as the standard momentum value. State the velocity rule first. Then state that consistent directions speed up and flips cancel out.

Nesterov accelerated gradientSearch on YouTube

Nesterov accelerated gradient (NAG) improves momentum with a lookahead. It does not use the gradient at the current point. It first jumps along the stored velocity. It then measures the gradient at that lookahead point. This peek corrects the course before a bad leap. It cuts overshoot and oscillation.

θ~t=θt−βvt−1\tilde{\theta}_t = \theta_t - \beta v_{t-1}gt=∇J(θ~t)g_t = \nabla J(\tilde{\theta}_t)vt=βvt−1+ηgtv_t = \beta v_{t-1} + \eta g_tθt+1=θt−vt\theta_{t+1} = \theta_t - v_t

θ~t\tilde{\theta}_t is the lookahead point. gtg_t is the gradient at the lookahead point. vtv_t is the corrected velocity. θt+1\theta_{t+1} is the new parameter vector. The four steps are lookahead, gradient, velocity correction and parameter update.

Look, Grade, Velocity, Drop: L-G-V-D

Lookahead point θ~t\tilde{\theta}_t · Gradient at lookahead gtg_t · Velocity correction vtv_t · Drop to θt+1=θt−vt\theta_{t+1} = \theta_t - v_t.

MomentumNAG
Uses the gradient at the current pointUses the gradient at the lookahead point
Takes a big leap, then sees the slopePeeks ahead, then adjusts the leap
Faster than plain descent but can overshootLess overshoot and less oscillation
One gradient per step at θt\theta_tOne gradient per step at θ~t\tilde{\theta}_t

Worked example. NAG step on J(θ)=θ2J(\theta) = \theta^2 with ∇J(θ)=2θ\nabla J(\theta) = 2\theta. Set θt=1.0\theta_t = 1.0, vt−1=0.2v_{t-1} = 0.2, β=0.9\beta = 0.9 and η=0.1\eta = 0.1.

Step 1. Lookahead point.

θ~t=1.0−0.9⋅0.2=1.0−0.18=0.82\begin{aligned} \tilde{\theta}_t &= 1.0 - 0.9 \cdot 0.2\\ &= 1.0 - 0.18 = \mathbf{0.82} \end{aligned}

Step 2. Gradient at lookahead.

gt=2⋅0.82=1.64\begin{aligned} g_t &= 2 \cdot 0.82 = \mathbf{1.64} \end{aligned}

The gradient at the current point would be 2.02.0. The lookahead sees the gentler slope ahead.

Step 3. Corrected velocity.

vt=0.9⋅0.2+0.1⋅1.64=0.18+0.164=0.344\begin{aligned} v_t &= 0.9 \cdot 0.2 + 0.1 \cdot 1.64\\ &= 0.18 + 0.164 = \mathbf{0.344} \end{aligned}

Step 4. Parameter update.

θt+1=1.0−0.344=0.656\begin{aligned} \theta_{t+1} &= 1.0 - 0.344 = \mathbf{0.656} \end{aligned}

Plain momentum would use gradient 2.0 and give vt=0.38v_t = 0.38 and θt+1=0.62\theta_{t+1} = 0.62. NAG takes the shorter corrected step.

Batch, stochastic and minibatch updatesSearch on YouTube

The three methods differ only in data per update. The per-epoch update count decides speed and noise.

Batch gradient descentSearch on YouTube

Batch gradient descent uses all NN training points for one update. It averages the NN gradients. It then applies the mean gradient once. One epoch gives one update. The path is smooth and direct. The cost per update grows with NN. Large datasets make each step costly.

Stochastic gradient descentSearch on YouTube

Stochastic gradient descent (SGD) updates after each single point. One epoch gives NN updates. Learning starts at once without waiting for the full pass. Early progress is fast. The path is noisy and less stable. The noise helps escape small local minima and saddle points. SGD suits large datasets with frequent updates.

Minibatch gradient descentSearch on YouTube

Minibatch gradient descent sits between the two. Fix a minibatch size BB. Update after each block of BB points. One epoch gives N/BN/B updates. It keeps the stability of batch updates. It keeps much of the speed of SGD.

batch updates per epoch=1SGD updates per epoch=Nminibatch updates per epoch=N/B\text{batch updates per epoch} = 1 \qquad \text{SGD updates per epoch} = N \qquad \text{minibatch updates per epoch} = N/B

NN is the training set size. BB is the minibatch size. One epoch means one full pass over the data. B=1B = 1 gives SGD. B=NB = N gives batch descent.

AlgorithmUpdates per epochCharacter
Batch gradient descent1Smooth, costly per step
Stochastic gradient descentNNFast start, noisy path
Minibatch gradient descentN/BN/BStable and fast, the common choice

Worked example. Count updates for N=10000N = 10000 points with minibatch size B=100B = 100.

batch=1 update per epochSGD=10000 updates per epochminibatch=10000/100=100 updates per epoch\begin{aligned} \text{batch} &= \mathbf{1} \text{ update per epoch}\\ \text{SGD} &= \mathbf{10000} \text{ updates per epoch}\\ \text{minibatch} &= 10000/100 = \mathbf{100} \text{ updates per epoch} \end{aligned}

Over 5 epochs.

batch total=5⋅1=5SGD total=5⋅10000=50000minibatch total=5⋅100=500\begin{aligned} \text{batch total} &= 5 \cdot 1 = \mathbf{5}\\ \text{SGD total} &= 5 \cdot 10000 = \mathbf{50000}\\ \text{minibatch total} &= 5 \cdot 100 = \mathbf{500} \end{aligned}

A second case: N=50000N = 50000 with B=50B = 50 gives 50000/50=100050000/50 = \mathbf{1000} minibatch updates per epoch.

Write N/BN/B for minibatch updates per epoch in the exam. Add the two ends: B=1B = 1 gives NN SGD updates, B=NB = N gives 1 batch update.

AdagradSearch on YouTube

Different weights need different step sizes. Some weights see large gradients often. They need small steps to avoid overshoot. Other weights see tiny or rare gradients. They need large steps to move at all. One global learning rate cannot serve both groups. Uneven feature scales make the gap worse.

Adaptive gradient (Adagrad) gives each weight its own rate. It tracks the sum of squared gradients per weight. Weights with large past gradients get smaller rates. Weights with small past gradients keep larger rates.

Gt=Gt−1+gt2G_t = G_{t-1} + g_t^2θt+1=θt−ηGt+ϵgt\theta_{t+1} = \theta_t - \frac{\eta}{\sqrt{G_t + \epsilon}} g_t

GtG_t is the accumulated sum of squared gradients. gtg_t is the current gradient. η\eta is the base learning rate. ϵ\epsilon is a small constant that avoids division by zero. All operations act per weight. The fraction is the effective learning rate for that weight.

Worked example. Two weights share η=0.1\eta = 0.1. Weight w1w_1 sees large gradients. Weight w2w_2 sees small gradients. Start with G0=0G_0 = 0 for both. Use ϵ=0\epsilon = 0 for hand calculation.

Iteration 1. Gradients are g=2.0g = 2.0 for w1w_1 and g=0.5g = 0.5 for w2w_2.

G1,w1=0+2.02=4.0effective ratew1=0.1/4.0=0.1/2=0.05Δw1=0.05⋅2.0=0.10G1,w2=0+0.52=0.25effective ratew2=0.1/0.25=0.1/0.5=0.20Δw2=0.20⋅0.5=0.10\begin{aligned} G_{1,w_1} &= 0 + 2.0^2 = \mathbf{4.0}\\ \text{effective rate}_{w_1} &= 0.1/\sqrt{4.0} = 0.1/2 = \mathbf{0.05}\\ \Delta w_1 &= 0.05 \cdot 2.0 = \mathbf{0.10}\\ G_{1,w_2} &= 0 + 0.5^2 = \mathbf{0.25}\\ \text{effective rate}_{w_2} &= 0.1/\sqrt{0.25} = 0.1/0.5 = \mathbf{0.20}\\ \Delta w_2 &= 0.20 \cdot 0.5 = \mathbf{0.10} \end{aligned}

So w1w_1 gets the smaller effective rate and w2w_2 gets the larger one.

Iteration 2. Same gradients again.

G2,w1=4.0+4.0=8.0effective ratew1=0.1/8.0=0.1/2.8284=0.0354Δw1=0.0354⋅2.0=0.0707G2,w2=0.25+0.25=0.50effective ratew2=0.1/0.50=0.1/0.7071=0.1414Δw2=0.1414⋅0.5=0.0707\begin{aligned} G_{2,w_1} &= 4.0 + 4.0 = \mathbf{8.0}\\ \text{effective rate}_{w_1} &= 0.1/\sqrt{8.0} = 0.1/2.8284 = \mathbf{0.0354}\\ \Delta w_1 &= 0.0354 \cdot 2.0 = \mathbf{0.0707}\\ G_{2,w_2} &= 0.25 + 0.25 = \mathbf{0.50}\\ \text{effective rate}_{w_2} &= 0.1/\sqrt{0.50} = 0.1/0.7071 = \mathbf{0.1414}\\ \Delta w_2 &= 0.1414 \cdot 0.5 = \mathbf{0.0707} \end{aligned}

Both rates shrink by 1/21/\sqrt{2}. The denominator only grows. Learning stalls with time.

Do not expect Adagrad to train to the end. The sum GtG_t grows without bound. The effective rate falls toward zero and updates freeze.

RMSpropSearch on YouTube

Root mean square propagation (RMSprop) fixes the decay of Adagrad. It replaces the full sum with a moving average. Recent squared gradients matter more. Old ones fade away. The denominator then stays bounded.

vt=βvt−1+(1−β)gt2v_t = \beta v_{t-1} + (1 - \beta) g_t^2θt+1=θt−ηvt+ϵgt\theta_{t+1} = \theta_t - \frac{\eta}{\sqrt{v_t + \epsilon}} g_t

vtv_t is the moving average of squared gradients. β\beta is the decay rate, often 0.9. gtg_t is the current gradient. η\eta is the base learning rate. ϵ\epsilon avoids division by zero. Each weight keeps its own vtv_t.

A short check shows the effect. With β=0.9\beta = 0.9, each new squared gradient adds only 10 percent weight. A long run of large gradients still leaves room for new steps. The method keeps adaptive rates without the aggressive freeze.

AdamSearch on YouTube

Adaptive moment estimation (Adam) joins both ideas. Momentum tracks the mean gradient. RMSprop tracks the mean squared gradient. Adam keeps both moving averages. It corrects their early bias. It then applies an adaptive momentum step.

mt=β1mt−1+(1−β1)gtm_t = \beta_1 m_{t-1} + (1 - \beta_1) g_tvt=β2vt−1+(1−β2)gt2v_t = \beta_2 v_{t-1} + (1 - \beta_2) g_t^2

mtm_t is the first moment, the momentum average. vtv_t is the second moment, the adaptive average. β1=0.9\beta_1 = 0.9 and β2=0.999\beta_2 = 0.999 are the decay rates. gtg_t is the current gradient. Both averages start at zero.

m^t=mt1−β1tv^t=vt1−β2t\hat{m}_t = \frac{m_t}{1 - \beta_1^t} \qquad \hat{v}_t = \frac{v_t}{1 - \beta_2^t}θt+1=θt−ηm^tv^t+ϵ\theta_{t+1} = \theta_t - \frac{\eta \hat{m}_t}{\sqrt{\hat{v}_t} + \epsilon}

m^t\hat{m}_t and v^t\hat{v}_t are the bias-corrected moments. tt is the iteration index starting at 1. η\eta is the learning rate. ϵ\epsilon is a small constant. The correction matters most in early steps when the averages still lean toward zero.

The four Adam steps are first moment, second moment, bias correction and parameter update. A variant called Nadam swaps plain momentum for Nesterov lookahead momentum. It applies the lookahead idea inside the Adam first moment.

G-M-A-R-D-A-N: Good Momentum And Rates Defeat All Noise

Gradient descent base · Momentum velocity · Nesterov Ahead lookahead. SGD and minibatch Rate is N/BN/B. Divided rates mark Adagrad · Averaged squares mark RMSprop · Adam and Nadam join both.

Adam in four: M-V-C-U. Mean gradient mtm_t · Variance term vtv_t · Corrected m^t\hat{m}_t, v^t\hat{v}_t · Update θ\theta.

Worked example. One Adam step with g1=0.6g_1 = 0.6, β1=0.9\beta_1 = 0.9, β2=0.999\beta_2 = 0.999, η=0.001\eta = 0.001 and ϵ=10−8\epsilon = 10^{-8}.

Moments at t=1t = 1 from zero start.

m1=0.9⋅0+0.1⋅0.6=0.06v1=0.999⋅0+0.001⋅0.36=0.00036\begin{aligned} m_1 &= 0.9 \cdot 0 + 0.1 \cdot 0.6 = \mathbf{0.06}\\ v_1 &= 0.999 \cdot 0 + 0.001 \cdot 0.36 = \mathbf{0.00036} \end{aligned}

Bias correction at t=1t = 1.

m^1=0.06/(1−0.9)=0.06/0.1=0.6v^1=0.00036/(1−0.999)=0.00036/0.001=0.36\begin{aligned} \hat{m}_1 &= 0.06/(1 - 0.9) = 0.06/0.1 = \mathbf{0.6}\\ \hat{v}_1 &= 0.00036/(1 - 0.999) = 0.00036/0.001 = \mathbf{0.36} \end{aligned}

Parameter change.

Δθ=0.001⋅0.6/(0.36+10−8)=0.001⋅0.6/0.6=0.001\begin{aligned} \Delta \theta &= 0.001 \cdot 0.6/(\sqrt{0.36} + 10^{-8})\\ &= 0.001 \cdot 0.6/0.6 = \mathbf{0.001} \end{aligned}

Without correction the raw ratio m1/v1m_1/\sqrt{v_1} would give 0.06/0.019=3.160.06/0.019 = 3.16 times η\eta. The correction restores the true gradient scale of 0.6.

Second-order methodsSearch on YouTube

First-order methods use only the gradient ∇f(θ)\nabla f(\theta). This group holds plain descent, SGD, RMSprop and Adam. The gradient gives the slope. It does not give the curvature. Second-order methods also use the Hessian H=∇2f(θ)H = \nabla^2 f(\theta). The Hessian shows how the gradient itself changes. Curvature guides a more exact step.

θt+1=θt−H−1∇f(θt)\theta_{t+1} = \theta_t - H^{-1} \nabla f(\theta_t)

H=∇2f(θt)H = \nabla^2 f(\theta_t) is the Hessian matrix of second derivatives. H−1H^{-1} is its inverse. ∇f(θt)\nabla f(\theta_t) is the gradient. This is Newton's method. It follows curvature in each direction.

The rule is simple. For a sharply curved direction, move a short way. For a flat direction, move a farther way. Convergence needs fewer iterations in theory. It also routes around tricky saddle zones better. Two limits block its use in deep nets. The Hessian has squared size in the parameter count. It is huge for large networks. Its inverse costs even more to compute and store.

Saddle pointsSearch on YouTube

A saddle point has zero gradient without being a minimum or maximum. It slopes up in some directions. It slopes down in others. Gradient methods rely on slope to move. At zero slope they see no direction. They may halt and report a false minimum. Training then stalls or slows hard.

saddle point, gradient zero
Saddle shape. One slice curves up. The other curves down. The centre has zero slope.

Deep loss surfaces have high dimension. Saddle points there outnumber true local minima by far. Methods with memory or curvature escape more often. Momentum rolls through on stored velocity. Adam adapts each rate and keeps motion. Second-order methods read curvature and step away.

Race four optimizers down one loss surface. Change steps, surface and paths to test each rule.

Valley surface, start (w,b)=(2,6)

→
— GD
— Momentum
— NAG
— Adam
η 0.12, Adam 0.35

NAG looks ahead to 0.82. It sees slope 1.64, not 2.0. It steps to 0.656. Momentum steps to 0.62.

Adagrad gives 0.05 to w1 and 0.20 to w2. RMSprop holds both rates alive.

Adagrad w1 0.05
Adagrad w2 0.20
RMSprop w1 0.05
RMSprop w2 0.20

Step 28. GD loss 0.00. Momentum loss 4.57. NAG loss 0.00. Adam loss 2.90.

Valley view: GD creeps down the floor. Momentum swings but runs fast. NAG cuts the swing. Adam steadies each direction. Adagrad iter 2 falls to 0.0354 and 0.1414. Both shrink by 1/√2.

Quick self-testSearch on YouTube

1. State the Zoey analogy and the plain gradient descent rule.

Zoey at height A must reach B below by slide, spiral, jump or stairs. Each path gives a different time and cost. Training matches this: θt+1=θt−η∇J(θt)\theta_{t+1} = \theta_t - \eta \nabla J(\theta_t). Steep slopes give large steps and gentle slopes give small steps.

2. For f(x)=x2+1f(x) = x^2 + 1, find the slope sign at x=2x = 2 and x=−1x = -1. Which change drops more, 2→12 \to 1 or 1→01 \to 0?

f′(x)=2xf^\prime(x) = 2x. At x=2x = 2 the slope is 4, positive and steep. At x=−1x = -1 the slope is −2-2, negative. The drop 2→12 \to 1 is 5−2=35 - 2 = 3. The drop 1→01 \to 0 is 2−1=12 - 1 = 1. The steep part drops more.

3. Differentiate momentum and NAG in one line each. Write the NAG four steps.

Momentum uses the gradient at the current point. NAG uses the gradient at the lookahead point. The four steps are lookahead θ~t\tilde{\theta}_t, gradient gtg_t, velocity vtv_t and update θt+1=θt−vt\theta_{t+1} = \theta_t - v_t.

4. Run one NAG step: θ=1.0\theta = 1.0, v=0.2v = 0.2, β=0.9\beta = 0.9, η=0.1\eta = 0.1, J=θ2J = \theta^2.

Lookahead is 1.0−0.18=0.821.0 - 0.18 = 0.82. Gradient is 1.641.64. Velocity is 0.18+0.164=0.3440.18 + 0.164 = 0.344. New θ=1.0−0.344=0.656\theta = 1.0 - 0.344 = 0.656.

5. Differentiate batch, SGD and minibatch by updates per epoch for N=10000N = 10000 and B=100B = 100.

Batch gives 1 update. SGD gives N=10000N = 10000 updates. Minibatch gives N/B=100N/B = 100 updates. Over 5 epochs the totals are 5, 50000 and 500.

6. In Adagrad with η=0.1\eta = 0.1, Gw1=4.0G_{w_1} = 4.0 and Gw2=0.25G_{w_2} = 0.25, which weight gets the larger effective rate?

Effective rate is 0.1/G0.1/\sqrt{G}. Weight w1w_1 gets 0.050.05. Weight w2w_2 gets 0.200.20. The weight with small past gradients gets the larger rate.

7. Why does Adagrad stall, and how does RMSprop fix it?

Adagrad sums all squared gradients in GtG_t. The denominator grows without bound and the rate falls toward zero. RMSprop uses a moving average vt=βvt−1+(1−β)gt2v_t = \beta v_{t-1} + (1-\beta)g_t^2 with β\beta near 0.9. Old gradients fade, so the rate stays alive.

8. Write the four Adam steps and the bias correction at t=1t = 1 for g1=0.6g_1 = 0.6.

Steps are first moment mtm_t, second moment vtv_t, bias correction and update. Here m1=0.06m_1 = 0.06 and v1=0.00036v_1 = 0.00036. Correction gives m^1=0.6\hat{m}_1 = 0.6 and v^1=0.36\hat{v}_1 = 0.36. The step is η⋅0.6/0.6=η\eta \cdot 0.6/0.6 = \eta.

9. Differentiate first-order and second-order methods. State two limits of Newton updates.

First-order methods use only the gradient ∇f\nabla f. Second-order methods add the Hessian H=∇2fH = \nabla^2 f and use θ−H−1∇f\theta - H^{-1}\nabla f. The Hessian is huge for large nets. Its inverse is costly to compute and store.

10. What is a saddle point, and which methods escape it more often?

A saddle point has zero gradient but is neither minimum nor maximum. Plain descent stalls there. Momentum, Adam and second-order methods escape more often through stored velocity, adaptive rates or curvature data.

  • Plain gradient descent uses θt+1=θt−η∇J(θt)\theta_{t+1} = \theta_t - \eta \nabla J(\theta_t). Steep slopes step far. Gentle slopes step short.
  • For f(x)=x2+1f(x) = x^2 + 1, f′=2xf^\prime = 2x. Slopes are 2 at x=1x = 1, 4 at x=2x = 2 and −2-2 at x=−1x = -1.
  • Momentum adds velocity vt=βvt−1+∇Jv_t = \beta v_{t-1} + \nabla J. It speeds consistent directions and damps flips. Standard β=0.9\beta = 0.9.
  • NAG runs four steps: lookahead, gradient at lookahead, velocity correction and update. It cuts overshoot.
  • Batch gives 1 update per epoch. SGD gives NN. Minibatch gives N/BN/B. B=1B = 1 is SGD and B=NB = N is batch.
  • Adagrad scales each weight by η/Gt+ϵ\eta/\sqrt{G_t + \epsilon}. GtG_t grows forever, so the rate decays to zero.
  • RMSprop uses vt=βvt−1+(1−β)gt2v_t = \beta v_{t-1} + (1-\beta)g_t^2 with β\beta near 0.9. It keeps adaptive rates alive.
  • Adam keeps mtm_t and vtv_t, corrects bias with 1−βt1 - \beta^t terms and updates with ηm^t/(v^t+ϵ)\eta \hat{m}_t/(\sqrt{\hat{v}_t} + \epsilon). Nadam uses Nesterov momentum inside Adam.
  • Newton uses θ−H−1∇f\theta - H^{-1}\nabla f. It moves short on sharp curves and far on flat ones. Hessian size and inversion block large nets.
  • Saddle points have zero gradient but are not minima. They dominate deep loss surfaces. Memory and curvature methods escape them.