// Fit the model on the batches generated by datagen.flow()
history = model.fit_generator(
datagen.flow(X_train, Y_train, batch_size=batch_size),
samples_per_epoch=X_train.shape[0], validation_data=(X_test, Y_test),
nb_epoch=nb_epoch)
plot_history(history)
After Change
trainflow = traingen.flow(X_train, Y_train, batch_size=batch_size)
testgen = ImageDataGenerator(featurewise_center=gcn,
featurewise_std_normalization=gcn,
zca_whitening=zca)
testgen.fit(X_test)
testflow = testgen.flow(X_test, Y_test, batch_size=batch_size)
// Fit the model on the batches generated by datagen.flow()
history = model.fit_generator(trainflow, nb_epoch=nb_epoch,
samples_per_epoch=len(X_train),
validation_data=testflow,
nb_val_samples=len(X_test))
plot_history(history)
score = model.evaluate_generator(testflow, val_samples=len(X_test))
print("Test score:", score[0])
print("Test accuracy:", score[1])
model.save("{:2.2f}.h5".format(score[1]*100))