Hi, can I know what is going on? what I did is trying to replace fit() with fit_generator()
my training data is train_VGG16 with shape (1624, 7, 7, 512)
valid data is valid_VGG16 with shape (98, 7, 7, 512),
test data is test_VGG16 with shape (109, 7, 7 512)
the model is very simple one as I just wanna test out replacing it with fit_generator().
VGG16_model = Sequential()
VGG16_model.add(GlobalAveragePooling2D(input_shape=(7,7,512)))
VGG16_model.add(Dense(2, activation='softmax'))
VGG16_model.summary()
for fit():
VGG16_model.fit(train_VGG16, train_targets,
validation_data=(valid_VGG16, valid_targets),
epochs=100, batch_size=2, callbacks=[checkpointer], verbose=1)
I understand python generator concept and made custom generator. Please correct me if I'm wrong.
I'm using the train_VGG16 and slice it with batch_size for example, 2, then each time, it will use the sliced train_VGG16 of shape (2, 7, 7, 512) to train the model.
and to run through the whole 1624 records, I've specified the steps_per_epoch as 812, so that 812 * 2 = 1624.
and here is the fit_generator():
VGG16a_model.fit_generator(generator=train_gen,
validation_data=valid_gen,
steps_per_epoch=812,
validation_steps=49,
max_q_size=1,
verbose=1,
shuffle=False,
callbacks=[checkpointer1],
epochs=100)
I don't know why the outputs of the two are different? it is normal (which I don't think so)?
I did the same for using batch_size of 1624 and step_per_epoch = 1, the results is still different to fit()
Please help! Keras experts!
I dont think it is a completely new problem and many experts should have solution on it or there are working code. please advise. thanks.
the use of generator is to solve the out of memory issue.
If it were possible to have 1Tb of RAM, I would not need to use generator method.
fit() just load everything to the memory and it is done.
anyway, Please kindly help. I am running out of my methods. I just feel fit_generator() is totally different to fit() in results. but it should not be.
the results is fit 96.3303%, while fit_generator(), 88.0734%