Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Data Science by (17.6k points)

My code is working properly. I have used Save_Best_only function and Keras fit.generator to train the model. It gives the values. I need to extract the best accuracy, best validation accuracy among the epochs and print them in a new cell on jupyter notebook.

I assigned a variable for fit generator and try to get the details. But I don't know the keywords to print.

Test_Model = model_final.fit_generator(

train_generator,

epochs = 2,

#steps_per_epoch = 8,

validation_data = validation_generator,

#validation_steps = 8,

callbacks = [es,cp]

)

print (Test_Model)

Best Accuracy is 99.2% & Best Validation Accuracy is 99.8% etc.

1 Answer

0 votes
by (17.6k points)

Use .history from the fit_generator dictionary and pass the values into separate arrays as shown below:

con_acc = Test_Model.history['acc']

val_acc = Test_Model.history['val_acc']

After that, using max function in Python we get the max value of each array as shown below:

max(con_acc)

max(val_acc)

Browse Categories

...