Learn about epochs in machine learning—how they impact model training, prevent overfitting, and optimize performance with Ultralytics YOLO.
In machine learning (ML), particularly in the context of training deep learning models, an epoch represents one complete pass of the entire training dataset through the learning algorithm. Training models is an iterative process where the model learns patterns by repeatedly processing the data. Epochs are a fundamental hyperparameter that defines the number of times the algorithm will work through the entire dataset, allowing the model to learn from each example within the data multiple times.
During the training process, a model's internal parameters, or weights, are adjusted based on the errors it makes in its predictions. This adjustment typically happens using an optimization algorithm like Gradient Descent or its variants (e.g., Adam Optimizer). One epoch means that every sample in the training dataset has had an opportunity to update the model's internal parameters once. For large datasets, processing the entire dataset at once is computationally expensive, so the data is often divided into smaller chunks called batches.
It's important to distinguish an epoch from related terms:
Think of it like reading a book: the entire book is the dataset, a chapter is a batch, reading one chapter is an iteration, and reading the entire book cover-to-cover is one epoch.
The number of epochs is a critical hyperparameter because it determines how many times the model learns from the full dataset.
Finding the right balance is key to achieving good model performance and generalization. This often involves monitoring the model's performance on a separate validation dataset during training.
There's no single "correct" number of epochs; the optimal value depends on the complexity of the data, the size of the dataset, the model architecture, and the learning rate. Common approaches include:
Epochs are a standard parameter in most deep learning frameworks:
fit
method.Epochs are a cornerstone of iterative learning in ML, balancing the need for sufficient exposure to data against the risks of overfitting. Selecting the right number of epochs, often through careful experimentation and monitoring as discussed in resources like Stanford's CS231n course or the Machine Learning Mastery blog, is key to building effective models. You can find more definitions in resources like the Google Machine Learning Glossary.