AI glossary: Training and models

What Is an Epoch in Machine Learning? Epoch vs Batch vs Iteration

Satvik ParamkushamUpdated October 5, 20266 min read

Definition

An epoch is one complete pass of the entire training dataset through a machine learning model. Training usually runs for many epochs, and after each one the model has seen every training example once.

In Hindi: Epoch matlab model ne poore training data ko ek baar shuru se end tak dekh liya, yaani ek full round of training.

What is an epoch in machine learning?

An epoch in machine learning is one full pass through the whole training dataset, where the model sees every training example exactly once.

Models rarely learn enough from seeing the data a single time. So training repeats the process: epoch 1, epoch 2, epoch 3 and so on. In each pass the model makes predictions, measures how wrong it was (the loss), and nudges its internal weights, also called parameters, to do a little better next time.

The number of epochs is a hyperparameter. That means you choose it before training, just like the learning rate or the batch size. It is not something the model learns by itself.

What is an epoch in simple words?

In simple words, an epoch is one complete revision of your full syllabus.

Say you are revising a 10 chapter science book before your exam. You do not read the whole book in one sitting. You read 2 chapters per sitting, so finishing the book takes 5 sittings. Finishing the book once is one epoch. Each sitting is one iteration, and the 2 chapters you read per sitting are your batch.

Most students revise the book more than once, because each round makes the concepts clearer. A model is the same. But revising the same book 50 times can turn into pure memorising, which is the machine learning problem called overfitting.

What is epoch and batch size in machine learning?

Batch size is how many training examples the model looks at before it updates its weights once, while an epoch is the full pass over all examples, made up of many such batches.

The three terms fit together with one simple formula:

iterations per epoch = number of training samples / batch size
total iterations = iterations per epoch x number of epochs

Here is a worked example with 1,000 training samples, a batch size of 100 and 20 epochs:

TermMeaningValue in the example
SampleOne training example, such as one image or one sentence1,000 samples
Batch sizeSamples processed before one weight update100
Iteration (step)One weight update using one batch1,000 / 100 = 10 per epoch
EpochOne full pass over all samples10 iterations
Total trainingAll epochs together10 x 20 = 200 iterations

If the numbers do not divide evenly, say 1,050 samples with a batch size of 100, most libraries run 11 iterations and the last batch simply has 50 samples, unless you tell them to drop the incomplete batch.

Epoch, batch and iteration questions show up often in machine learning interviews, usually as a quick calculation like the one above.

What happens during one epoch of training?

During one epoch, the model goes through every batch of the training data, learns from each one, and is then usually checked on separate validation data.

For a neural network, each iteration inside the epoch follows the same loop:

  1. Forward pass: the model makes predictions for the batch.
  2. Loss: a loss function measures how far those predictions are from the correct answers.
  3. Backward pass: backpropagation works out how each weight contributed to the error.
  4. Update: an optimiser such as SGD or Adam adjusts the weights slightly.

At the end of the epoch, most training scripts print the average training loss and the validation loss. That is why searches like "epoch and loss" go together: you watch the loss fall epoch by epoch to judge whether learning is working. Many setups also shuffle the data before each epoch so the model does not learn the order of examples.

How many epochs should you use?

No single number of epochs is correct; you should train until validation performance stops improving and then stop.

The right number depends on the dataset size, the model and the learning rate. Some rough patterns, which vary a lot by project:

  • Small datasets and simple models: often tens to a few hundred epochs.
  • Large image or text models trained from scratch: fewer passes, because each epoch already contains a huge amount of data.
  • Fine-tuning a pretrained model: often only a few epochs, since the model already knows a lot. When you fine-tune an LLM on a small dataset, too many epochs can make it parrot your examples.

The practical answer is early stopping. You set a generous maximum, monitor validation loss, and stop when it has not improved for a few epochs (called patience). In Keras it looks like this:

early_stop = EarlyStopping(monitor="val_loss", patience=3, restore_best_weights=True)
model.fit(x_train, y_train, epochs=100, batch_size=32,
          validation_data=(x_val, y_val), callbacks=[early_stop])

I would never pick the epoch count by guessing. Plot the training and validation loss once, and the curve will tell you where to stop.

How are epochs related to overfitting and underfitting?

Too few epochs lead to underfitting and too many epochs can lead to overfitting.

  • Too few epochs: the model has not had enough rounds to learn the pattern, so both training and validation accuracy stay low.
  • The right range: training and validation accuracy improve together.
  • Too many epochs: training accuracy keeps climbing, but validation accuracy flattens or drops because the model starts memorising noise.

The epoch where validation loss is lowest is usually the best version of your model, which is exactly what early stopping with restored best weights saves for you.

Frequently asked questions

Is an epoch the same as an iteration?

No. An iteration is one weight update using one batch, while an epoch is a full pass over all the training data. With 1,000 samples and a batch size of 100, one epoch contains 10 iterations.

What does Epoch 5/20 mean in training logs?

It means the model is on its fifth full pass out of a planned 20 passes over the training data. The numbers printed beside it are usually the loss and accuracy for that epoch.

Does increasing epochs increase accuracy?

Only up to a point. Early on, more epochs improve both training and validation accuracy, but after the best point extra epochs mostly raise training accuracy while validation accuracy stays flat or falls.

How do you pronounce epoch?

Both EE-pok and EP-uk are commonly used. In Indian and British English you will mostly hear EE-pok, and either is fine in an interview.

What is an epoch in reinforcement learning?

Reinforcement learning has no fixed dataset in the usual sense, so the word is used more loosely. Libraries often use epoch to mean a fixed number of environment steps or episodes, or the number of passes over a collected batch of experience, so check the library documentation.

References