简体   繁体   中英

Keras: Is there a need to reload the model if I train for 10 epochs multiple times?

I am training a model and want to use the mAP metric. For some reason the tensorflow mean_average_precision_at_k does not work for me, but the sklearn average_precision_score works. How can I have access to the keras's model outputs to perform the sklearn metrics? Can I compile the model one time and fit for 10 epochs, perform the metric and fit again for 10 epochs? Or do I need to save the model and reload it every time? Thank you

Can I compile the model one time and fit for 10 epochs, perform the metric and fit again for 10 epochs

Yes, absolutely.

The model will keep the training weights between calls to fit() . You can call this as many times as you please.

For any one who might have the same Issue. It seems that in Tensorflow 1.14, the implementation of Keras keeps the model weights, but restarts the optimizer which leads to bad results over many repetitions of the .fit() function. My loss is about 800 when using .fit() once and about 2800 when fitting for 5 epochs each time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM