Challenge - 5 Problems
Data Augmentation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of TensorFlow data augmentation pipeline
What is the shape of the output tensor after applying this augmentation pipeline to a batch of 32 images of size 64x64x3?
TensorFlow
import tensorflow as tf batch_size = 32 image_size = 64 # Create dummy batch of images images = tf.random.uniform([batch_size, image_size, image_size, 3]) # Define augmentation pipeline augmentation = tf.keras.Sequential([ tf.keras.layers.RandomFlip('horizontal'), tf.keras.layers.RandomRotation(0.1), tf.keras.layers.RandomZoom(0.2) ]) augmented_images = augmentation(images) output_shape = augmented_images.shape
Attempts:
2 left
💡 Hint
Augmentation layers keep the batch size and image dimensions the same.
✗ Incorrect
The augmentation layers like RandomFlip, RandomRotation, and RandomZoom in TensorFlow keep the input shape unchanged. They only modify pixel values or positions but do not change the tensor shape.
🧠 Conceptual
intermediate1:30remaining
Purpose of data augmentation in training pipelines
Why do we use data augmentation in machine learning training pipelines?
Attempts:
2 left
💡 Hint
Think about how augmentation affects model generalization.
✗ Incorrect
Data augmentation creates new variations of existing data by applying transformations. This helps the model learn to generalize better and reduces overfitting.
❓ Hyperparameter
advanced1:30remaining
Choosing augmentation parameters for RandomRotation
Which of these RandomRotation parameters will rotate images up to 45 degrees in either direction?
Attempts:
2 left
💡 Hint
Rotation factor is a fraction of 2π radians (360 degrees).
✗ Incorrect
RandomRotation's factor determines the maximum rotation angle of factor * 360 degrees in either direction. 0.125 × 360° = 45°, so rotation up to ±45°.
❓ Metrics
advanced1:30remaining
Effect of data augmentation on training and validation accuracy
If a model trained without augmentation has training accuracy 98% and validation accuracy 75%, what is the most likely effect of adding data augmentation?
Attempts:
2 left
💡 Hint
Augmentation makes training harder but improves generalization.
✗ Incorrect
Augmentation adds variability making training harder, so training accuracy may drop. But it helps the model generalize better, improving validation accuracy.
🔧 Debug
expert2:30remaining
Debugging augmentation pipeline causing shape mismatch error
Given this pipeline, which option explains why a shape mismatch error occurs during training?
```python
import tensorflow as tf
augmentation = tf.keras.Sequential([
tf.keras.layers.RandomFlip('horizontal'),
tf.keras.layers.RandomRotation(0.2),
tf.keras.layers.Resizing(128, 128)
])
# Input images are 64x64x3
images = tf.random.uniform([16, 64, 64, 3])
augmented = augmentation(images)
model = tf.keras.Sequential([
tf.keras.layers.InputLayer(input_shape=(64, 64, 3)),
tf.keras.layers.Conv2D(32, 3, activation='relu'),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(10)
])
model(augmented)
```
Attempts:
2 left
💡 Hint
Check the input shape expected by the model vs output shape of augmentation.
✗ Incorrect
The augmentation pipeline resizes images to 128x128, but the model expects 64x64 input, causing a shape mismatch error.