Data Augmentation in Keras: How many training observations do I end up with?

I'm reading through Francois Chollet's "Deep Learning with Python" and was recently introduced to a concept I had never encountered before in my statistics studies. Namely, data augmentation. I have a question about what the following code does (appearing on pg 141 of the book):

train_datagen = ImageDataGenerator(rescale=1./255,
rotation_range=40,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,)

test_datagen = ImageDataGenerator(rescale=1./255)

train_generator = train_datagen.flow_from_directory(train_dir,
target_size = (150,150)
batch_size = 32,
class_mode='binary')

history = model.fit_generator(
train_generator,
steps_per_epoch=100,
epochs=100,
validation_data=validation_generator,
validation_steps=50)


What I want to know is how the ImageDataGenerator() is working. E.g., if I have a training directory with 2000 images, will the data augmentation create more than 2000 observations to train with? How do I know/control how many observations are developed?

• I think I understand it now. Since neural networks work in generations (or epochs) they constantly accept the same data through repeatedly. So, each generation it's the same input pictures (32 pictures per batch) over and over. Thus the network sees each one 100 times. By augmenting (flipping, zooming, rotating, shifting ranges etc.) we change the image at every epoch so the network can't "cheat" and just learn every picture. – Nicklovn Jan 8 at 19:54
• Note that you're allowed to answer your own question using the answer box below your question. – Sycorax Jan 8 at 19:58
• Yes I know. The only reason I didn't is that I have no yet confirmed my answer. I'm fairly confident but not certain of my answer. – Nicklovn Jan 8 at 21:14
• I am pretty sure it goes through the pictures in the directory 32 per step and 100 such batches per epoch. I.e. if there are 2000 pictures, you'd be back at the first one before the end of the epoch, but if course each picture is augmented each time is used, so is never exactly the same. You can of course generate a batch, display the augmented pictures, then generate another batch and look at that. – Björn Jan 8 at 22:37
• Yes. OK So my understanding was correct. Thank you for this response. – Nicklovn Jan 9 at 0:28