Skip to content
Calcrivo

Epoch Calculator

Calculate the number of training epochs needed given dataset size and step budget.

Inputs

samples
samples

Number of Epochs

3.200

Total Training Steps

10,000

Steps per Epoch

3,125.00

Step by step

  1. Steps per epoch: dataset_size ÷ batch_size

    100,000 ÷ 32

    = 3125.00

  2. Epochs: total_steps × batch_size ÷ dataset_size

    10,000 × 32 ÷ 100,000

    = 3.200

How it works

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.

Formulas

Epochs from steps

epochs = (total_steps × batch_size) / dataset_size

total_steps
Total number of optimizer steps
batch_size
Samples per training step
dataset_size
Total number of samples in the dataset

Steps from epochs

total_steps = (epochs × dataset_size) / batch_size

epochs
Number of full passes over the dataset
dataset_size
Total number of samples in the dataset
batch_size
Samples per training step

Frequently Asked Questions

Why might epochs come out as a fraction?

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.

Does this account for gradient accumulation?

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.

How does dataset shuffling affect this calculation?

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.

What if the last batch of an epoch is smaller than batch_size?

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.

You might also need