Skip to content
ENExplore Calculators

Epoch Calculator

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

About Epoch Calculator

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

Worked example

With the default values below, Epoch Calculator returns Number of Epochs of 3.200. Change any input above and every figure here is recalculated in your browser.

Inputs used

Solve Forone of Number of Epochs, Total Training Steps
Number of Epochs
Dataset Sizeaccepts 1–1,000,000,000 samples
100,000 samples
Batch Sizeaccepts 1–1,000,000 samples
32 samples
Total Training Stepsaccepts 1–1,000,000,000
10,000
Number of Epochsaccepts 0.01–100,000
10

Results

Number of Epochs
3.200
Total Training Steps
10,000
Steps per Epoch
3,125.00

Step by step

  1. 1Steps per epoch: dataset_size ÷ batch_size= 3125.00
  2. 2Epochs: total_steps × batch_size ÷ dataset_size= 3.200

Assumptions and limits

  • The result is derived only from the 5 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 3 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

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.

Epoch Calculator – Calculate Number of Epochs | Calcrivo