Skip to content
ContentLora

    Tip: press / anywhere to search.

    Explainer

    How gradient descent works: how AI models learn from their mistakes

    Gradient descent is the standard technique for training machine learning models: it repeatedly measures how wrong the model is and nudges the model's numbers a small step in the direction that reduces the error.[1][2] The size of each step is set by the learning rate; too small and training crawls, too large and it never settles.[3] In neural networks, backpropagation computes the direction for every weight, and optimisers such as Adam adapt the steps as training goes.[4][5]

    Editor reviewedUpdated Explainer20 claims · 10% primaryMachine learning foundations, Artificial intelligence
    Reading level: 3 passages differ; the rest is the same for everyone.

    This page is part of our machine learning foundations series. It assumes the idea of a gradient from linear algebra for machine learning and the basic picture in how machine learning works. The next step, loss functions, explains what exactly is being minimised.

    Training a model means finding the values of its parameters, the weights and biases, that make its predictions as good as possible. Gradient descent is the standard technique: it iteratively finds the weights and bias that produce the lowest loss, the measure of how wrong the model is.[6] It is not a new idea. Google’s machine learning glossary notes that gradient descent is much, much older than machine learning.[7]

    The blindfolded hiker

    Stanford’s CS231n course offers a picture to keep in mind: you are hiking blindfolded on hilly ground and want to reach the bottom of the valley. You can’t see the map, but you can feel the slope under your feet, so you step in the direction that feels steepest downhill, and repeat.[8]

    In this picture, your position is the model’s settings and your height is the error. Gradient descent starts with random settings near zero, checks which direction lowers the error, moves a small amount that way, and repeats until it can’t get any lower.[2]

    The gradient of a function is the vector of its partial derivatives and points in the direction of steepest ascent.[9] Gradient descent initialises the parameters near zero, computes the gradient of the loss with respect to them, moves a small amount against it, and repeats until the loss stops falling.[2] CS231n compares following the gradient to a blindfolded hiker feeling for the steepest slope.[8]

    Step size: the learning rate

    How far to move on each step is set by the learning rate. The model multiplies the gradient by the learning rate to get its next parameter values.[3] Getting it right matters. If the learning rate is too low, the model can take a long time to converge; if it is too high, the model never converges and instead bounces around the best weights.[3] CS231n calls the step size one of the most important, and most headache-inducing, settings in training a neural network.[10]

    The learning rate is a hyperparameter: a value people choose to control training. The weights and biases, by contrast, are parameters that the model calculates during training.[11]

    Batches and epochs

    A big dataset may hold millions of examples, and checking all of them before every small step would be slow. So in practice models estimate the slope from a sample. Stochastic gradient descent uses just one example per step, which works given enough steps but is very noisy. Mini-batch gradient descent, the usual compromise, uses a small batch of examples per step.[12]

    One full pass through all the training data is called an epoch. With 1,000 examples, batches of 100 and 20 epochs, the model updates its weights 200 times.[13]

    Computing the full loss over the whole training set for a single update is wasteful at scale, so the gradient is estimated over batches.[12] Pure stochastic gradient descent uses a batch size of one and is noisy; mini-batch SGD uses a batch size between one and the dataset size.[12] An epoch is one pass over every training example, so the number of updates is the number of epochs times the dataset size divided by the batch size.[13]

    When training stops: convergence and bumpy landscapes

    A model has converged when the loss changes very little or not at all with each step, so more training won’t improve it.[14] Watching the loss fall over time on a loss curve is how practitioners see this happen.[15]

    For simple linear models, the loss landscape is a smooth bowl: it is always convex.[16] Neural networks are different. Their loss landscapes are non-convex, which CS231n describes as complex, bumpy terrain rather than a bowl.[16] Researchers writing in 2016 and 2019 said that why large networks trained this way still generalize well was not well explained; see overfitting and generalization.[17][18]

    Backpropagation and Adam

    Large neural networks can have more than a trillion parameters,[19] and gradient descent needs to know which way to nudge each one. Backpropagation is the algorithm that works this out: it runs the network forward to make a prediction, then passes backward through the network to work out the gradient for every weight.[4] It is what makes gradient descent practical for networks with many layers.[20]

    Adam, an optimiser published in 2015, refines gradient descent by adapting its steps using running estimates of the gradients.[5]

    Backpropagation implements gradient descent in neural networks through repeated forward and backward passes, computing the gradient of the loss with respect to every weight.[4][20] Adam, published at ICLR 2015, is a first-order gradient-based optimiser built on adaptive estimates of lower-order moments of the gradients; its authors describe it as computationally efficient, light on memory and suited to problems with large data or many parameters.[5] See how neural networks work for the network side.

    This page describes the core idea. Real training runs add many refinements, such as learning-rate schedules and other optimisers, that we do not cover here.

    Next in the crash course

    Questions readers ask

    What is gradient descent in simple terms?

    A way of finding the model settings with the lowest error. Start from random settings, work out which direction lowers the error, take a small step that way, and repeat until the error stops falling.[6][2]

    What is the learning rate?

    A number set before training that scales each step. If it is too low, training can take a long time to converge; if it is too high, the model never converges and bounces around the best settings.[3]

    What is stochastic gradient descent?

    Instead of measuring the error on every training example before each step, stochastic gradient descent uses one example per step, which works but is noisy. Mini-batch gradient descent, a compromise, uses a small batch of examples per step.[12]

    What is an epoch?

    One full pass through the training data. With 1,000 examples, a batch size of 100 and 20 epochs, the model updates its weights 200 times.[13]

    How is backpropagation related to gradient descent?

    Backpropagation is the algorithm that implements gradient descent in neural networks. It makes gradient descent practical for networks with many layers.[4][20]

    Sources

    · 20 claims from 6 publishers

    Each numbered claim is a statement we checked against the sources listed with it. Tap a number in the text to see its sources in place.

    1. [1]

      Gradient descent is the mathematical technique that repeatedly adjusts a model's weights and bias to find the combination with the lowest loss. reportedas of 2026-11-07

    2. [2]

      In gradient descent, training starts with random weights and biases near zero; the model then repeatedly works out which direction to move the weights to reduce the loss, moves them a small amount in that direction, and repeats until it cannot reduce the loss further. reportedas of 2026-11-22

    3. [3]

      The learning rate is a number set before training that controls how big each gradient-descent step is; the model multiplies the gradient by it, and if it is too low the model can take a long time to converge, while if it is too high the model never converges and bounces around the best weights. reportedas of 2026-11-22

    4. [4]

      Backpropagation is the algorithm that implements gradient descent in neural networks; training repeats a two-pass cycle of a forward pass and a backward pass. reportedas of 2026-11-22

    5. [5]

      The Adam optimiser, published at the 2015 International Conference on Learning Representations, is an algorithm for first-order gradient-based optimisation based on adaptive estimates of lower-order moments; its authors describe it as computationally efficient, light on memory and suited to problems with large data or many parameters. reportedas of 2026-11-22

    6. [6]

      Google's course describes gradient descent as a mathematical technique that iteratively finds the weights and bias producing the lowest loss, repeating a fixed cycle for a number of user-defined iterations. reportedas of 2026-11-22

    7. [7]

      Google's glossary notes that gradient descent is much older than machine learning. reportedas of 2026-11-22

    8. [8]

      Stanford's CS231n notes compare optimisation to hiking blindfolded on hilly terrain and trying to reach the bottom, feeling the slope underfoot and stepping in the direction that feels steepest. reportedas of 2026-11-22

    9. [9]

      Google's machine learning glossary defines the gradient as the vector of partial derivatives with respect to all the independent variables, and says it points in the direction of steepest ascent. reportedas of 2026-11-22

    10. [10]

      Stanford's CS231n notes call the step size, also known as the learning rate, one of the most important and most headache-inducing hyperparameter settings in training a neural network. reportedas of 2026-11-22

    11. [11]

      Hyperparameters, such as the learning rate, batch size and number of epochs, are values people set to control training, whereas parameters such as the weights and bias are part of the model and are calculated during training. reportedas of 2026-11-22

    12. [12]

      Instead of computing the loss over every example before each update, stochastic gradient descent uses a single example per step, which works given enough iterations but is very noisy, while mini-batch stochastic gradient descent uses a batch larger than one but smaller than the whole dataset as a compromise. confirmedas of 2026-11-22

    13. [13]

      An epoch means the model has processed every training example once; with 1,000 examples, a batch size of 100 and 20 epochs, the model updates its weights and bias 200 times. reportedas of 2026-11-22

    14. [14]

      A model has converged when the loss changes very little or not at all with each iteration, so additional training won't improve it. reportedas of 2026-11-22

    15. [15]

      A loss curve plots loss against the number of training iterations and helps show whether a model is converging or overfitting. reportedas of 2026-11-22

    16. [16]

      The loss functions of linear models always produce a convex, bowl-shaped surface, but once the model is a neural network the objective becomes non-convex, a bumpy terrain rather than a bowl. reportedas of 2026-11-22

    17. [17]

      The authors of that paper wrote that conventional explanations, properties of the model family or regularisation, fail to explain why large neural networks generalize well in practice. reportedas of 2026-11-22

    18. [18]

      The PNAS authors wrote that breakthroughs in machine learning are rapidly changing science and society while fundamental understanding of the technology has lagged far behind. confirmedas of 2026-11-22

    19. [19]

      Today's artificial neural networks are often enormous and built from many layers; these are called deep neural networks, and training them is called deep learning. Large language models can contain more than one trillion parameters. confirmedas of 2024-10-08

    20. [20]

      Backpropagation is the most common training algorithm for neural networks; it makes gradient descent feasible for networks with many layers, and machine learning libraries usually handle it automatically. reportedas of 2026-11-07

    Revision history (1)
    1. Page created.

    Created Nov 22, 2026. Last reviewed by an editor on Nov 22, 2026. Next scheduled review: Jun 21, 2027.

    Cite this page

    "How gradient descent works: how AI models learn from their mistakes." ContentLora, updated Nov 22, 2026. https://contentlora.com/explain/how-gradient-descent-works

    Spotted an error? Suggest a correction or emailcorrections@contentlora.com.