Bird
Raised Fist0
Computer Visionml~20 mins

Data augmentation importance in Computer Vision - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Data Augmentation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why use data augmentation in training image models?

Imagine you have a small set of photos to teach a computer to recognize cats. Why is it helpful to use data augmentation?

AIt converts images to grayscale to simplify the model.
BIt reduces the size of the dataset to speed up training.
CIt removes noisy images from the dataset to improve accuracy.
DIt creates new images by changing existing ones, helping the model learn more varied examples.
Attempts:
2 left
💡 Hint

Think about how changing images slightly can help the model see more types of cats.

Predict Output
intermediate
1:30remaining
Output of augmented image shape

Given this code snippet using TensorFlow's image augmentation, what is the shape of the output image?

Computer Vision
import tensorflow as tf

image = tf.random.uniform(shape=(100, 100, 3))
augmented = tf.image.random_flip_left_right(image)
print(augmented.shape)
A(100, 100, 3)
B(100, 100)
C(3, 100, 100)
D(None, None, 3)
Attempts:
2 left
💡 Hint

Flipping an image horizontally does not change its shape.

Model Choice
advanced
2:00remaining
Choosing a model to test data augmentation effect

You want to test how data augmentation improves model performance on a small image dataset. Which model choice is best to clearly see the effect?

AA random forest model on raw pixel values.
BA simple CNN with few layers trained with and without augmentation.
CA very deep CNN pretrained on a large dataset without augmentation.
DA linear regression model on flattened images.
Attempts:
2 left
💡 Hint

Think about a model that can learn from images and show clear differences when data changes.

Hyperparameter
advanced
2:00remaining
Best augmentation intensity for small datasets

When applying data augmentation to a small image dataset, which approach to augmentation intensity usually helps the model most?

AUse no augmentation to keep original data quality.
BUse very strong augmentation to create completely new images.
CUse moderate augmentation to increase diversity without making images unrealistic.
DUse only color changes without geometric transformations.
Attempts:
2 left
💡 Hint

Think about balancing new examples and keeping images recognizable.

Metrics
expert
2:30remaining
Evaluating augmentation impact on model metrics

You trained two image classifiers: one with data augmentation and one without. After training, the augmented model has higher training loss but better validation accuracy. What does this indicate?

AAugmentation helps reduce overfitting by making training harder but improving generalization.
BAugmentation causes the model to underfit, so it performs worse overall.
CHigher training loss means the augmented model is worse in every way.
DValidation accuracy is unreliable; only training loss matters.
Attempts:
2 left
💡 Hint

Think about what it means when training is harder but validation improves.

Practice

(1/5)
1. Why is data augmentation important in training computer vision models?
easy
A. It increases the variety of training images to help the model generalize better.
B. It reduces the size of the training dataset to speed up training.
C. It removes noisy images from the dataset automatically.
D. It guarantees 100% accuracy on the training data.

Solution

  1. Step 1: Understand data augmentation purpose

    Data augmentation creates new images by slightly changing existing ones to increase variety.
  2. Step 2: Connect augmentation to model learning

    More variety helps the model learn features that work on new, unseen images, improving generalization.
  3. Final Answer:

    It increases the variety of training images to help the model generalize better. -> Option A
  4. Quick Check:

    Data augmentation = better generalization [OK]
Hint: Think: more image variety means better learning [OK]
Common Mistakes:
  • Confusing augmentation with data reduction
  • Believing augmentation removes bad images
  • Assuming augmentation guarantees perfect accuracy
2. Which of the following is a correct way to apply horizontal flip augmentation using Python's torchvision library?
easy
A. transforms.FlipHorizontal(prob=0.5)
B. transforms.HorizontalFlip(0.5)
C. transforms.RandomHorizontalFlip(p=0.5)
D. transforms.RandomFlipHorizontal()

