Search code examples
pythontensorflowconv-neural-networktf.keras

image augmentations using tensorflow


i have a question about augmentations...when we use ImageDataGenerator with certain changes like zooming, shifting, and flipping for training.... does this mean the model won't ever see the original (unaugment) image ??

# Data Augmentation
  data_augmentation = tf.keras.Sequential([
  tf.keras.layers.experimental.preprocessing.RandomRotation(0.1),
  tf.keras.layers.experimental.preprocessing.RandomTranslation(0.1, 0.1)
])

model = Sequential([ data_augmentation,, .........

Solution

  • You can't know it! The transformations in the data augmentation are applied randomly to each batch of training images, so each time a batch is processed during training, the model sees slightly different versions of the original images. The point is that during the training, an image is processed more and more times (1 for each epoch if the batches are disjoint), so the model will see #epochs slightly different versions of the same image... therefore, one of this slightly different versions may be the original image (this is unlikely to be true, but it's not impossible).