Batches, Examples and Shuffling

3 min
Audience
ages 10–15
Duration
30 to 40 min
Adventure
1/8
Badge to earn
Mini-Batch Master

Today's mission

Simulate mini-batches and explain why their composition changes the direction of a learning step.

Proof of success: explain "Batches, examples and shuffling", complete "Gradient by the Handful" and name the limit of the analogy.

The story

In a card workshop, Louis has to learn a rule from 40 patterns. He could look at all 40 before each correction, but that takes lots of space. He picks packs of five. The first pack happens to contain only stripes; the correction it gives poorly represents the whole collection. After shuffling, the packs become more varied. Each mini-batch provides an imperfect but practical estimate of the overall correction.

What is technically true

Vocabulary is only useful if it helps you predict what will happen. Lean on these three ideas. Here, your anchor is "Batches, examples and shuffling".

  • An example is one observation; a dataset is the whole collection; a batch is the group processed during one computation.
  • A mini-batch produces a gradient estimate: small size often means more noise, large size means more memory and a different calculation.
  • Shuffling the training data reduces misleading ordered packs, except when the temporal order carries information that must be preserved.

The vertical map

This loop comes back to the mini-batches after each update: several successive estimates keep the training moving forward. Read the diagram from top to bottom: each arrow announces a transformation or a check, never a thought inside the machine.

A useful analogy — and where it breaks

The analogy: A batch is like a handful of cards drawn from a big box.

Where it breaks: Unlike the randomness of a game, the model's sampling follows a precise procedure, and some data — like a timeline — must not be shuffled blindly. An analogy helps you get started; it never replaces the data, the calculations or a test.

Screen-free activity — Gradient by the Handful

Materials: 24 red or blue cards, four batch envelopes and six tokens
Suggested time: 10 to 20 minutes.

  1. First place all the reds together, then all the blues, and form batches of four without shuffling.
  2. For each batch, move a token toward the majority color as a simulated correction.
  3. Shuffle the cards, reform the batches and repeat the moves.
  4. Compare the trajectories and calculate the overall proportion of the two colors.

What you should notice: unbalanced batches produce corrections that zigzag or favor one part of the dataset.

Optional challenge

Test batches of two, four and twelve cards; describe the trade-off between stability, number of updates and materials needed.

Safety, fairness and human choice

If a rare category disappears from many batches, it can be neglected. Inspect batch composition and never publish an individual ranking.

Responsible question: How would you form batches to keep a rare category without copying personal data?

Mini-quiz with answers

  1. Are batch and dataset synonyms?

    Answer: No. The dataset is the full collection; the batch is a group processed at a single step.

  2. Why shuffle the training cards?

    Answer: To avoid the order creating batches that are systematically different, whenever time is not a variable to preserve.

  3. Is the largest batch always the best?

    Answer: No. It can be more stable but demands more memory and does not always give the best generalization.

Competency badge

Mini-Batch Master — You earn this badge if you can explain the diagram without reading, show the result of the activity and kindly correct a wrong answer.