Raj_Ame09
Raj_Ame09

Reputation: 140

In ImageDataGenerator data is augmented in each batch or each epoch?

I know that in each epoch we have a new set of augmentation. But my question is that if we have a total of 10 sample image, batch_size = 5, and we took steps_per_epoch = 3 instead of 2, then we will pass 5*3 = 15 images in each epoch,

so definitely we will have repetition, my question is that if image x is repeated, will both have the same augmentation value or different.
It depends on whether new augmentation happens in each batch or in each epoch.

Thanks,

Upvotes: 2

Views: 2248

Answers (1)

iamarchisha
iamarchisha

Reputation: 305

Augmentation happens epoch-wise and not per batch.

Explanation:

train_size = 10 
batch_size = 5
steps_per_epoch = n*(train_size//batch_size) # n is any positive integer

How ImageDataGenerator works is that, for the 1st epoch it will augment all the 10 images to generate 10 augmented images and then select 1-5 augmented images for the 1st step of training. This means that your data to be used for training is defined by the epoch. In the 2nd step for the 1st epoch the next set of augmented images, that is, 6-10 will be used.

In the 2nd epoch, a new set of augmented images will be generated and then for each step, the defined number of images will be used. So if you use 3 steps per epoch then 5 images from the set of 10 augmented images will be repeated.

Upvotes: 1

Related Questions