Skip to content
IT glossary
Data and MLUpdated December 3, 2026

Gradient descent

Градиентный спуск

Gradient descent is a way to minimize a function by repeatedly moving its parameters opposite to the gradient. In machine learning, it helps find model parameters that give a lower training loss.

What gradient descent does

A loss function gives a model's predictions a numerical score: lower is better. Training means finding weights that make that score small on the training data. Gradient descent starts with an initial set of weights and uses the slope of the loss at the current weights to decide where to go next. It repeats this process because the slope changes as the weights move.

How the update works

For weights w and objective L, the update is w ← w − η · ∇L(w). The gradient ∇L(w) is a vector of partial derivatives, one per weight. It points in the direction of steepest local increase, so the minus sign makes the update go downhill. The positive multiplier η is the learning rate. It scales the gradient rather than setting a fixed travel distance: with the same learning rate, a larger gradient produces a larger step.

A one-weight example

Take L(w) = (w − 4)². Its derivative is 2(w − 4). Starting at w = 0 with a learning rate of 0.25, the derivative is −8, so the update moves the weight to 0 − 0.25 × (−8) = 2. At w = 2, the derivative is −4, so the next update moves it to 3. The loss drops from 16 to 4 to 1. Here the steps get smaller because the slope gets flatter near the minimum, not because the learning rate changes.

Full batches, single examples, and mini-batches

Full-batch gradient descent computes each update using the entire training set. Stochastic gradient descent (SGD), in the strict sense, uses one randomly sampled example per update. Mini-batch training uses a small group of examples, which makes updates cheaper than a full pass and lets hardware process examples together. In practice, a library's SGD optimizer is often used with mini-batches. This approach is common in neural network training, where backpropagation computes the gradients and the optimizer applies the update.

What to watch for in an interview

Be ready to work through one update by hand and explain what happens if the learning rate changes. A rate that's too small can make progress slow; one that's too large can overshoot a minimum repeatedly or cause the loss to diverge. A single increase in mini-batch loss doesn't tell you much, since different batches contain different examples. Also distinguish a stationary point from a minimum: a zero gradient means the basic update makes no move, but that can happen at a saddle point or a maximum as well as at a minimum.