Calculate the number of training epochs needed given dataset size and step budget.
An epoch is one complete pass over the training dataset. The relationship between epochs, total training steps, dataset size, and batch size is: total_steps = epochs × dataset_size / batch_size, which rearranges to epochs = total_steps × batch_size / dataset_size. This calculator solves either direction: given a target step budget (e.g. from a compute budget), find how many epochs that represents, or given a target number of epochs, find the total number of optimizer steps that will run.
Epochs from steps
epochs = (total_steps × batch_size) / dataset_size
Steps from epochs
total_steps = (epochs × dataset_size) / batch_size
A training run does not have to stop on an exact dataset boundary — a fractional epoch count (e.g. 3.4) simply means training stopped partway through the 4th pass over the data, which is common when step count is set by a compute or time budget rather than a whole number of passes.
No — if you use gradient accumulation, use the effective batch size (micro-batch × accumulation steps) as the batch size input, since that is the size of the update actually applied to the model per optimizer step.
It doesn't — shuffling changes the order samples are seen in, not the count of samples per epoch or steps per epoch, so this formula holds regardless of shuffling strategy.
This calculator assumes an even division; in practice frameworks either drop the final partial batch or process it as a smaller batch, which introduces a small discrepancy of at most one batch per epoch.