0
0
PyTorchml~5 mins

Data augmentation in PyTorch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is data augmentation in machine learning?
Data augmentation is a technique to increase the size and diversity of training data by making small changes to existing data, like flipping or rotating images. This helps models learn better and avoid overfitting.
Click to reveal answer
beginner
Name two common image data augmentation techniques.
Two common image data augmentation techniques are flipping (horizontal or vertical) and rotation by small angles. These create new images that help the model see different views of the same object.
Click to reveal answer
intermediate
How does data augmentation help prevent overfitting?
Data augmentation adds variety to training data, so the model doesn't memorize exact examples. This makes the model generalize better to new data, reducing overfitting.
Click to reveal answer
beginner
Show a simple PyTorch code snippet to apply random horizontal flip to images during training.
from torchvision import transforms
transform = transforms.Compose([
    transforms.RandomHorizontalFlip(p=0.5),
    transforms.ToTensor()
])

This code flips images horizontally with 50% chance before converting them to tensors.
Click to reveal answer
intermediate
What is the difference between online and offline data augmentation?
Offline augmentation creates new data files before training, increasing dataset size on disk. Online augmentation applies random changes on the fly during training, saving storage and adding variety each epoch.
Click to reveal answer
Which of the following is NOT a typical data augmentation technique for images?
ARandom rotation
BHorizontal flip
CChanging image file format
DAdding Gaussian noise
Why do we use data augmentation in training machine learning models?
ATo reduce training time
BTo increase dataset size and variety
CTo make the model smaller
DTo remove noisy data
In PyTorch, which module provides common data augmentation transforms?
Atorch.utils.data
Btorch.optim
Ctorch.nn
Dtorchvision.transforms
What does RandomHorizontalFlip(p=0.5) do during training?
AFlips images horizontally with 50% chance
BFlips every image horizontally
CFlips images vertically with 50% chance
DDoes nothing
Which is a benefit of online data augmentation over offline augmentation?
AAdds variety each training epoch
BRequires more disk space
CSlows down training significantly
DCreates fixed augmented dataset
Explain what data augmentation is and why it is useful in training machine learning models.
Think about how changing images slightly can help a model learn better.
You got /4 concepts.
    Describe how you would implement data augmentation in a PyTorch image classification project.
    Focus on the code steps to add augmentation before feeding images to the model.
    You got /4 concepts.