SIMETRIUM .COM epoch · step · batch
1 epoch = the whole dataset
EN|36 languages
epoch epochepochepoch epoch epoch 01 02 03 epoch 1/3 stop loss · train / val 0123 epoch SYMBOL PLATE steps/epoch = ⌈N / B⌉N = 24 · B = 1 · 3 epoch ISO/IEC 22989:2022 · ISO/IEC 23053:2022
Letter case
An epoch has no symbol; it is written as a word: “3 epochs”, “0.44 epochs”, and in training logs as epoch 3/10. The number of epochs can be fractional: it is the share of the dataset the model has managed to read. In formulas the epoch is denoted by the letter E.
Do not confuse
An epoch is not a step: in one step the model sees only a bundle of examples, a batch, while an epoch is made of hundreds and thousands of steps. Nor should it be confused with the Unix epoch, the moment of 1 January 1970 from which computers count seconds, or with an epoch in astronomy and geology.
Under the cast word epoch a drum turns, with twenty-four cards fixed around its rim: the whole training set. Above the drum stands a reading head, and its green beam blinks whenever the next card passes under it. One full turn of the drum is one epoch, and the counter on the left flips from 01 to 02 and 03. On the small screen on the right a dot creeps along the training-error curve, while the dashed validation-error curve turns upward after the second epoch, where a green “stop” mark sits. At the bottom a slider runs along a scale from zero to three epochs, and a glint sweeps across the metal of the letters.
Unit passport · AI series · training length

epoch

Epoch
E · 1 epoch = ⌈N / B⌉ steps · E = D / |dataset|

Here is a strange entry from the technical report on GPT-3, the model that started the chatbot craze. It read Wikipedia 3.4 times, but the huge archive of web pages Common Crawl only 0.44 times, that is, less than half. How can you read something “0.44 times”, and why did the developers deliberately make the model reread a small encyclopedia but not finish the internet? The answer is hidden in the data-mixture workshop below, and for now remember: an epoch can be fractional.

An epoch is one full pass over the training data: the model has seen every example exactly once. It is the oldest counter of training length, and still the main one when you fine-tune a model on your own data or teach it to recognise images or sounds. Too few epochs and the model has not managed to learn; too many and it has memorised the examples by heart, along with their errors, and answers worse on new data. This sheet has a calculator of steps and cost, a live experiment with overfitting and early stopping, mini-batches on an error surface, and a workshop that shows how many times a model will read each of its sources.

What it is
one full pass over the training set; a counter of training length
Notation
no symbol; E in formulas; epoch 3/10 in logs; in Chinese 轮 (lún, “round”)
Link to steps
steps per epoch = ⌈N / (B · devices · accumulation)⌉; N is examples, B is batch
Fractional epoch
tokens read divided by the size of the source: 0.44 epochs is less than half
Typical values
≈ 1 — language models · 3 — fine-tuning · 90 — ImageNet · 300 — object detectors
References
ISO/IEC 22989:2022 (AI terminology) · ISO/IEC 23053:2022 (machine learning)
Count steps and price Overfit a model GPT-3 data mixture
Calculator
Tool · steps, epochs and time

How many steps in an epoch and how long to wait

Enter how many examples the dataset has, the batch size on one GPU, the number of GPUs and gradient accumulation: the model takes one step once it has collected the whole effective batch. Below you will see steps per epoch, steps in the whole training, learning-rate warm-up steps, and the time if you know how long one step takes.

Tool · fine-tuning a language model

How many tokens and how much money fine-tuning will take

Fine-tuning services charge for training tokens: the number of examples multiplied by their average length and by the number of epochs. Enter your data and the price from the price list; choose the currency yourself, the calculation does not depend on it. To the right of each epoch you can see what share of its benefit remains, if you believe the studies of data repetition.

Etymology

Stop, repeat and bake

Neural-network training is described with three words, and each came from its own kitchen: Greek philosophy, Latin rhetoric and the English bakery. Epoch once meant a halt, iteration a repetition, and batch a lot of bread baked at one time. Put them together and you get an exact picture: the model bakes answers in batches, over and over, and from time to time stops to mark a lap completed.

