σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Optimization skill›Module 2 · Gradient methods›Topic 2.3·~55 minIntermediate

Momentum RMSProp and Adam

Skill positionModule 2 of 5 · Topic 3 of 3
2.3 Momentum RMSProp and Adam
—Lab score— / 100Total XP—Streak—

Remembering past gradients

Plain gradient steps treat every iteration on its own, so they zig-zag across narrow valleys and crawl along flat ones. Momentum keeps a velocity, a running sum of past gradients: v←βv+g\mathbf v\leftarrow\beta\mathbf v+\mathbf gv←βv+g, w←w−ηv\mathbf w\leftarrow\mathbf w-\eta\mathbf vw←w−ηv. Gradients that point the same way keep adding up, while gradients that flip sign cancel out. With a constant gradient the velocity grows toward 1/(1−β)1/(1-\beta)1/(1−β) times the gradient, so β=0.9\beta=0.9β=0.9 ends up taking steps ten times larger than plain descent.

v←βv+g,w←w−ηv,v∞=g1−β\mathbf v\leftarrow\beta\mathbf v+\mathbf g,\qquad \mathbf w\leftarrow\mathbf w-\eta\mathbf v,\qquad \mathbf v_{\infty}=\frac{\mathbf g}{1-\beta}v←βv+g,w←w−ηv,v∞​=1−βg​(1)

RMSProp fixes a different problem, parameters on different scales. It tracks a running average sss of the squared gradient of each coordinate and divides the step by s\sqrt{s}s​, so a coordinate with a large, noisy gradient takes small steps and a coordinate with a small gradient takes bigger ones. Adam combines both ideas: it averages the gradient (mmm, the momentum part) and the squared gradient (vvv, the RMSProp part). Both averages start at zero, which makes them too small in the first steps, so Adam divides by 1−βt1-\beta^{t}1−βt to correct that bias. The usual defaults are β1=0.9\beta_1=0.9β1​=0.9, β2=0.999\beta_2=0.999β2​=0.999 and η=10−3\eta=10^{-3}η=10−3.

s←ρs+(1−ρ)g2,w←w−ηgs+εs\leftarrow\rho s+(1-\rho)g^{2},\qquad w\leftarrow w-\eta\frac{g}{\sqrt{s}+\varepsilon}s←ρs+(1−ρ)g2,w←w−ηs​+εg​(2)
m←β1m+(1−β1)g,v←β2v+(1−β2)g2,m^=m1−β1t,  v^=v1−β2t,w←w−ηm^v^+εm\leftarrow\beta_1 m+(1-\beta_1)g,\quad v\leftarrow\beta_2 v+(1-\beta_2)g^{2},\quad \hat m=\frac{m}{1-\beta_1^{t}},\ \ \hat v=\frac{v}{1-\beta_2^{t}},\quad w\leftarrow w-\eta\frac{\hat m}{\sqrt{\hat v}+\varepsilon}m←β1​m+(1−β1​)g,v←β2​v+(1−β2​)g2,m^=1−β1t​m​,  v^=1−β2t​v​,w←w−ηv^​+εm^​(3)
Three updates by handMomentum with β=0.9\beta=0.9β=0.9, η=0.1\eta=0.1η=0.1 and a constant gradient g=1g=1g=1: v1=1v_1=1v1​=1, v2=1.9v_2=1.9v2​=1.9, v3=2.71v_3=2.71v3​=2.71, so the third step has length 0.2710.2710.271 against 0.10.10.1 for plain descent. RMSProp with ρ=0.9\rho=0.9ρ=0.9 and g=2g=2g=2: s1=0.1⋅4=0.4s_1=0.1\cdot4=0.4s1​=0.1⋅4=0.4 and g/s1=3.16g/\sqrt{s_1}=3.16g/s1​​=3.16, a step amplified by about 3.163.163.16. Adam at t=1t=1t=1 with g=2g=2g=2: m=0.2m=0.2m=0.2, v=0.004v=0.004v=0.004, so m^=2\hat m=2m^=2, v^=4\hat v=4v^=4 and the step is η⋅2/2=η\eta\cdot2/2=\etaη⋅2/2=η, whatever the size of ggg.
  • Momentum: smooths zig-zag and speeds up along consistent directions.
  • RMSProp: divides each coordinate by the running root-mean-square of its gradient.
  • Adam: both, plus a bias correction because the averages start at zero.
Adam is a default, not a guaranteeBecause Adam's step is about η\etaη per coordinate whatever the gradient size, η\etaη becomes the main tuning knob: too large and the loss bounces, too small and training crawls. Decay η\etaη over time on noisy problems, and compare against a well-tuned SGD with momentum before trusting Adam's result, since the two can settle in different minima.

Lab · what's graded

  • Momentum velocity15 pts
  • The long-run amplification15 pts
  • RMSProp average10 pts
  • The RMSProp step scale15 pts
  • Adam's first step15 pts
  • Match method and idea15 pts
  • Why per-coordinate scaling helps15 pts
0/ 7 answered
Tasks
1Numeric answer15 ptsNot answered

With β=0.9\beta=0.9β=0.9 and a constant gradient g=1g=1g=1, starting from v0=0v_0=0v0​=0, what is the velocity v3v_3v3​ after three updates v←βv+gv\leftarrow\beta v+gv←βv+g?

v3=v3 =v3=accepted: ± 0.01
2Numeric answer15 ptsNot answered

With a constant gradient, the velocity tends to g/(1−β)g/(1-\beta)g/(1−β). By what factor does β=0.9\beta=0.9β=0.9 end up multiplying the step compared with plain descent?

amp=amp =amp=accepted: ± 0.05
3Numeric answer10 ptsNot answered

RMSProp with ρ=0.9\rho=0.9ρ=0.9, starting from s0=0s_0=0s0​=0, sees the gradient g=2g=2g=2. What is s1=ρs0+(1−ρ)g2s_1=\rho s_0+(1-\rho)g^2s1​=ρs0​+(1−ρ)g2?

s1=s1 =s1=accepted: ± 0.005
4Numeric answer15 ptsNot answered

The RMSProp step is η g/s1\eta\,g/\sqrt{s_1}ηg/s1​​. For g=2g=2g=2 and s1=0.4s_1=0.4s1​=0.4, what is g/s1g/\sqrt{s_1}g/s1​​? Give it to two decimals.

scale=scale =scale=accepted: ± 0.02
5Numeric answer15 ptsNot answered

Adam at t=1t=1t=1 with β1=0.9\beta_1=0.9β1​=0.9, β2=0.999\beta_2=0.999β2​=0.999 and g=2g=2g=2 has m=0.2m=0.2m=0.2 and v=0.004v=0.004v=0.004. After the bias correction its step is η m^/v^\eta\,\hat m/\sqrt{\hat v}ηm^/v^​. By what multiple of η\etaη does it move?

adam1=adam1 =adam1=accepted: ± 0.01
6Match15 ptsNot answered

Match each method with its main idea.

Pick the partner of each item on the left.

Momentum
RMSProp
Adam
Bias correction
7Explain in words15 ptsNot answered

In one or two sentences, say why dividing each coordinate's step by the size of its recent gradients helps when parameters live on very different scales.

Math modeKeyboard or LaTeX inputTask 1 of 7 · Ctrl ⏎ to check

Log in to run your code.

Every lecture is free to read. Create an account or log in to run code, run tests and submit this lab.

  • In-browser IDE with a bash terminal — nothing to install
  • Instant grading, XP and your place on the skill
Create an accountLog in
OR
Continue with GitHub