我有一个像下面这样的代码来增强图像,
# Augmentation
train_datagen = ImageDataGenerator(rotation_range=5, # rotation
width_shift_range=0.2, # horizontal shift
zoom_range=0.2, # zoom
horizontal_flip=True, # horizontal flip
brightness_range=[0.2,0.8]) # brightness
# Epochs
epochs = 25
# Batch size
batch_size = 32
history = model.fit(train_datagen.flow(x_train,y_train,
batch_size=batch_size,
seed=27,
shuffle=False),
epochs=epochs,
steps_per_epoch=x_train.shape[0] // batch_size,
validation_data=(x_test,y_test),
verbose=1)
我正试图确切地了解由于增强,在训练过程中将创建多少额外的图像。第二个问题是我如何在飞行中为训练创建额外的50K图像?
dataggenerator不创建新图像,而只是为每个epoch进行转换。如果你在整个训练集中有x_train = [x1,x2,x3]图像,在每个epoch的训练中,模型应该看到相同的x_train,但是你的x_train太小了(只有3张图像),所以每个epoch的数据将为模型提供整个x_train稍微变换的数据(根据你在ImageDataGenerator中输入的参数),例如:
- for epoch 1 x_train: [x1,x2,x3]
- for epoch: [x1_t1,x2_t1,x3_t1]
- for epoch 3 x_train: [x1_t2,x2_t2,x3_t2]等等…