# Drill 21 Momentum variation 2

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/17/tee-c17-s21

Canonical: https://deep-learning-study-room.vercel.app/read/dl/tee/section/tee-c17-s21/

## Question

**Question.** J(θ) = ½(θ−1)², θ₀ = -0.5, η = 0.1. Perform two Momentum updates. Use β = 0.9, v₀ = 0 and signed velocity.

## Answer — step by step

### Given

Objective: J(θ) = ½(θ−1)².

Initial θ₀ = −0.5; η = 0.1; two iterations.

β = 0.9; initial signed velocity v₀ = 0.

### To find

Find every stored state needed by the method and the parameter after each of two updates.

### Formula — which one and why

**Momentum with signed velocity.** Combine the retained old displacement with the current downhill correction, then add that signed displacement to the old parameter.

v = signed velocity/displacement; β = momentum coefficient; g = current gradient; η = learning rate. This convention uses +v in the parameter update.



$$
v_t=\beta v_{t-1}-\eta g_t
$$





$$
\theta_t=\theta_{t-1}+v_t
$$



**Yaad rakhne ka cue:** Pehle velocity banao; phir old parameter mein velocity jodo.

### Solution — step by step

### Meaning of the symbols

θ (theta) is the number we update. η (eta) is learning rate 0.1. g is the derivative of the objective, evaluated at the required position. A subscript counts updates; θ₀ means the starting value.

### Differentiate the objective first



$$
J(\theta)=\frac12(\theta-1)^2,\qquad J\prime(\theta)=\theta-1
$$



The power rule brings down 2, which cancels the half. The inside derivative is 1, so the remaining gradient is θ minus 1.

### Update formulas

v stores the signed movement from the previous update. β = 0.9 retains 90% of that movement. Start v₀ = 0.



$$
g_t=J\prime(\theta_{t-1})
$$





$$
v_t=\beta v_{t-1}-\eta g_t,\quad \theta_t=\theta_{t-1}+v_t
$$



**Step 1: Update 1.**



$$
g_1=-0.5-(1)=-1.5
$$





$$
v_1=0.9(0)-0.1(-1.5)=0.15
$$





$$
\theta_1=-0.5+(0.15)=-0.35
$$



**Step 2: Update 2.**



$$
g_2=-0.35-(1)=-1.35
$$





$$
v_2=0.9(0.15)-0.1(-1.35)=0.27
$$





$$
\theta_2=-0.35+(0.27)=-0.08
$$



**Final parameter after two updates: -0.08.** The second gradient is evaluated again using the parameter obtained after the first update.
