Gradient descent is a first-order iterative optimisation algorithm that finds the parameters that minimise a function, which in machine learning is usually the cost or loss function. Each step moves the parameters a small amount in the direction that reduces loss, and the process repeats until loss stops falling.
This page is for practitioners and technical leaders who want to understand how models learn. It covers the steps, the learning rate, batch and stochastic variants, how it differs from related methods, and the practical checks that matter.
The Google Machine Learning Crash Course describes gradient descent as a technique that iteratively finds the weights and bias that produce the model with the lowest loss. It starts with values near zero, computes the loss, determines which direction lowers it, and moves the weight and bias a small amount in that direction. The process repeats until the model cannot reduce the loss any further.
The size of each move is the learning rate, a setting chosen by the practitioner. The Google course notes that a model has converged when additional iterations no longer reduce loss meaningfully. Too large a step can overshoot, and too small a step makes training slow, so the rate is tuned and loss is watched during training.
Variants are distinguished by how much data each step uses. Full batch gradient descent uses the whole dataset at once to compute the gradient, whereas stochastic gradient descent takes a sample while computing it. The scikit-learn stochastic gradient descent guide describes stochastic gradient descent as approximating the true gradient by considering a single training example at a time, and calls it an efficient way to fit linear classifiers and regressors under convex loss functions. It is only a way to train a model, not a model family.
| Variant | Data used per step | Trade-off |
|---|---|---|
| Full batch | The whole training set | Smooth steps, but costly on large data |
| Stochastic | One example or a small sample | Cheap steps, but noisier progress |
| Mini-batch | A small group of examples | A common middle ground between the two |
The scikit-learn guide lists efficiency and ease of implementation as advantages. Its listed drawbacks are the need for hyperparameters such as the regularisation strength and number of iterations, and sensitivity to feature scaling. It recommends standardising features, for example with a scaling step in a pipeline fitted on training data only.
| Method | Uses | Typical consequence |
|---|---|---|
| First order (gradient descent) | The gradient only | Cheap per step, needs a tuned learning rate |
| Second order | The gradient and curvature information | Costlier per step, can take fewer steps |
Gradient descent is a first order method because it relies on the first derivative alone. Second order approaches add curvature information, which can reduce the number of steps but raises the cost of each one.
AI agents call machine learning models to reason and act, so teams that build and run agents benefit from knowing what a model's training run optimised for and how it was evaluated. Platforms such as ElixirClaw, XenonStack's AI agents computing platform, sit around the models that agents rely on.
To map one decision your agents make, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.
It is a way of improving a model step by step. At each step the parameters move slightly in the direction that lowers the loss, until the loss stops falling.
The learning rate sets how far the parameters move at each step. Too large a value can overshoot the minimum, and too small a value makes training slow.
Batch gradient descent uses the whole dataset to compute each gradient. Stochastic gradient descent uses a single example or a small sample, which makes each step cheaper but noisier.
Stochastic gradient descent is sensitive to feature scaling, so features should be standardised before training, with the scaler fitted on training data only.
Convergence is reached when further iterations no longer reduce the loss meaningfully. Train until the loss stabilises to confirm it.