Skip to content
StackDecode
AI & ML Atlas
Machine LearningNeural NetworksoptimiserInteractive simulation

Mini-Batch Gradient Descent

Gradient descent on small random batches: the practical middle ground.

The idea

Each update averages the gradient over a batch (for example 32 or 256 examples). Batches are less noisy than single samples and run efficiently on GPUs, but update far more often than full-batch descent. This is what "SGD" usually means in deep learning.

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

  • current weights
  • minimum
  • last update

Start somewhere on the bowl. Rings are lines of equal loss; the minimum is at the centre.

step:
0
loss:
3.4617
1/61

Loss landscape seen from above: a long narrow valley. Final loss 0.0275.

Step by step

  1. 1Shuffle and split the data into batches.
  2. 2For each batch compute the average gradient.
  3. 3Update the parameters.
  4. 4Pass over all batches (an epoch) and repeat.

Where it is used

Nearly all neural network training.

Watch out for

Batch size interacts with the learning rate; very large batches can generalise worse.

Related