Skip to content
Glacius
OptimizationConcept reference

Gradient descent steps

One gradient descent update subtracts the learning rate times the current gradient.

On this page 9 sections
  1. Overview
  2. Keep the state, gradient, and step separate
  3. Update each coordinate
  4. Calculate the gradient from an objective
  5. Use derivatives from one starting state
  6. Understand what the direction does and does not guarantee
  7. Key takeaway
  8. Sources & further reading
  9. Concept connections

01Keep the state, gradient, and step separate#

Gradient descent uses a local derivative to choose a new parameter state. Let θ\theta denote the current parameter vector, ff the scalar objective, and g=∇f(θ)g=\nabla f(\theta) its gradient at that state.

The learning rate η\eta is a positive number controlling the scale of the update. One plain gradient descent step is

θnew=θ−ηg.\theta_{\mathrm{new}}=\theta-\eta g.

There are three different objects here: the gradient gg, the change −ηg-\eta g, and the new parameter θnew\theta_{\mathrm{new}}. A gradient is a vector of rates; it is not itself the new parameter value.

The minus sign chooses the direction of local decrease. The learning rate decides how far we move in that direction.

02Update each coordinate#

Take θ=(4,−1)T\theta=(4,-1)^T, gradient g=(2,−4)Tg=(2,-4)^T, and learning rate η=0.5\eta=0.5. First scale the gradient: ηg=(1,−2)T\eta g=(1,-2)^T. Then subtract:

θnew=(4−1−1−(−2))=(31).\begin{gathered}\theta_{\mathrm{new}}=\begin{pmatrix}4-1\\-1-(-2)\end{pmatrix}\\=\begin{pmatrix}3\\1\end{pmatrix}.\end{gathered}

The first coordinate decreases. The second increases because we subtract a negative gradient component.

Current parameter θ=(4,−1). Gradient g=(2,−4) and rate η=.5 give step −ηg=(−1,2). The step arrow starts at θ and ends at the new parameter (3,1). Both coordinate axes use equal scale.Current parameter θ=(4,−1). Gradient g=(2,−4) and rate η=.5 give step −ηg=(−1,2). The step arrow starts at θ and ends at the new parameter (3,1). Both coordinate axes use equal scale.
Figure 1Current parameter θ=(4,−1). Gradient g=(2,−4) and rate η=.5 give step −ηg=(−1,2). The step arrow starts at θ and ends at the new parameter (3,1). Both coordinate axes use equal scale.
Link to this figure ↗Download SVGDownload PNG

The actual step is θnew−θ=(−1,2)T\theta_{\mathrm{new}}-\theta=(-1,2)^T, the opposite direction to the gradient. On equal coordinate scales, its length is the gradient length multiplied by 0.50.5.

Do not subtract the learning rate alone from each coordinate. It scales the corresponding derivative, so coordinates can change by different amounts and in different directions.

Check your reasoning

Current θ=(3,2)\theta=(3, 2), gradient g=(4,−8)g=(4, -8), η=0.25\eta=0.25. Find the descent update.

  1. A(2,5)(2, 5)
  2. B(2,4)(2, 4)
  3. C(3,4)(3, 4)
Show answer and explanation
(2,4)(2, 4)

Subtract ηg\eta g coordinatewise: (2,4)(2, 4).

03Calculate the gradient from an objective#

Consider the two-parameter objective f(a,b)=(a−1)2+2b2f(a,b)=(a-1)^2+2b^2. Its gradient is

∇f(a,b)=(2(a−1)4b).\begin{gathered}\nabla f(a,b)\\=\begin{pmatrix}2(a-1)\\4b\end{pmatrix}.\end{gathered}

At (a,b)=(3,−1)(a,b)=(3,-1), the objective is 66 and the gradient is (4,−4)T(4,-4)^T. With η=0.1\eta=0.1, the update gives (anew,bnew)=(2.6,−0.6)(a_{\mathrm{new}},b_{\mathrm{new}})=(2.6,-0.6).

Evaluate the objective at the new state to see what happened:

f(2.6,−0.6)=1.62+2(0.62)=3.28.\begin{gathered}f(2.6,-0.6)\\=1.6^2+2(0.6^2)\\=3.28.\end{gathered}

This particular step reduced the objective from 66 to 3.283.28. Calculating the new value is a separate forward evaluation; the old gradient alone is not the new loss.

The same rule works with one parameter. For h(x)=2(x−1)2h(x)=2(x-1)^2, the derivative is h′(x)=4(x−1)h'(x)=4(x-1). At x=3x=3, it is 88, so a learning rate of 0.10.1 gives xnew=3−0.1(8)=2.2x_{\mathrm{new}}=3-0.1(8)=2.2.

The objective also happens to equal 88 at this starting point. That numerical coincidence does not make objective values interchangeable with derivatives.

Check your reasoning

f(x)=4(x−3)2/2f(x)=4(x-3)^2/2. Start x=5x=5, rate η=0.25\eta=0.25. Find the next x.

Show answer and explanation
3

Derivative 4(x−3) gives 8; new x is 5−0.25(8)=3.

04Use derivatives from one starting state#

A plain gradient step computes all gradient entries at the same current parameter state, then updates all coordinates. For our two-parameter example, both derivatives came from (3,−1)(3,-1).

Updating one coordinate and recomputing another derivative midway would be a different procedure for objectives whose variables interact.

After reaching (2.6,−0.6)(2.6,-0.6), the next gradient is (3.2,−2.4)T(3.2,-2.4)^T. It differs from the original (4,−4)T(4,-4)^T because the parameters have moved.

The next iteration therefore starts with a new derivative calculation at the new state. Keep the subscript or evaluation point visible when following more than one step.

Check your reasoning

Current θ=(2,−3)\theta=(2, -3), g=(6,−2)g=(6, -2), η=0.5\eta=0.5. Draft update: (5,−4)(5, -4). Repair it.

  1. A(−1,−1)(-1, -1)
  2. B(0,−2)(0, -2)
  3. C(−1,−2)(-1, -2)
Show answer and explanation
(−1,−2)(-1, -2)

Subtract ηg\eta g coordinatewise: (−1,−2)(-1, -2).

05Understand what the direction does and does not guarantee#

Return to the original (3,−1)(3,-1) and the same gradient (4,−4)T(4,-4)^T, but choose η=1\eta=1. The new point is (−1,3)(-1,3).

Its objective is (−2)2+2(32)=22(-2)^2+2(3^2)=22, much larger than the starting value 66. The local downhill direction was correct; the step was too large.

For a differentiable objective with a nonzero gradient, a sufficiently small positive step along the negative gradient decreases the objective locally. This does not guarantee that an arbitrary learning rate decreases it, or that repeated steps find a global minimum.

A zero gradient produces no movement under this rule. A stationary point may be a minimum, maximum, or saddle; the update formula alone does not classify it.

For a weight matrix, the same operation happens entry by entry:

Wnew=W−η∇WL.W_{\mathrm{new}}=W-\eta\nabla_W L.

The gradient has the same shape as WW, so every parameter receives its own scaled derivative. Backpropagation computes those derivatives. Plain gradient descent uses them to change the parameters; momentum and Adam use other update rules.

Key takeaway

Evaluate the current gradient, scale every coordinate by the rate and subtract from the current parameter.

  • Compute one gradient descent update.

Sources & further reading

  1. [1]
    Dive into Deep Learning §12.3.1–12.3.2 ↗Dive into Deep Learning §12.3.1–12.3.2 · Article

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Gradient descent steps.” Math behind ML. /learn/o-gradient-step