I trained a cnn model with precision
and recall
metrics which are imported from keras_metrics
. But when I tried to load the model, I am getting the error: ValueError: Unknown metric function:binary_precision
. I have not used binary_precision
function anywhere but still I gave `binary_precision' in custom_objects as per the error:
model = load_model(modelfilepath,custom_objects={'metrics': [keras_metrics.precision(),binary_precision]})
With this I am getting the error, NameError: name 'binary_precision' is not defined
. What should I do for this.
My code is as follows:
#compiling the model
model.compile(optimizer=SGD(),loss='binary_crossentropy',metrics = ['accuracy',keras_metrics.precision(),keras_metrics.recall()])
#loading the model after training and saving it
model = load_model(modelfilepath,custom_objects={'metrics': [keras_metrics.precision(),binary_precision]})