Epochs
An epoch is one complete pass through the entire training dataset. Understanding epochs helps you control how long to train a model.
8 min•By Priygop Team•Updated 2026
What is an Epoch?
Imagine you are studying for an exam using 100 practice questions. Reading through all 100 questions once is one epoch. Reading through them again is a second epoch.
In deep learning, one epoch means the model has seen every training example exactly once. After each epoch, you evaluate the model to see if it improved.
Typically:
- Too few epochs: the model has not learned enough (underfitting)
- Too many epochs: the model memorizes the training data (overfitting)
- The right number: depends on the task, usually found by monitoring validation loss
Diagram
Loading diagram…
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Epoch Count Guidelines
- Simple tasks with clean data: 10 to 50 epochs is often enough
- Complex tasks with large datasets: hundreds or thousands of epochs
- In practice: train until validation loss stops improving, then stop
- Early stopping: a technique that automatically stops training when validation loss stops decreasing
- The learning rate and batch size affect how many epochs are needed
Epoch vs Step
Epoch vs Step
# Clarifying epochs vs steps (batches)
total_examples = 1000
batch_size = 100 # process 100 examples at a time
steps_per_epoch = total_examples // batch_size # = 10
num_epochs = 20
total_steps = steps_per_epoch * num_epochs
print(f"Total training examples: {total_examples}")
print(f"Batch size: {batch_size}")
print(f"Steps per epoch (batches per epoch): {steps_per_epoch}")
print(f"Total epochs: {num_epochs}")
print(f"Total training steps: {total_steps}")
print()
# Simulating what happens each epoch
print("Training simulation:")
for epoch in range(1, 4): # Show first 3 epochs
print(f"Epoch {epoch}:")
for step in range(1, steps_per_epoch + 1):
start = (step - 1) * batch_size
end = step * batch_size
# print(f" Step {step}: processing examples {start} to {end}")
print(f" Processed {steps_per_epoch} batches ({total_examples} examples)")
print(f" Validation: measure loss and accuracy on held-out data")Key Takeaways
- An epoch is one complete pass through the entire training dataset.
- Simple tasks with clean data: 10 to 50 epochs is often enough
- Complex tasks with large datasets: hundreds or thousands of epochs
- In practice: train until validation loss stops improving, then stop