# Gradient descent

> Canonical: https://skillalmanac.com/glossary/gradient-descent | Last verified: 2026-11-24 | Index status: index-eligible

Gradient descent iteratively updates parameters in the opposite direction of an objective's gradient, scaled by a learning rate. Step size and stopping rules affect the result; the method does not generally guarantee a global minimum.

Also called: gradient descent algorithm, batch gradient descent.

## In plain language

Gradient descent is how many models learn. Picture walking down a foggy hill by feeling which way the ground slopes under your feet and taking a step downhill, again and again. The height is the model's error, and each step nudges the model's settings to reduce it. The size of the step matters: too large and you can overshoot the bottom, too small and training takes a long time. IBM notes the walk can also settle in a dip that is not the lowest point. Training with it uses computing time, which is a cost when models are large. A fixed-weight inference request need not perform gradient descent; an application can separately invoke optimization or training.

## Technical definition

Gradient descent minimizes a loss function over model parameters. At each step it computes the gradient, the vector of slopes of the loss with respect to the parameters, and moves the parameters a small step in the negative gradient direction. The step size is the learning rate, which Stanford's CS231n notes call one of the most important hyperparameters to tune. Backpropagation is a common way to compute neural-network gradients. Stochastic gradient descent uses one example, per Google's glossary, and, per CS231n, mini-batch computes the gradient over batches of the training data; CS231n notes that people often say SGD when they mean mini-batch. IBM notes that on non-convex problems it can stop at a local minimum.

## How it shows up when you use agents

Gradient descent can appear when you or an agent write optimization or training code, for example with PyTorch or scikit-learn, and in the settings and logs of that code: the learning rate, the batch size and a loss value printed each step.

Reading those logs is the practical skill. A loss that falls steadily suggests the steps are suitable. A loss that jumps or rises can mean the learning rate is too high, which is a [hyperparameter](/glossary/hyperparameter) you choose. The loss itself is defined by the [loss function](/glossary/loss-function), and in a [neural network](/glossary/neural-network) the gradient comes from [backpropagation](/glossary/backpropagation).

What breaks when it is misunderstood: people treat a falling training loss as proof the model is good. Compare it with loss on held-out data, and check the split with [split-leakage-check](/skills/skill-almanac/split-leakage-check). A next action when a run behaves badly is to change one setting, usually the learning rate, and rerun with the same data so you can see the effect. Large runs cost compute time, so test on a small slice first.

## Worked example (illustrative)

For the toy objective f(w)=w², start at w=1, whose gradient is 2. A learning rate of 1.5 gives w_new=1−1.5×2=−2, so the objective rises from 1 to 4. The computed step follows the negative gradient yet overshoots. This is an arithmetic counterexample to guaranteed improvement at any step size, not a training benchmark.

## Common confusions

- **Gradient descent versus backpropagation.** Backpropagation computes the gradient in a neural network. Gradient descent uses the gradient to update the parameters. See [Backpropagation](/glossary/backpropagation).
- **Batch versus stochastic versus mini-batch.** They differ in how many examples are used per update: all, one, or a small group. Many people say SGD for mini-batch, as CS231n notes.
- **Gradient descent versus loss function.** The loss function measures error. Gradient descent uses its gradient to propose parameter updates; step size affects whether a finite update lowers it. See [Loss function](/glossary/loss-function).
- **Myth.** Gradient descent finds the best possible model. IBM notes it can stop in a local minimum that is not the lowest point, especially on non-convex problems.

## Worked examples in this catalogue

### [math-step-checker](https://skillalmanac.com/skills/skill-almanac/math-step-checker)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A learner's own worked arithmetic or algebra checked line by line with a script that re-evaluates every step exactly and finds the first step that breaks.

Why it exercises the concept: One gradient descent update is arithmetic: a gradient, a learning rate and a subtraction. Working a few steps by hand and checking each line is a way to see the method move.

### [split-leakage-check](https://skillalmanac.com/skills/skill-almanac/split-leakage-check)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A check of train, validation and test files for duplicates, shared groups, time and label leakage, printed as JSON.

Why it exercises the concept: Gradient descent proposes objective-reducing updates, but a finite step can raise loss. This linked skill checks evaluation splits rather than the optimizer.

### [Claude Code](https://skillalmanac.com/tools/claude-code)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Claude Code's overview page describes it as an agentic coding tool that reads your codebase, edits files and runs commands.

Why it exercises the concept: An agent can write a short optimization loop so you can inspect how loss responds to the step size. Loss need not fall at every step.

## Related terms

- [Backpropagation](https://skillalmanac.com/glossary/backpropagation.md)
- [Loss function](https://skillalmanac.com/glossary/loss-function.md)
- [Neural network](https://skillalmanac.com/glossary/neural-network.md)
- [Machine learning (ML)](https://skillalmanac.com/glossary/machine-learning.md)
- [Hyperparameter](https://skillalmanac.com/glossary/hyperparameter.md)
- [Deep learning](https://skillalmanac.com/glossary/deep-learning.md)

## Sources

- [What is gradient descent?](https://www.ibm.com/think/topics/gradient-descent), IBM (accessed 2026-11-24)
- [CS231n Convolutional Neural Networks for Visual Recognition: Optimization](https://cs231n.github.io/optimization-1/), Stanford University (accessed 2026-11-24)
- [Machine Learning Glossary: gradient descent](https://developers.google.com/machine-learning/glossary#gradient-descent), Google for Developers (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
