I was wondering about how the datagenerator works, especially the image multiplying part during training.
I used the generator with .next()
and saw the results. But I am a little bit confused if it multiplies images during training.
In the lines of code below is the implementation of the generator, but the steps_per_epoch
is just the number of the batches of my images len(train_generator.classes) // batch_size
. So if my database consists of 1024 images, I will get 16 batches with 64 images in each, as well as I will have 16 steps per epoch. So if I am doing steps just for my initial images, where do the multiplied images go? Or maybe I don't really understand the step_per_epoch
part?
# Import of the data
data_generator = ImageDataGenerator(
#rescale=1.0/255.0,
rotation_range=10,
width_shift_range=0.1,
horizontal_flip=True,
height_shift_range=0.1,
validation_split=0.3
)
train_generator = data_generator.flow_from_directory(
train_path,
target_size=(img_height, img_width),
batch_size=batch_size,
color_mode="grayscale",
class_mode="categorical",
subset="training"
)
model.fit(train_generator,
steps_per_epoch=len(train_generator.classes) // batch_size,
epochs=epoch_n,
validation_steps=len(valid_generator.classes) // batch_size,
validation_data=valid_generator,
)
question from:
https://stackoverflow.com/questions/65842406/what-is-keras-imagedatagenerator-logic 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…