Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding metrics to existing model in Keras

I have an existing model and would like to add additional metrics to it. The Keras metrics page says the metrics are added at compile time, but I would like to add them after loading (in part because model.load_model() only seems to load the first metric, and because I have new metrics I would like to try on existing model first). Is that possible?

like image 511
johndodo Avatar asked May 30 '17 16:05

johndodo


People also ask

What does metrics do in Keras?

A metric is a function that is used to judge the performance of your model. Metric functions are similar to loss functions, except that the results from evaluating a metric are not used when training the model. Note that you may use any loss function as a metric.

What is Y_true and Y_pred?

The tensor y_true is the true data (or target, ground truth) you pass to the fit method. It's a conversion of the numpy array y_train into a tensor. The tensor y_pred is the data predicted (calculated, output) by your model.


1 Answers

You can compile a model as many times as you want. That will not change its weights.

So you can load the model and then compile it with metrics.

The only possible problem of recompiling the model is possibly resetting the optimizer state.

like image 175
Daniel Möller Avatar answered Sep 27 '22 23:09

Daniel Möller