# Batch size

> Canonical: https://skillalmanac.com/glossary/batch-size | Last verified: 2026-11-25 | Index status: index-eligible

In machine-learning training, batch size is the number of examples used in one training iteration before a parameter update; it may be one, a subset, or the full training set.

## In plain language

Training can calculate an update from one example, from a smaller group called a mini-batch, or from the full training set. Batch size is the number of examples included in that calculation. Smaller groups produce more updates while processing a dataset; full-batch training uses all examples for one update. Batch size is a hyperparameter chosen for the training procedure, not a value learned by the model. It is distinct from an epoch, statistical sample size and an API batch of requests.

## Technical definition

Google defines a batch as the examples used in one training iteration and batch size as the number of examples in that batch. A size of 1 corresponds to stochastic gradient descent; full-batch training uses the entire training set; mini-batch training uses a subset. Stanford's CS231n material illustrates computing a gradient over a sampled mini-batch and then performing a parameter update. For a training set containing N examples and batch size B, the number of batches needed to cover one epoch is ceil(N / B) when the final partial batch is retained. Here the denominator is B, the number of examples per batch; data-loader choices can instead discard a partial final batch.

## How it shows up when you use agents

This entry uses the machine-learning training sense of batch size. A batch is the set of examples used in one training iteration, and batch size is the number of examples in that set. An agent may encounter the setting while explaining a training configuration, reviewing a training loop or diagnosing why the expected number of updates does not match the dataset size.

The setting covers three cases. A batch size of one uses one example for an update and corresponds to stochastic gradient descent in Google's glossary. A mini-batch uses a subset of the training data. Full-batch training uses the entire training set for an update. For N training examples and a batch size B, covering the data takes ceil(N / B) batches when a final partial batch is retained. In that formula, the denominator B is explicitly the number of examples per batch. A training pipeline may instead discard the final partial batch, so inspect that choice before reconciling counts.

A useful reader action is to write down the training-set size, configured batch size and treatment of the final partial batch, then compare the expected count with the training log. The sample-size-calculator skill is an illustrative catalogue contrast: it estimates subjects per group for specified statistical study designs. It does not choose or benchmark a training batch size.

## Common confusions

**Batch size versus epoch.** Batch size counts examples per training iteration. An [epoch](/glossary/epoch) is one pass over the training set. Several batches usually make up an epoch.

**Mini-batch versus batch size.** A mini-batch is a subset used for an update. Batch size is the count of examples in whichever batch strategy is used.

**Batch size versus sample size.** Statistical sample size concerns the observations collected for a study or dataset. Training batch size partitions available training examples for parameter updates.

**Training batch versus API batch.** An API may group independent requests for scheduling or processing. That operational use of “batch” is not the optimizer setting defined here.

**One universally correct value.** Batch size is a hyperparameter. The supplied sources define the strategies and show mini-batch updates, but they do not establish one value that is best across models, datasets or hardware.

## Worked examples in this catalogue

### [sample-size-calculator](https://skillalmanac.com/skills/skill-almanac/sample-size-calculator)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Illustrative contrast: calculate the planned number of subjects per group for specified statistical designs, effect sizes, alpha and power assumptions.

Why it exercises the concept: This clarifies a frequent terminology error: study sample size concerns how much data to collect, while training batch size concerns how many existing examples contribute to one update. The skill does not select or test an optimizer batch size.

## Related terms

- [Gradient descent](https://skillalmanac.com/glossary/gradient-descent.md)
- [Stochastic gradient descent (SGD)](https://skillalmanac.com/glossary/stochastic-gradient-descent.md)
- [Hyperparameter](https://skillalmanac.com/glossary/hyperparameter.md)
- [Epoch (machine learning)](https://skillalmanac.com/glossary/epoch.md)
- [Loss function](https://skillalmanac.com/glossary/loss-function.md)
- [Machine learning (ML)](https://skillalmanac.com/glossary/machine-learning.md)

## Sources

- [Machine Learning Glossary](https://developers.google.com/machine-learning/glossary#batch-size), Google for Developers (accessed 2026-11-25)
- [CS231n Convolutional Neural Networks for Visual Recognition: Optimization](https://cs231n.github.io/optimization-1/), Stanford University (accessed 2026-11-25)
- [What is gradient descent?](https://www.ibm.com/think/topics/gradient-descent), IBM (accessed 2026-11-25)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
