Yolo فيجن شنتشن
شنتشن
انضم الآن
مسرد المصطلحات

تنعيم العلامات

Explore how [label smoothing](https://www.ultralytics.com/glossary/label-smoothing) prevents overfitting and improves model generalization. Learn to implement this technique with [YOLO26](https://docs.ultralytics.com/models/yolo26/) for better accuracy.

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.

The Mechanics of Soft Targets

To understand how label smoothing operates, it helps to contrast it with standard "hard" targets. in traditional التعلم الخاضع للإشراف, 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 لوجيتس, 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 دالة الخسارة, such as cross-entropy, preventing the وظيفة التنشيط (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.

تطبيقات واقعية

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.

تطبيق تجانس التسمية مع 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 تصنيف الصور or detection tasks. This is often done to squeeze extra performance out of state-of-the-art models like يولو26.

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.

انضم إلى مجتمع Ultralytics

انضم إلى مستقبل الذكاء الاصطناعي. تواصل وتعاون وانمو مع المبتكرين العالميين

انضم الآن