Batch Size Calculator

Two Sides of the Same Division

Batch size and step count are locked together by the size of the dataset — pick one and the other follows. This calculator handles both directions: working out the batch size needed to hit a target number of batches, or working out how many optimizer steps a chosen batch size produces per epoch.

The Formulas

Find Batch Size: Batch Size = Dataset Size / Number of Batches (rounded up)
Find Steps per Epoch: Steps per Epoch = ceil(Dataset Size / Batch Size)

Worked Examples

Both modes, using a 60,000-sample dataset
ModeInputCalculationResult
Find Batch Size1,700 desired batches60,000 / 1,700 = 35.29, rounded up36 samples per batch
Find Steps per EpochBatch size 64ceil(60,000 / 64) = ceil(937.5)938 steps per epoch

Rounding up matters in both directions: a batch size rounded down would leave some batches oversized, and steps-per-epoch is always rounded up so the final, smaller batch still gets counted as a full step.

Where This Matters

  • Matching a target step count — some training recipes specify a total number of optimizer steps rather than epochs; this calculator converts that into the batch size needed.
  • Estimating training time — steps per epoch, multiplied by time per step, gives the epoch duration used elsewhere in training-time planning.
  • GPU memory trade-offs — larger batch sizes use more memory per step but need fewer steps per epoch; this calculator makes that trade-off concrete.

How to Use This Calculator

  1. Choose the mode: Find Batch Size or Find Steps per Epoch.
  2. For Find Batch Size: enter Dataset Size and Desired Number of Batches.
  3. For Find Steps per Epoch: enter Dataset Size and Batch Size.
  4. Select Calculate to see the result.

Related Calculations

Feed the resulting batch size into the Epoch Time Calculator, or check its memory impact with the GPU Memory Calculator.