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

Stochastic Gradient Descent

Gradient descent using one random example at a time.

The idea

Instead of the full dataset, each update uses one randomly chosen sample. Each step is a noisy but cheap estimate of the true gradient. The noise makes the path jittery but can help escape shallow local minima, and updates happen far more often.

θ ← θ − η·∇L(θ; xᵢ, yᵢ)

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.2662.

Step by step

  1. 1Shuffle the training data.
  2. 2Take one example and compute its gradient.
  3. 3Update the parameters with that gradient.
  4. 4Go through all examples (an epoch), then repeat.

Where it is used

Large datasets and online learning.

Watch out for

Noisy convergence: the learning rate usually needs to decay.

Related