epochGr. ἐποχή
epékhein · to hold back→the point of reference→pass over the data
To the Greeks epokhē was a stop, a suspension; the sceptic philosophers used it for withholding judgement. Astronomers took the word for the moment to which the positions of stars are tied: for example, “epoch J2000.0”. Hence the epochs of history and geology. In a neural network an epoch is also a mark: the model has gone round the data, and this is a convenient moment to stop, check it and save it.
iterationLat. iteratio
iterum · again→iterare · to repeat→training step
Latin iterum, “again”, gave the verb “to repeat”, and rhetoricians called a deliberate repetition of a word iteration. Mathematicians adapted the word for calculations that refine an answer again and again, like Newton’s method for a root. In training an iteration is one step: the model took a batch, computed the error and adjusted the parameters. Sometimes an epoch is carelessly called an iteration too, hence the confusion.
batchEng. batch
bacan · to bake→a lot of bread→a bundle of examples
Old English bacan, “to bake”, gave the word bæcce: everything a baker puts into the oven at one time. Later any portion came to be called a batch: batch processing on mainframes was named just that. In training a batch is a bundle of examples from which the model makes one step. A hundred examples with a batch of ten is ten steps per epoch.
What it is called in other languages
轮 lún — in China, “round, turn”: 训练轮数 — “number of training rounds”; documentation more often writes simply epoch
エポック — Japanese, 에포크 — Korean: the English word in a syllabic alphabet
حقبة ḥiqba — Arabic, “epoch, period”; in textbooks and دورة تدريب, “training round”
época — Spanish and Portuguese, époque — French, Epoche — German
एपॉक — Hindi; epok — Indonesian and Turkish (in Turkish and dönem)
epoch — Russian; epoha — Serbian; kipindi — Swahili, “period”
step · iter
one optimizer step on one batch
bs · B
batch size, how many examples are in a batch
lr · η
learning rate — the size of a step
val · dev
a validation set that the model is not shown during training
01 · Definition and order of examples

A lap of the textbook

Imagine a student preparing for an exam with a problem book. They solve problems five at a time, after each five they check the answers and draw conclusions, and on reaching the end of the book they start again. A five of problems is a batch, the checking and conclusions are a training step, and one pass through the whole book is an epoch. To remember the solutions better, the student will go through the book several times. But if they repeat it twenty times, they will learn the answers to exactly these problems by heart, typos included, and at the exam with new problems they will be lost.

It is the same with a neural network: nobody knows in advance how many epochs are needed. So part of the data is set aside and not shown to the model, and after each epoch the model is checked on it. While the error on the held-out data falls, training is paying off; when it starts to rise, the model has begun to cram, and training should be stopped. This technique is called early stopping. Before each epoch the examples are usually shuffled, so that the model does not get used to their order.

N — examples · B — batch per device · g — devices · a — accumulation · E — epochs · D — tokens read · U — unique tokens
Interactive · four epochs of one dataset

In which order the model sees the examples

Each row is an epoch, each cell is an example: the colour shows which example it is, from the first (blue) to the last (crimson). Batches are outlined with a frame. Switch the shuffling mode and the batch size and see how what the model sees in a row changes.

Reference · benchmark values
5005steps per ImageNet epoch at batch 256: 1 281 167 images divided by 256, rounded up 90epochs ResNet-50 was trained on ImageNet in the classic 2015 paper, and AlexNet for as many in 2012 ≈ 4epochs over the same texts a language model tolerates almost without loss; beyond that the benefit melts fast 3epochs is the default in the Hugging Face Trainer, the most popular fine-tuning library
The riddle solved

How to read the internet 0.44 times

Large language models are trained not on one dataset but on a mixture of several: filtered web pages, books, articles, code and encyclopedias. Developers decide in advance what share of the training tokens each source gets, and this share need not match its size. In GPT-3 training lasted three hundred billion tokens, and sixty percent of them were taken from Common Crawl, which held 410 billion. So the model managed to read only 180 billion, about 0.44 of its epoch, and the rest simply never got its turn.

Wikipedia, which has about three billion tokens, was given three percent of the training, roughly nine billion tokens, and the report records that it was read 3.4 times. The developers knowingly overfed the model with quality texts and underfed it with noisy ones: better to reread an encyclopedia three times than to finish random pages with ads and scraps of menus. Move the source shares in the data-mixture workshop and see when repeats become too many.

Interactive · three experiments with epochs

Overfit, shuffle, reread

In the “Overfitting” experiment real gradient descent fits a flexible curve to a few noisy points: move the epoch slider and watch the model first catch the pattern, then start to wiggle in order to pass through every point together with the noise. In the “Mini-batches” experiment the same descent walks over an error map in small bundles: you can see how batch size and shuffling change the path. And in the “Repeats” experiment a language model rereads the same corpus, and each next epoch brings less and less benefit.

Epochs elapsed
Training points · noise · weight penalty
Steps taken
Batch of 48 examples
Epochs over one corpus
Unique tokens in the corpus

Chart · learning-rate schedule
A big step at the start, a small one at the end
Along the horizontal axis are ninety training epochs, along the vertical the learning rate as a share of the largest. Almost always it is first ramped up smoothly and toward the end reduced, so that the model “lands” at a good point. Choose a schedule: the others stay pale for comparison.
epochslr ÷ lr_max

Chart · how many epochs are used in practice
From half a pass to tens of thousands
Each bar is a known training run, its length is the number of epochs on a logarithmic scale. The more data, the fewer epochs: language models hardly reread their texts, while small sets of images and problems are run hundreds and thousands of times. The dashed line is one epoch, the green bar is the limit beyond which repeating text is almost useless.
trainingepochs, log scale
02 · Orders of magnitude

