I am trying to use the ImageDataGenerator from Keras and I want to use model.fit instead of model.fit_generator , I want to get rid of the below statements i.e:- steps_per_epoch and validation_steps.
Will it work and does it augment the data dynamically also or not ?
from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(rescale = 1./255,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True)
test_datagen = ImageDataGenerator(rescale = 1./255)
training_set = train_datagen.flow_from_directory(train_path,
target_size = (224, 224),
batch_size = 32,
class_mode = 'categorical')
test_set = test_datagen.flow_from_directory(valid_path,
target_size = (224, 224),
batch_size = 32,
class_mode = 'categorical')
#flow from directory is the method of imagedatagenerator
checkpoint_callback = ModelCheckpoint(filepath='CNN MobileNet.h5',monitor='val_accuracy', mode='max', save_best_only=True)
history=model.fit_generator(training_set,validation_data=(test_set),epochs=10,steps_per_epoch=len(training_set)
,validation_steps=len(test_set),callbacks=[checkpoint_callback])
# history=model.fit(training_set,validation_data=(test_set),epochs=10,callbacks=[checkpoint_callback])
question from:
https://stackoverflow.com/questions/65885923/can-we-use-model-fit-only-instead-of-model-fit-generator 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…