Solution

  1. Step 1: Recall torchvision syntax for horizontal flip

    The correct transform is RandomHorizontalFlip with a probability parameter p.
  2. Step 2: Check each option's correctness

    Only transforms.RandomHorizontalFlip(p=0.5) matches the correct syntax and parameter name.
  3. Final Answer:

    transforms.RandomHorizontalFlip(p=0.5) -> Option C
  4. Quick Check:

    Correct torchvision flip syntax = transforms.RandomHorizontalFlip(p=0.5) [OK]
Hint: Look for 'RandomHorizontalFlip' with parameter p= [OK]
Common Mistakes:
  • Using wrong class names like HorizontalFlip
  • Incorrect parameter names like prob instead of p
  • Missing the probability parameter
3. What will be the output shape of the augmented image after applying the following PyTorch transform?
transform = transforms.Compose([
  transforms.Resize((128, 128)),
  transforms.RandomRotation(30),
  transforms.ToTensor()
])
augmented_image = transform(original_image)
medium
A. [128, 3, 128]
B. [128, 128, 3]
C. [1, 128, 128]
D. [3, 128, 128]

Solution

  1. Step 1: Analyze the transform steps

    Resize changes image to 128x128 pixels. RandomRotation keeps size same. ToTensor converts image to tensor with channels first.
  2. Step 2: Determine tensor shape format

    PyTorch tensors from images have shape [channels, height, width]. For RGB images, channels=3.
  3. Final Answer:

    [3, 128, 128] -> Option D
  4. Quick Check:

    PyTorch image tensor shape = [channels, height, width] [OK]
Hint: PyTorch image tensors are channels first: [3, H, W] [OK]
Common Mistakes:
  • Confusing channel order with height and width
  • Assuming rotation changes image size
  • Mixing up tensor shape formats
4. You wrote this augmentation code but get an error:
transform = transforms.Compose([
  transforms.RandomRotation(45),
  transforms.RandomHorizontalFlip(0.3),
  transforms.ToTensor()
])
What is the likely cause?
medium
A. RandomHorizontalFlip expects a keyword argument p, not a positional float.
B. RandomRotation requires integer degrees, not float.
C. ToTensor must come before RandomRotation.
D. Compose cannot combine these transforms.

Solution

  1. Step 1: Check RandomHorizontalFlip usage

    RandomHorizontalFlip requires the probability parameter as a keyword argument p=, not a positional argument.
  2. Step 2: Verify other transform usages

    RandomRotation accepts float degrees, ToTensor can be last, Compose supports these transforms.
  3. Final Answer:

    RandomHorizontalFlip expects a keyword argument p, not a positional float. -> Option A
  4. Quick Check:

    RandomHorizontalFlip(p=0.3) correct syntax [OK]
Hint: Check if transform params use correct keywords [OK]
Common Mistakes:
  • Passing probability as positional argument
  • Thinking rotation degrees must be integer
  • Misordering transforms in Compose
5. You have a small dataset of 100 images for a classification task. Which data augmentation strategy will most likely improve your model's ability to recognize objects in new photos?
hard
A. Only resize images to a fixed size without any other changes.
B. Apply random flips, rotations up to 30 degrees, and brightness changes during training.
C. Add Gaussian noise to all images without any geometric transforms.
D. Train without augmentation but increase model layers.

Solution

  1. Step 1: Consider dataset size and augmentation needs

    Small datasets benefit from augmentations that create varied views of images to prevent overfitting.
  2. Step 2: Evaluate augmentation types

    Random flips, rotations, and brightness changes simulate real-world variations, improving generalization better than noise alone or no augmentation.
  3. Final Answer:

    Apply random flips, rotations up to 30 degrees, and brightness changes during training. -> Option B
  4. Quick Check:

    Varied augmentations = better generalization on small data [OK]
Hint: Use varied simple transforms for small datasets [OK]
Common Mistakes:
  • Ignoring augmentation on small datasets
  • Using only noise without geometric changes
  • Relying on bigger models instead of data variety