Gradient descent
Gradient descent is the basic method used to train most machine learning models: repeatedly nudge the model's parameters a small step in the direction that most reduces its error.
Imagine walking down a mountain in thick fog. You cannot see the valley, only the slope under your feet, so you take a step in whichever direction goes downhill most steeply, then check again. Gradient descent does the same thing with a model's error. The error, or loss, depends on the model's parameters; the gradient says which way is uphill; and each training step moves the parameters a little way downhill.
Each step has three parts. The model makes predictions on some training data and the loss is measured. The gradient of the loss with respect to every parameter is calculated, in neural networks by backpropagation. Then every parameter is moved against its gradient by an amount set by the learning rate. Google's machine learning glossary calls the product of the learning rate and the gradient the gradient step. Repeat this thousands or millions of times and the loss falls.
The idea is far older than machine learning. Augustin-Louis Cauchy is generally credited with proposing it in 1847, Jacques Hadamard proposed a similar method independently in 1907, and Haskell Curry first studied its convergence for nonlinear problems in 1944.
Modern training rarely computes the gradient over a whole dataset at once. Stochastic gradient descent estimates it from a single example or, more commonly, a mini-batch, which Google's glossary puts at typically 10 to 1,000 examples. Optimisers such as Adam add refinements such as adapting the step size for each parameter, but they are still variations on the same downhill walk.
Gradient descent has limits. Steps that are too large overshoot and can diverge; steps that are too small make training slow. On complicated loss surfaces it can stall at a local minimum or slow down near a saddle point, although for the special class of convex problems every local minimum is also the global one. When news reports say a model learned from data, gradient descent is almost always the mechanism.
It is a step-by-step way of reducing a model's error. At each step the method works out which small change to the model's parameters would reduce the error most, makes that change, and repeats until the error stops falling. Plain gradient descent calculates the gradient using the whole training set before each step. Stochastic gradient descent estimates it from one example or a small random batch, which is far cheaper per step and is what large models use in practice. No. It finds a point where the error stops decreasing locally, which may not be the best possible. For convex problems any such point is the global best, but neural network training is not convex. Augustin-Louis Cauchy is generally credited with first proposing it in 1847. Jacques Hadamard independently proposed a similar method in 1907.Common questions
What is gradient descent in simple terms?
What is the difference between gradient descent and stochastic gradient descent?
Does gradient descent always find the best solution?
Who invented gradient descent?
Search for "gradient descent explained", "stochastic gradient descent" or "gradient descent learning rate" to learn more. Google's Machine Learning Crash Course has an interactive treatment, and maths and optimisation references cover the theory. Framework documentation for PyTorch and TensorFlow shows how optimisers built on gradient descent are used in practice.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.