0

I use keras to do image augmentation and segmentation. I want to investigate the number of images generated, so I test the following setting of arguments: (1) set batch_size as 1 in flow_from_directory when define the generator:

def myGene(...):
    ...
    image_datagen = ImageDataGenerator(**aug_dict)
    image_generator = image_datagen.flow_from_directory(...,batch_size = 1,..., save_prefix  = 'view',...)
    mask_datagen = ImageDataGenerator(**aug_dict)
    mask_generator = mask_datagen.flow_from_directory(...,batch_size = 1,..., save_prefix  = 'view',...)
    ...

(2) When training, I set epochs = 1 and steps_per_epoch=1:

model.fit_generator(myGene,steps_per_epoch=1,epochs=1,...)

After training finished, I expect only 1 image and 1 mask are in the directory './view', but I actually found 11 pairs there.

What is wrong here? Did I fail to setting some arguments, or did I do something wrong?

4

1 回答 1

1

在 中fit_generator,有一个名为 的隐藏参数max_queue_size=10,这意味着生成器将尝试在当前训练批次之前生成 10 个批次的队列。

您只是看到为填充队列而生成的图像。您可以尝试使用max_queue_size=0,但即使您可能会看到额外的图像。

于 2018-12-10T17:46:20.807 回答