0
0
PyTorchml~12 mins

Label smoothing in PyTorch - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Label smoothing

This pipeline shows how label smoothing helps a classification model learn better by softening the target labels. Instead of hard 0 or 1 labels, it uses slightly softened labels to reduce overconfidence and improve generalization.

Data Flow - 4 Stages
1Raw data input
1000 rows x 10 columnsLoad dataset with 10 features per sample1000 rows x 10 columns
[5.1, 3.5, 1.4, ..., 0.2]
2Train/test split
1000 rows x 10 columnsSplit data into training (80%) and testing (20%) sets800 rows x 10 columns (train), 200 rows x 10 columns (test)
[5.1, 3.5, 1.4, ..., 0.2]
3Label smoothing applied
800 rows x 3 classes (one-hot labels)Convert hard labels (0 or 1) to soft labels (e.g., 0.9 and 0.05)800 rows x 3 classes (smoothed labels)
[0.05, 0.9, 0.05]
4Model training
800 rows x 10 featuresTrain neural network with smoothed labelsTrained model
Neural network weights updated
Training Trace - Epoch by Epoch
Loss
1.2 |*       
1.0 | **     
0.8 |  ***   
0.6 |   **** 
0.4 |        
    +--------
     1 2 3 4 5 Epochs
EpochLoss ↓Accuracy ↑Observation
11.200.55Loss starts high, accuracy moderate
20.950.65Loss decreases, accuracy improves
30.800.72Model learns better with smoothed labels
40.700.78Loss continues to decrease steadily
50.620.82Accuracy improves, model generalizes well
Prediction Trace - 4 Layers
Layer 1: Input layer
Layer 2: Hidden layers with ReLU
Layer 3: Output layer with softmax
Layer 4: Compare with smoothed label
Model Quiz - 3 Questions
Test your understanding
What is the main purpose of label smoothing in training?
ATo increase the number of training samples
BTo speed up the training process
CTo prevent the model from becoming too confident
DTo reduce the number of features
Key Insight
Label smoothing helps the model avoid being too sure about its predictions. This leads to better learning and improved accuracy by making the model more flexible and less prone to mistakes on new data.