/ THE IDEA
Each example produces a prediction and a loss, meaning a numerical error score. A gradient measures how that loss responds to tiny changes in the model's adjustable numbers. For a typical mini-batch update, the gradients from the chosen examples are averaged. The update follows that average rather than any one example's preference. Random sampling helps the batch represent the broader collection. Shuffling and taking groups without replacement is also common. Larger batches often give a less noisy estimate, but they demand more work per update and may encounter limits in memory or hardware efficiency. Batch size and training duration therefore need to be considered together.
THE FORMAL IDEA
g_batch = (g₁ + g₂ + … + g_B) / B
| B is the number of examples in the batch. Each g is one example's sensitivity for the same adjustable model number. | | g_batch is their average. The dots mean continue adding matching quantities; the expression shows one component of a larger gradient. |
|
RUN THE TINY EXAMPLE
Change one thing. Predict what happens.
Four dimensionless toy examples have sensitivities 2, 2, −2 and −2. The full average is (2+2−2−2)/4 = 0. A two-example batch containing the first pair has average (2+2)/2 = 2. Change the sampled pair to examples one and three: average becomes (2−2)/2 = 0.
|
The model's state and the complete dataset did not change. Only the sampled evidence changed, yet the proposed update changed. A noisy training curve can therefore reflect sampling variability rather than the model repeatedly forgetting everything. Averaging several examples can reduce that variability, without guaranteeing it vanishes.
/ SO WHAT?
This also explains why the order of examples matters. If all easy cases arrive first and difficult cases last, successive batches give systematically different messages. Randomisation is a way of avoiding that accidental curriculum when it is not intended. To compare two training runs fairly, record the batch policy as well as the final model architecture.
ONE CAVEAT |
| Random batches are not automatically independent or representative: duplicated and correlated records can reduce their effective variety. Larger batches do not guarantee better final predictions, and a zero sampled gradient need not mean training is complete. |
KEEP THIS
A mini-batch update reacts to sampled evidence, so changing the sample can change the next step even when the model has not changed.
|
NEXT: Why can switching a coil off produce a voltage?
|