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

Label Smoothing

Learn how label smoothing prevents overfitting and improves model generalization. Discover how to implement this technique with Ultralytics YOLO26 for better results.

Label smoothing is a regularization technique widely used in machine learning to improve model generalization and prevent overfitting. When training neural networks, the goal is typically to minimize the error between predictions and ground truth. However, if a model becomes too confident in its predictions—assigning near 100% probability to a single class—it often begins to memorize the specific noise in the training data rather than learning robust patterns. This phenomenon, known as overfitting, degrades performance on new, unseen examples. Label smoothing addresses this by discouraging the model from predicting with absolute certainty, essentially telling the network that there is always a small margin for error.

Link to this sectionThe Mechanics of Soft Targets#

To understand how label smoothing operates, it helps to contrast it with standard "hard" targets. in traditional supervised learning, classification labels are usually represented via one-hot encoding. For instance, in a task distinguishing between cats and dogs, a "dog" image would have a target vector of [0, 1]. To match this perfectly, the model pushes its internal scores, known as logits, toward infinity, which can lead to unstable gradients and an inability to adapt.

Label smoothing replaces these rigid 1s and 0s with "soft" targets. Instead of a target probability of 1.0, the correct class might be assigned 0.9, while the remaining probability mass (0.1) is distributed uniformly across the incorrect classes. This subtle shift modifies the objective of the loss function, such as cross-entropy, preventing the activation function (usually Softmax) from saturating. The result is a model that learns tighter clusters of classes in the feature space and produces better model calibration, meaning the predicted probabilities more accurately reflect the true likelihood of correctness.

Link to this sectionReal-World Applications#

This technique is particularly critical in domains where data ambiguity is inherent or datasets are prone to labeling errors.

  • Medical Diagnosis: In the field of AI in healthcare, clinical data is rarely black and white. For example, in medical image analysis, a scan might show features that are highly suggestive of a disease but not definitive. Training with hard labels forces the model to ignore this uncertainty. By applying label smoothing, the model retains a degree of skepticism, which is vital for decision-support systems where overconfidence could lead to misdiagnosis.
  • Large-Scale Image Classification: Massive public datasets like ImageNet often contain mislabeled images or images containing multiple valid objects. If a model tries to fit these noisy examples with 100% confidence, it learns incorrect associations. Label smoothing acts as a buffer against label noise, ensuring that a few bad data points do not drastically skew the final model weights.

Link to this sectionImplementing Label Smoothing with Ultralytics#

Modern deep learning frameworks simplify the application of this technique. Using the ultralytics package, you can easily integrate label smoothing into your training pipeline for image classification or detection tasks. This is often done to squeeze extra performance out of state-of-the-art models like YOLO26.

The following example demonstrates how to train a classification model with label smoothing enabled:

from ultralytics import YOLO

# Load a pre-trained YOLO26 classification model
model = YOLO("yolo26n-cls.pt")

# Train with label_smoothing set to 0.1
# The target for the correct class becomes 1.0 - 0.5 * 0.1 = 0.95 (depending on implementation specifics)
model.train(data="mnist", epochs=5, label_smoothing=0.1)

It is helpful to distinguish label smoothing from other regularization strategies to understand when to use it.

  • vs. Dropout: A dropout layer randomly deactivates neurons during training to force the network to learn redundant representations. While both prevent overfitting, dropout modifies the network architecture dynamically, whereas label smoothing modifies the optimization target (the labels themselves).
  • vs. Knowledge Distillation: Both techniques involve training on soft targets. However, in knowledge distillation, the soft targets come from a "teacher" model and contain learned information (e.g., "this looks 10% like a cat"). In contrast, label smoothing uses "uninformative" soft targets derived mathematically (e.g., "give 10% probability to all other classes equally").
  • vs. Data Augmentation: Strategies for data augmentation change the input data (rotating, cropping, coloring) to increase variety. Label smoothing changes the output expectations. Comprehensive training workflows on the Ultralytics Platform often combine augmentation, dropout, and label smoothing to achieve maximum accuracy.

By mitigating the vanishing gradient problem in the final layers and encouraging the model to learn more robust features, label smoothing remains a staple in modern deep learning architectures.

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