the.ai

Optimization / Training

verified

Stochastic Gradient Descent

Computing the gradient over the whole dataset for every step is unaffordable. Stochastic gradient descent estimates it from a small random batch instead — noisier, but hundreds of times cheaper, so it takes many more steps in the same wall-clock time and gets further.

Viz primitive · loss-curvesteps = 1000 · batch = 32
loss
step 01000

Loss over 1000 training steps, starting near 6.0. It falls to about 2.11, with 87% of the total improvement arriving in the first half.

Loss over steps with gradient noise from a finite batch. Drag the batch size to watch the trajectory smooth out while each step costs more.

32

Reviewed by opendroid · 2026-08-04