How to use F1 Score with Keras model?
For your implementation of f1_score
to work I had to switch y_true
and y_pred
in the function declaration.
P.S.: for those who asked: K = keras.backend
When you load the model, you have to supply that metric as part of the custom_objects
bag.
Try it like this:
from keras import models
model = models.load_model(model_path, custom_objects= {'f1_score': f1_score})
Where f1_score
is the function that you passed through compile
.