Batch

A batch is the group of training examples a model processes together in one training step before its weights are updated.

Training a model means repeatedly showing it examples and adjusting its weights. Updating after every single example is noisy; processing the entire dataset before each update is impractical when there are millions of examples. The usual compromise is the batch. Google's machine learning glossary defines it as the set of examples used in one training iteration: the model processes the batch, averages the error across it, makes one set of weight updates and moves on to the next batch.

Most training today uses mini-batches, small random subsets of the training data. If a dataset holds 1,000 examples and each batch holds 20, one pass through all the data, called an epoch, takes 50 steps. Choosing examples at random keeps each batch roughly representative, so the averaged gradient points in about the right direction while costing a fraction of the full calculation. The randomness also adds a little noise, which Google's course notes can help a model generalise.

Batches matter for hardware too. Accelerator chips are built to do many calculations in parallel, so processing a batch of examples at once uses them far more efficiently than one at a time. In distributed training, a batch is often split across many chips, each handling its share before the results are combined.

The word has a separate meaning at the other end of a model's life. Batch inference means running a finished model over many inputs together, often overnight, instead of answering requests live. When an AI provider advertises a batch API, that is what it means, not training.

Common questions

What is a batch in machine learning?

A batch is the set of training examples processed together in one training step. The model makes predictions for every example in the batch, averages the errors and updates its weights once, then moves to the next batch.

What is the difference between a batch and an epoch?

A batch is one slice of the training data used for one update. An epoch is one complete pass through the whole training dataset, which takes as many batches as it takes to cover every example once. With 1,000 examples and batches of 100, one epoch is ten batches.

What is a mini-batch?

A mini-batch is a small, randomly selected subset of the training data, usually between 10 and 1,000 examples in Google's description, used for one update. In practice most people say batch when they mean mini-batch, since training on the full dataset at once is rare.

What does a batch API mean for AI services?

It refers to batch inference: sending many requests to an already trained model to be processed together rather than one by one in real time. It is unrelated to the training batches used to build the model.

Finding more

Search for "batch vs epoch vs iteration", "mini-batch gradient descent" or "batch size effect on training" for clear explanations. Machine learning courses and glossaries from major providers, and the documentation of training frameworks, explain these terms consistently. For batch inference, providers' own pricing and API documentation is the authority.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.