0
0
TensorFlowml~10 mins

Data augmentation for images 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 create a data augmentation layer that randomly flips images horizontally.

TensorFlow
data_augmentation = tf.keras.Sequential([
    tf.keras.layers.RandomFlip([1])
])
Drag options to blanks, or click blank then click option'
A'none'
B'vertical'
C'horizontal_and_vertical'
D'horizontal'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'vertical' which flips images top to bottom instead of horizontally.
Using 'none' which disables flipping.
2fill in blank
medium

Complete the code to add a 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 which is interpreted as 20 full rotations (invalid).
Using 2 which is more than 1 and invalid.
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.
Using a negative value which is invalid.
Using a large integer which is out of range.
4fill in blank
hard

Fill both blanks to create a data augmentation pipeline that randomly flips images vertically and applies random contrast adjustment.

TensorFlow
data_augmentation = tf.keras.Sequential([
    tf.keras.layers.RandomFlip([1]),
    tf.keras.layers.RandomContrast([2])
])
Drag options to blanks, or click blank then click option'
A'vertical'
B0.2
C0.5
D'horizontal'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'horizontal' instead of 'vertical' for flipping.
Using contrast factor greater than 1 which is invalid.
5fill in blank
hard

Fill all three blanks to create a data augmentation pipeline that randomly flips images horizontally, applies random rotation of 10%, and random zoom of 15%.

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