Skip to main content
Luxara Academy

Archive — one question answered

How does one gradient descent step work?

Once you have the gradient, how do you update weight w?

Gradient descent moves parameters downhill on the loss. For one weight ww, derivative ∂L/∂w\partial L / \partial w and learning rate η\eta:

wnew=wold−η∂L∂ww_{\text{new}} = w_{\text{old}} - \eta \frac{\partial L}{\partial w}

Toy numbers: w=0.5w = 0.5, ∂L/∂w=2.0\partial L / \partial w = 2.0, η=0.1\eta = 0.1. Update: wnew=0.5−0.1×2.0=0.3w_{\text{new}} = 0.5 - 0.1 \times 2.0 = 0.3. Loss usually drops if η\eta is not too large.

The minus sign trips beginners: gradient increases loss, so we step opposite. With many parameters, each wjw_j and bb updates together after gradients on one example or a batch.

python
w, grad, eta = 0.5, 2.0, 0.1
w = w - eta * grad
assert w == 0.3

The Deep Learning track does this by hand on one spam email before wrapping a NumPy loop — so when loss explodes, you check η\eta or gradients first. Treat ∂L/∂w\partial L/\partial w as “if I nudge ww a tiny bit, does loss go up or down?” — the update rule is just that question turned into arithmetic. On the course spreadsheet exercise, students recompute wneww_{\text{new}} for the spam neuron before trusting w -= eta * grad in NumPy.