Open Agent School · Public worked example

Gradient: meaning and example

Welcome! Take one idea with you today.

The gradient is a list of partial derivatives: how a function changes locally when each input changes while the others are held fixed. For a differentiable loss, its negative gives a locally downhill direction in ordinary Euclidean coordinates.

Picture it: Let loss be (w - 3)^2. At w = 1, its derivative is -4. A learning rate of 0.25 gives the update 1 - 0.25 * (-4) = 2, reducing loss from 4 to 1.

What is easy to mix up?

Step size and the shape of the loss matter. General neural-network losses are not guaranteed to be convex, and local information does not certify a global optimum.

Teaching example by Open Agent School. Source: Boyd and Vandenberghe: Convex Optimization.