Gradient descent steps
One gradient descent update subtracts the learning rate times the current gradient.
On this page 9 sections
01Keep the state, gradient, and step separate#
Gradient descent uses a local derivative to choose a new parameter state. Let denote the current parameter vector, the scalar objective, and its gradient at that state.
The learning rate is a positive number controlling the scale of the update. One plain gradient descent step is
There are three different objects here: the gradient , the change , and the new parameter . 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 , gradient , and learning rate . First scale the gradient: . Then subtract:
The first coordinate decreases. The second increases because we subtract a negative gradient component.
The actual step is , the opposite direction to the gradient. On equal coordinate scales, its length is the gradient length multiplied by .
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.
Current , gradient , . Find the descent update.
Show answer and explanation
Subtract coordinatewise: .
03Calculate the gradient from an objective#
Consider the two-parameter objective . Its gradient is
At , the objective is and the gradient is . With , the update gives .
Evaluate the objective at the new state to see what happened:
This particular step reduced the objective from to . 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 , the derivative is . At , it is , so a learning rate of gives .
The objective also happens to equal at this starting point. That numerical coincidence does not make objective values interchangeable with derivatives.
. Start , rate . Find the next x.
Show answer and explanation
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 .
Updating one coordinate and recomputing another derivative midway would be a different procedure for objectives whose variables interact.
After reaching , the next gradient is . It differs from the original 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.
Current , , . Draft update: . Repair it.
Show answer and explanation
Subtract coordinatewise: .
05Understand what the direction does and does not guarantee#
Return to the original and the same gradient , but choose . The new point is .
Its objective is , much larger than the starting value . 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:
The gradient has the same shape as , 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.
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]Dive into Deep Learning §12.3.1–12.3.2 ↗Dive into Deep Learning §12.3.1–12.3.2 · Article