0
0
TensorFlowml~10 mins

Data augmentation as regularization in TensorFlow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to apply random horizontal flip to images for data augmentation.

TensorFlow
data_augmentation = tf.keras.Sequential([
    tf.keras.layers.RandomFlip([1])
])
Drag options to blanks, or click blank then click option'
A'horizontal_and_vertical'
B'horizontal'
C'vertical'
D'none'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'vertical' flips images up and down, which is less common for some datasets.
2fill in blank
medium

Complete the code to add random rotation of 20% to the data augmentation pipeline.

TensorFlow
data_augmentation = tf.keras.Sequential([
    tf.keras.layers.RandomRotation([1])
])
Drag options to blanks, or click blank then click option'
A0.2
B20
C2
D0.02
Attempts:
3 left
💡 Hint
Common Mistakes
Using 20 instead of 0.2 causes an error because the value must be between 0 and 1.
3fill in blank
hard

Fix the error in the code to correctly apply random zoom augmentation.

TensorFlow
data_augmentation = tf.keras.Sequential([
    tf.keras.layers.RandomZoom(height_factor=[1])
])
Drag options to blanks, or click blank then click option'
A-0.1
B10
C0.1
D'0.1'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a float causes a type error.
Negative values are invalid for zoom factor.
4fill in blank
hard

Fill both blanks to create a data augmentation pipeline with random flip and rotation.

TensorFlow
data_augmentation = tf.keras.Sequential([
    tf.keras.layers.RandomFlip([1]),
    tf.keras.layers.RandomRotation([2])
])
Drag options to blanks, or click blank then click option'
A'horizontal'
B0.3
C0.2
D'vertical'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'vertical' flip instead of 'horizontal'.
Using 0.3 instead of 0.2 for rotation.
5fill in blank
hard

Fill all three blanks to build a data augmentation pipeline with flip, rotation, and zoom.

TensorFlow
data_augmentation = tf.keras.Sequential([
    tf.keras.layers.RandomFlip([1]),
    tf.keras.layers.RandomRotation([2]),
    tf.keras.layers.RandomZoom(height_factor=[3])
])
Drag options to blanks, or click blank then click option'
A'horizontal'
B0.1
C0.2
D'vertical'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up zoom and rotation values.
Using 'vertical' flip instead of 'horizontal'.