0
0
PyTorchml~12 mins

Data augmentation in PyTorch - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Data augmentation

Data augmentation is a technique to create more training data by making small changes to existing images. This helps the model learn better by seeing many versions of the same image.

Data Flow - 4 Stages
1Original dataset
1000 images x 3 channels x 32 height x 32 widthLoad raw images1000 images x 3 x 32 x 32
Image of a cat with RGB channels
2Apply random horizontal flip
1000 images x 3 x 32 x 32Flip images horizontally with 50% chance1000 images x 3 x 32 x 32
Cat image flipped left to right
3Apply random rotation
1000 images x 3 x 32 x 32Rotate images randomly between -15 and 15 degrees1000 images x 3 x 32 x 32
Cat image rotated slightly clockwise
4Normalize images
1000 images x 3 x 32 x 32Scale pixel values to mean=0.5 and std=0.51000 images x 3 x 32 x 32
Pixel values adjusted to range around zero
Training Trace - Epoch by Epoch
Loss
1.2 |****
0.9 |***
0.7 |**
0.55|*
0.45| 
    +------------
    Epochs 1 to 5
EpochLoss ↓Accuracy ↑Observation
11.20.45Model starts learning with high loss and low accuracy
20.90.60Loss decreases and accuracy improves as model learns
30.70.72Model continues to improve with augmented data
40.550.80Loss lowers and accuracy rises steadily
50.450.85Model shows good learning progress with augmentation
Prediction Trace - 5 Layers
Layer 1: Input image
Layer 2: Random horizontal flip
Layer 3: Random rotation
Layer 4: Normalization
Layer 5: Model prediction
Model Quiz - 3 Questions
Test your understanding
Why do we apply random horizontal flip during data augmentation?
ATo convert images to grayscale
BTo help the model learn from different views of the same image
CTo reduce the image size
DTo increase the number of image channels
Key Insight
Data augmentation creates varied versions of images, helping the model learn more robust features and improving accuracy by reducing overfitting.