Meet YOLO26: next-gen vision AI.
Ultralytics
Back to Ultralytics Glossary

Epoch

Learn what an epoch is in machine learning and how it impacts model training. Explore optimization, avoid overfitting, and train Ultralytics YOLO26 with ease.

An epoch represents one complete cycle through the entire training dataset by a machine learning algorithm. During this process, the model has the opportunity to update its internal parameters based on every sample in the data exactly once. In the context of deep learning, a single pass is rarely sufficient for a neural network to learn complex patterns effectively. Therefore, training typically involves multiple epochs, allowing the learning algorithm to iteratively refine its understanding and minimize the error between its predictions and the actual ground truth.

Link to this sectionThe Role of Epochs in Optimization#

The primary goal of training is to adjust model weights to minimize a specific loss function. Optimization algorithms, such as stochastic gradient descent (SGD) or the Adam optimizer, use the error calculated during each epoch to guide these adjustments. As the number of epochs increases, the model generally shifts from a state of high error (random guessing) to lower error (learned patterns).

However, selecting the correct number of epochs is a critical aspect of hyperparameter tuning.

  • Too few epochs: This can lead to underfitting, where the model has not yet captured the underlying trend of the data.
  • Too many epochs: This often results in overfitting, where the model memorizes the training noise rather than generalizing to new data. To prevent this, developers often monitor performance on validation data and employ techniques like early stopping to halt training when generalization stops improving.

Link to this sectionEpoch vs. Batch vs. Iteration#

It is common for beginners to confuse "epoch" with related terms. Understanding the hierarchy of these concepts is essential for configuring training loops correctly:

  • Epoch: One complete pass through the full dataset.
  • Batch: A subset of the dataset processed simultaneously. Because datasets are often too large to fit into GPU memory all at once, they are divided into smaller groups defined by the batch size.
  • Iteration: A single update to the model's weights. If a dataset has 1,000 images and the batch size is 100, it will take 10 iterations to complete one epoch.

Link to this sectionReal-World Applications#

The number of epochs required varies drastically depending on the complexity of the task and the size of the data.

  • Medical Image Analysis: In medical image analysis, such as detecting tumors in MRI scans, accuracy is paramount. Models trained for these tasks often run for hundreds of epochs. This extensive training ensures the convolutional neural network (CNN) can discern subtle anomalies that distinguish malignant tissue from healthy tissue, potentially saving lives.
  • Autonomous Driving: For autonomous vehicles, object detection models must reliably identify pedestrians, signs, and other vehicles. Training these robust systems typically involves massive datasets like COCO or Objects365. While the dataset size is huge, the model still requires multiple epochs to converge on a solution that generalizes well to diverse weather and lighting conditions.

Link to this sectionManaging Training Cycles with Code#

When using modern frameworks like Ultralytics YOLO, defining the number of epochs is a straightforward argument in the training command. Tools like the Ultralytics Platform can help visualize the loss curves over each epoch to identify the optimal stopping point.

The following example demonstrates how to set the epoch count when training a YOLO26 model:

from ultralytics import YOLO

# Load the YOLO26n model (nano version for speed)
model = YOLO("yolo26n.pt")

# Train the model for 50 epochs
# The 'epochs' argument determines how many times the model sees the entire dataset
results = model.train(data="coco8.yaml", epochs=50, imgsz=640)

In this snippet, the epochs=50 argument instructs the training engine to cycle through the coco8.yaml dataset 50 distinct times. During each cycle, the model performs forward propagation and backpropagation to refine its detection capabilities.

Explore solutions

Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more
Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more
Real-time AI that works with your team

AI in Robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Real-time AI that works with your team

AI in Logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Real-time AI that works with your team

AI in Retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Real-time AI that works with your team

AI in Healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Real-time AI that works with your team

AI in Manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Real-time AI that works with your operation

AI in Automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Real-time AI tailored to your operation

AI in Agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning