Yahya Nik
Yahya Nik

Reputation: 85

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

Upvotes: 1

Views: 364

Answers (2)

Yahya Nik
Yahya Nik

Reputation: 85

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.

Upvotes: 0

Stewart_R
Stewart_R

Reputation: 14515

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.

Upvotes: 1

Related Questions