What is stochastic gradient descent?

Stochastic gradient descent is an optimisation method that estimates the loss gradient from one randomly chosen example or a small mini-batch rather than all training data and updates parameters at each step from that estimate.

It is also called SGD. It differs from gradient descent in how much data each step uses: gradient descent computes the full gradient on all data, while SGD makes a noisy but far cheaper estimate from a small sample. Adaptive optimisers such as Adam build on SGD.

Topic
Machine learning, models and training
Also known as
SGD, mini-batch gradient descent
Origin
1951, Robbins and Monro, stochastic approximation

How stochastic gradient descent works

  1. Training data is shuffled and split into mini-batches; each step takes one mini-batch.
  2. Loss and gradients are computed on the mini-batch with backpropagation.
  3. Parameters move against the gradient times the learning rate; a step completes without visiting all data.
  4. Momentum accumulates the direction of past steps to reduce oscillation; one full pass over the data is one epoch.

In more detail

The linear learning rate scaling rule

In multi-GPU training, growing the global batch size usually calls for raising the learning rate in proportion (the linear scaling rule). The rule is applied together with warmup and may not hold on its own at very large batch sizes.

The Robbins and Monro conditions and Nesterov momentum

Because mini-batch sampling adds gradient variance, SGD can oscillate in narrow valleys; classical convergence theory for convex problems requires a step size that decays under the Robbins and Monro conditions. Nesterov momentum evaluates the gradient at the look-ahead point momentum predicts, often damping oscillation better than standard momentum.

Commonly confused terms

TermHow it differs
Adam optimiserSGD uses a single global learning rate across all parameters (optionally with momentum), while Adam maintains per-parameter adaptive first and second gradient moments alongside decoupled weight decay in AdamW.
Gradient accumulationGradient accumulation sums gradients over several micro-batches in memory before applying a single SGD or Adam parameter update, simulating a larger effective batch size without extra activation VRAM.

Why stochastic gradient descent matters for on-premises AI

Large datasets do not fit in GPU memory at once; SGD makes training possible by splitting it into mini-batches and keeping each step cheap. In in-house training batch size, learning rate and momentum are tuned together: larger batches mean fewer steps but more memory. Update noise looks like a drawback but can help the model escape poor regions and generalise better. Momentum SGD remains common for CNNs, while Vision Transformers and language models mostly use Adam variants.

ON-PREMISES EXAMPLE

A public agency trains its document classification model on its own server with momentum SGD, picking the largest batch size that fits in GPU memory and tuning the learning rate to match.

Common questions

How does stochastic gradient descent differ from gradient descent?

Gradient descent computes the gradient from all data at each step. SGD uses one example or a mini-batch; it is noisier but moves much faster and is the only practical option on large data.

How does SGD differ from Adam?

SGD uses one learning rate for all parameters. Adam scales each parameter's step from its gradient history and usually converges faster with less tuning.

Sources

In the glossary: Glossary, R to Z

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.