Math · Machine learning · Training steps
Training steps per epoch calculator.
Convert dataset size, batch size and epochs into the number of batches and optimizer steps a training run will take, with gradient accumulation, drop-last and a warmup share.
For 50,000 samples, batch size 64, 10 epochs and 4 gradient-accumulation steps: 782 batches per epoch, 7,820 batches in total, 1,955 optimizer steps, an effective batch size of 256 and 98 warmup steps at 5%.
Inputs
Your result
Fill the form and press Calculate.
The arithmetic
PyTorch's DataLoader documents drop_last: set it to True to drop the last incomplete batch if the dataset size is not divisible by the batch size; if False, the last batch will be smaller. Its length is ceil(N / batch) without drop-last and N // batch (floor) with it. Total batches = batches per epoch × epochs. Hugging Face Transformers documents gradient_accumulation_steps as the number of update steps to accumulate gradients before performing a backward/update pass, num_train_epochs (a non-integer value runs a partial last epoch), max_steps (overrides epochs) and warmup_steps (a count, or a float ratio of total training steps). The effective batch size is batch size × accumulation steps (per device).
Assumptions made here: optimizer steps = ceil(total batches / accumulation steps), so a leftover partial accumulation still counts as one step; warmup steps = the warmup share of total optimizer steps, rounded up; fractional epochs round the total batch count up. Frameworks differ in how they treat a remainder, so confirm your trainer's own count before fixing a schedule or max_steps.
Worked example
50,000 samples, batch 64: ceil(50,000/64) = 782 batches per epoch, the last holding 50,000 − 781×64 = 16 samples. Ten epochs = 7,820 batches. With 4-step accumulation: ceil(7,820/4) = 1,955 optimizer steps, effective batch 256. A 5% warmup is ceil(0.05 × 1,955) = 98 steps. With drop-last, 781 batches per epoch and 50,000 − 781×64 = 16 samples are skipped each epoch (they may differ each epoch if the data is shuffled).
Sources, opened 15 October 2026: PyTorch source, torch/utils/data/dataloader.py (drop_last, __len__); Hugging Face Transformers source, training_args.py (gradient_accumulation_steps, num_train_epochs, max_steps, warmup_steps).
Frequently asked questions
How do you calculate steps per epoch?
Divide the number of training samples by the batch size and round up (ceil), or round down if the last incomplete batch is dropped. 50,000 samples at batch 64 is 782 steps per epoch.
What does gradient accumulation do to the step count?
The optimizer updates once per accumulation window, so optimizer steps are the batch count divided by the accumulation steps, and the effective batch size is batch size times accumulation steps.
What is drop_last?
A DataLoader option. When True, the last incomplete batch is dropped if the dataset size is not divisible by the batch size; when False, the last batch is smaller.
How many warmup steps should I use?
This calculator only converts a share into a step count. Common choices vary by model and task; check the paper or recipe for your model rather than a fixed rule.
Does this match my framework exactly?
It follows the documented ceil and floor batch rules. How a trainer counts a remainder inside an accumulation window can differ, so check your framework's reported total steps.
Learning and planning aid
Results are computed in your browser from the numbers you enter and the formulas described above. Check them against your own evaluation code before relying on them in a paper or a production decision.