What is an epoch?
An epoch is a training round completed when every example in the training dataset has passed through a machine learning model once.
Unlike batch size, which sets how many examples one update step processes, an epoch counts how many times the whole dataset has been processed. On one device without gradient accumulation, steps per epoch equal dataset size divided by batch size; calculation: 10,000 examples with a batch of 100 gives 10,000 / 100 = 100 steps.
- Topic
- Machine learning, models and training
- Also known as
- Training pass
How an epoch works
- Training data is usually shuffled at the start of each epoch and split into batches.
- Each batch passes through forward and backward propagation, updating parameters by one step.
- When all batches are processed an epoch ends; performance is often measured on validation data.
- Training stops on reaching the set number of epochs or when validation performance stops improving.
In more detail
Effective batch size, gradient accumulation and multi-GPU training
In distributed training or memory-constrained GPUs, gradient accumulation collects gradients over several micro-batches before performing a single parameter update. Consequently, steps per epoch depend on the effective global batch size (the product of micro-batch size, accumulation steps and data-parallel GPU count) and pipelines must decide whether to drop or process a smaller remainder batch at the end of an epoch.
Link to learning rate schedules
Modern learning rate schedules such as linear warmup followed by cosine decay are typically parameterised by total training steps (total epochs times steps per epoch). Changing the planned number of epochs or triggering early stopping mid-schedule alters the decay trajectory, meaning the model may stop while the learning rate is still too high unless the schedule is recalibrated.
Epoch counts in LLM training
While classical vision and tabular models often train for tens or hundreds of epochs, large language model (LLM) pretraining usually operates on token budgets where a massive corpus is seen once (1 epoch) or even sub-epoch. In contrast, supervised fine-tuning (SFT) or LoRA adaptation typically uses only 1 to 3 epochs, because more epochs can increase overfitting and catastrophic forgetting of general capabilities.
Memorisation and privacy risk in multi-epoch training
Repeating sensitive corporate datasets across too many epochs does not only harm generalisation; it also sharpens privacy risk. Repeated exposure makes language models more likely to memorise and regurgitate verbatim strings such as customer IDs, contracts or personal data under extraction or membership inference attacks.
Commonly confused terms
| Term | How it differs |
|---|---|
| Step (iteration) | An iteration (step) processes a single batch (or effective batch with gradient accumulation) and performs one weight update; an epoch comprises all steps needed to pass through the entire training dataset once. |
Why an epoch matters for on-premises AI
The number of epochs directly sets training time and so in-house GPU use. Too many can make the model memorise its training data, known as overfitting, while too few can leave learning unfinished. Validation performance is therefore tracked after each epoch while methods such as early stopping are used. This matters especially when fine-tuning on small, sensitive company data, where many epochs raise the risk of memorisation.
While fine-tuning a model that classifies service reports, a carmaker logs validation performance after each epoch; when it fails to improve for two epochs running, training stops while the best checkpoint is kept.
Common questions
How does an epoch differ from a step?
A step processes one batch and updates parameters once. An epoch is the total of steps covering the whole dataset.
How many epochs are needed?
There is no fixed number. It depends on data size, model and task; it is set by tracking validation performance.
Related terms
Sources
In the glossary: Glossary, D to L