Complete the code to create a data augmentation layer that randomly flips images horizontally.
data_augmentation = tf.keras.Sequential([
tf.keras.layers.RandomFlip([1])
])The RandomFlip layer with the argument 'horizontal' flips images left to right randomly, which is a common augmentation for image data.
Complete the code to add a random rotation of 20% to the data augmentation pipeline.
data_augmentation = tf.keras.Sequential([
tf.keras.layers.RandomRotation([1])
])The RandomRotation layer expects a float between 0 and 1 representing the fraction of a full circle. 0.2 means 20% of 360 degrees, or about 72 degrees rotation.
Fix the error in the code to correctly apply random zoom augmentation.
data_augmentation = tf.keras.Sequential([
tf.keras.layers.RandomZoom(height_factor=[1])
])The height_factor expects a float between 0 and 1 representing the zoom range. 0.1 means zooming in or out by up to 10%.
Fill both blanks to create a data augmentation pipeline that randomly flips images vertically and applies random contrast adjustment.
data_augmentation = tf.keras.Sequential([
tf.keras.layers.RandomFlip([1]),
tf.keras.layers.RandomContrast([2])
])RandomFlip('vertical') flips images top to bottom randomly. RandomContrast(0.2) adjusts contrast by up to 20%.
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%.
data_augmentation = tf.keras.Sequential([
tf.keras.layers.RandomFlip([1]),
tf.keras.layers.RandomRotation([2]),
tf.keras.layers.RandomZoom([3])
])The pipeline flips images horizontally, rotates them by 10% of a full circle, and zooms by 15%. These augmentations help the model learn better by seeing varied images.