Models and training

Training batch

stable definition
Machine-readable Download Markdown

Definition

A training batch is a group of examples evaluated together to estimate the gradient used by an optimizer. Full-batch gradient descent uses the entire training set for one estimate. Stochastic gradient descent in its strict sense uses one example. Most neural-network training uses a mini-batch between those extremes.

Batch size affects several systems at once. Larger batches use more memory and usually reduce the variance of the gradient estimate, but they also produce fewer optimizer updates per pass through a fixed dataset. Small batches provide noisier estimates and more frequent updates. Neither is automatically better; learning rate, optimizer, data order, model architecture, and hardware all interact with the choice.

Distributed training introduces several related sizes. A microbatch is the group that fits through one device at a time. Gradient accumulation combines several microbatches before an update. The global or effective batch size counts all examples contributing to that update across devices and accumulation steps.

Distinguish it from nearby terms

An epoch covers the training dataset once in aggregate. A batch is one group within that pass. An inference batch also groups examples for efficient execution, but it does not estimate a training gradient or trigger an optimizer update.

Check your understanding

A dataset has 10,000 examples. Eight workers each process 16 examples, and gradients accumulate for four rounds before an update. What is the microbatch size, the global batch per round, and the effective batch per optimizer step?