Gradient of a Function
The gradient identifies the direction in which the function increases fastest around the current vector.
From a Current Vector to a Decision
Gradient descent does not jump directly to its final answer. It begins with an initial vector, examines the function at that current vector, and repeatedly decides which direction to move next. The gradient provides the direction of greatest local increase, so the algorithm reverses that direction to descend.
One Update in Numbers
What do you think happens?
Suppose the current vector is [10], the gradient at that vector is [2], and the positive learning-rate parameter is 0.5. The scaled movement is therefore [1]. What next vector results when the scaled movement is subtracted?
Reveal answer
[9]
The scaled movement is 0.5 × [2] = [1]. Reversing the gradient direction means subtracting that movement from the current vector: [10] − [1] = [9].
Applying one descent update
Current vector: [10]. Gradient at the current vector: [2]. Positive parameter η: 0.5.
- 1Identify the direction
The gradient [2] indicates the direction in which the function increases fastest around the current vector.
- 2Scale the direction
Multiply the gradient by η: 0.5 × [2] = [1]. The parameter controls the size of the movement.
- 3Reverse the direction
Gradient descent subtracts the scaled gradient from the current vector: [10] − [1].
The next vector is [9].
What the Gradient Tells You
For a differentiable function, the gradient identifies the direction in which the function increases fastest around the current vector.
The gradient is a direction signal. At the current vector, it points toward the greatest local increase in the function. Gradient descent needs the opposite direction because its purpose is descent rather than increase. The update therefore reverses the gradient direction and scales the movement using the positive parameter η.
Reading the Update Rule
- 1The current vector is the point where the function and its gradient are inspected.
- 2The gradient supplies the direction in which the function increases fastest around that point.
- 3η is a positive parameter that scales the movement.
- 4Multiplying η by the gradient produces the scaled movement.
- 5Subtraction reverses the gradient direction and produces the next vector.
Repeating the Update
After one update, the newly produced vector becomes the current vector for the next iteration. The algorithm evaluates the gradient again at this new point and applies the same rule again. Starting from an initial value, often written as w(1) = 0 in the description of the algorithm, the process continues through the chosen number of iterations.
The repeated updates create a sequence of vectors. The gradient is not evaluated only once at the starting point; it is evaluated again at each newly produced vector. This is why the algorithm is an iterative process.
Choosing the Final Output
After T iterations, gradient descent needs a rule for selecting its output from the sequence of vectors. The algorithm can return the average vector, the last vector, or the best-performing vector.
| Output choice | What it returns | Source note |
|---|---|---|
| Average vector | The average of the vectors produced during the iterations | Especially useful when gradient descent is extended to nondifferentiable functions and to the stochastic case |
| Last vector | The vector produced by the final update | Uses the end of the update sequence |
| Best-performing vector | The vector selected as the best performer during the process | Selects from the vectors produced during the iterations |
The final output choice is part of how the algorithm is defined, not merely a formatting step after the updates.
Mistakes in Direction and Output
Common mistake Moving in the same direction as the gradient
What it looks likeAdding the scaled gradient to the current vector
Why it failsThe gradient points toward the greatest local increase, while gradient descent uses the opposite direction.
Do this insteadSubtract the scaled gradient from the current vector.
Common mistake Treating the gradient as the step size
What it looks likeIgnoring η and using the gradient without scaling
Why it failsThe gradient supplies the direction, while the positive parameter η scales the movement.
Do this insteadFirst scale the gradient with η, then subtract the resulting movement.
Common mistake Evaluating the gradient only at the initial vector
What it looks likeUsing the first gradient for every later update
Why it failsEach newly produced vector becomes the current point for the next gradient evaluation.
Do this insteadRe-evaluate the gradient at the current vector on every iteration.
Common mistake Assuming the final output must be the last vector
What it looks likeDiscarding the average and best-performing output choices
Why it failsThe algorithm can return an average vector, the last vector, or the best-performing vector.
Do this insteadChoose the output rule that is part of the algorithm's definition.
Check Your Understanding
A current vector is [12]. The gradient at that vector is [4], and η is 0.25. Determine the scaled movement and the next vector. Then state which vector becomes the current vector for the next iteration.
Hints
- Multiply η by the gradient to find the scaled movement.
- Subtract the scaled movement from the current vector.
- The newly produced vector becomes the current vector for the next iteration.
- 1The gradient identifies the direction in which a differentiable function increases fastest around the current vector.
- 2Gradient descent reverses the gradient direction because it is used to reduce the function value.
- 3The positive parameter η scales the movement before subtraction produces the next vector.
- 4Each next vector becomes the current vector for the following iteration, creating a sequence of vectors.
- 5After the iterations, the algorithm can return an average vector, the last vector, or the best-performing vector.
Key Takeaways
- The gradient points toward the fastest local increase of a differentiable function.
- Gradient descent moves opposite to that direction by subtracting a scaled gradient.
- The current vector, gradient, positive parameter η, and subtraction operation each have a distinct role in the update.
- The updated vector becomes the current point for the next iteration.
- The final output may be the average vector, the last vector, or the best-performing vector.