Equationpedia

Gradient Descent

Gradient descent tries to lower a function by repeatedly changing its inputs. The gradient points toward the steepest local increase, so the update moves in the opposite direction. The learning rate controls how far it moves.

Next point
Slope-based step
xt+1=xt−ηf′(xt)\htmlData{region=scalar-next}{\htmlData{term=scalar-parameter}{x}_{\htmlData{term=iteration}{t}+1}} = \htmlData{term=scalar-parameter}{x}_{\htmlData{term=iteration}{t}} - \htmlData{region=scalar-step}{\htmlData{term=learning-rate}{\eta} \htmlData{term=objective}{f}'(\htmlData{term=scalar-parameter}{x}_{\htmlData{term=iteration}{t}})}

Notes

Take a downhill step

Choose a starting point θ0\boldsymbol{\theta}_0 and a positive learning rate η\eta. At step tt, evaluate the gradient of the objective ff at the current point. The gradient contains one partial derivative per parameter. Subtracting the scaled gradient uses those slopes to propose the next point. Open Downhill step and identify which part gives the direction and which part controls distance.

Try the same slope with different step sizes

Switch to One-dimensional update and use f(x)=x2f(x)=x^2 with x0=4x_0=4. The derivative is 2x2x, so the update is xt+1=(1−2η)xtx_{t+1}=(1-2\eta)x_t. With η=1/4\eta=1/4, the first two steps go from 44 to 22 to 11. With η=3/4\eta=3/4, the first two steps go from 44 to −2-2 to 11. The second route crosses the minimum on every step, and both routes halve the distance to it.

Now try η=1\eta=1. The points alternate between 44 and −4-4, and the objective stays at 1616. A direction that points downhill at the starting point can still lead to a poor result when you take a large step.

Compute the gradient from a sample

For an objective that averages losses over a dataset, the full gradient uses every example. The Single-example stochastic update picks one example and uses its gradient instead. With uniform sampling, the average of these possible gradients at a fixed point equals the full gradient. Individual steps can move the full objective up or down. The amount of work saved per step depends on the cost of evaluating each example.

Sources

Merch

Creating your shirt…