From a tenth to ten thousand rounds

Drag the slider: it moves along a logarithm, and each division is ten times the previous one. On the left are the hugest datasets, which the model does not manage to finish reading; on the right are tiny tasks that a neural network runs thousands of times until it suddenly grasps the pattern. See where your own project would land.

left: 0.1 epochs · right: 10 000 epochsfrom papers and developers’ reports; the sign ≈ means an estimate
03 · Data-mixture workshop

How many times the model will read each source

Here is the real GPT-3 data mixture from OpenAI’s 2020 technical report: five sources, their size in tokens and the share each received in training. Move the shares and the total training length, and you will see how many epochs fall on each source. Everything that is reread more than four times lights up red: beyond that, according to studies, repeats bring almost no benefit. The same arithmetic can be applied to your own data: enter it in place of the example.

Tool · epochs by source

Each bar is a source: the height of the light part is its size, of the dark part how much of it has been read. The marks on the bar are whole epochs. A source with a zero share the model will not see at all. In OpenAI’s report the sizes are rounded, so for WebText2 and Wikipedia it records 2.9 and 3.4 epochs, while here it comes out as 3.5 and 3.0.
Cheat sheet · how to choose the number of epochs
04 · Epoch in code

Where the number of epochs is set and what the default is

Every library names the number of epochs a little differently, and the defaults differ by hundreds of times: from one epoch in Keras to a thousand in PyTorch Lightning if you specify nothing. Keep this in mind when running someone else’s example. Tap a row to read the details.

libraryparameterdefault

For work · epochs and early stopping

Three snippets worth keeping at hand

Setting epochs with a margin and adding early stopping is more reliable than guessing the number in advance: the model stops by itself when the validation error has stopped falling for several epochs in a row, and returns the best weights.

05 · Writing rules
Correct
State the batch and the dataset size along with the epochs: “3 epochs of 52 thousand examples, batch 32”.
Write fractional epochs if the dataset was not read in full: “0.44 epochs”.
For large models give tokens, not epochs: “trained on 15 trillion tokens”.
Say after which epoch the weights were taken: “best validation: epoch 7 of 20”.
Write “epoch 3 of 10” or epoch 3/10.
Incorrect
Call a single step or one iteration an epoch.
Compare numbers of epochs on datasets of different sizes: 90 epochs of ImageNet and 90 epochs of MNIST are different amounts of work.
Write “epochs: 3” without saying over what data: with a mixture of sources each has its own epochs.
Assume that more epochs is always better: past a certain number the model starts to cram.
Confuse it with the Unix epoch: “epoch 1 700 000 000” is seconds since 1970.
06 · Neighbouring units
07 · Historical section
EPOCH 1 ACC 0.913EPOCH 2 ACC 0.947EPOCH 3 ACC 0.961EPOCH 4 ACC 0.968EPOCH 5 ACC 0.972EPOCH 6 ACC 0.973EPOCH 7 ACC 0.972EPOCH 8 ACC 0.970STOP · BEST EPOCH 6line-printer printout
training log on punched tape
Note

For many years the rule was simple: once the validation error starts to rise, training further is useless. But in 2022 OpenAI researchers led by Alethea Power described a strange phenomenon. A small network was learning to add numbers modulo 97, and within a few hundred steps it learned all the training examples by heart, while on new ones it erred as if at random. It was not stopped, and tens of thousands of steps later, when any engineer would long since have given up, the accuracy on new examples suddenly jumped to almost a hundred percent.

The phenomenon was named grokking, after the word grok coined by the science-fiction writer Robert Heinlein, meaning “to understand to the very depths”. Having memorised the answers, the model kept slowly simplifying its weights and at some point found the real rule instead of a lookup table. Grokking occurs mostly on small mathematical tasks and with a strong penalty on large weights, while for ordinary data early stopping is still reliable. But it is a reminder: the number of epochs is not only a budget but also a question of what the model will have time to understand.

10²10⁴10⁵grokking · 2022
understanding after cramming
Series · AI
units of language models

How a neural network is measured

The epoch links data with training: tokens are what the model reads, parameters are what it adjusts, and epochs and steps show how many times and in what portions this happens. On the left is a console where these measures meet in one training run; on the right are the series sheets.

train.log · one fine-tuning run
Catalogue of quantities
the whole index →
the foundation · 7 units

The seven SI base units

on the sheet’s topic · model training and AI
The index lab: a glass of cabbage juice, a burner, a glass of water on a cold plate and a gear train
Index · all quantities on one page
The lab at the entrance to the index

A drop of acid changes the colour of the juice, salt colours the flame, water freezes at a tap. Below them are all Simetrium sheets, by discipline and alphabetically.

Open the index →
08 · Your language
every link is a real page in that locale

Read it in your own language

translated and checkeddraft translationqueued