简体   繁体   English

在 ImageDataGenerator 中,每个批次或每个时期都会增加数据?

[英]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,但我的问题是,如果我们总共有 10 个样本图像, batch_size = 5 ,并且我们采用steps_per_epoch = 3而不是 2,那么我们将在每个 epoch 传递5*3 = 15图像,

so definitely we will have repetition, my question is that if image x is repeated, will both have the same augmentation value or different.所以我们肯定会有重复,我的问题是,如果图像x重复,两者将具有相同或不同的增强值。
It depends on whether new augmentation happens in each batch or in each epoch.这取决于新的增强是在每批还是在每个时期发生。

Thanks,谢谢,

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. ImageDataGenerator的工作原理是,对于第一个 epoch,它将增强所有 10 个图像以生成 10 个增强图像,然后 select 1-5 个增强图像用于训练的第一步。 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.在第一个时期的第二步中,将使用下一组增强图像,即 6-10。

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.在第二个 epoch 中,将生成一组新的增强图像,然后对于每一步,将使用定义的图像数量。 So if you use 3 steps per epoch then 5 images from the set of 10 augmented images will be repeated.因此,如果您每个 epoch 使用 3 个步骤,则将重复 10 个增强图像集中的 5 个图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM