I have trained a keras CNN monitoring the metrics as follow:
METRICS = [
TruePositives(name=\'tp\'),
FalsePositives(name=\'fp\'),
TrueNegatives(name=\'tn\'
It looks like you are playing with a tensorflow tutorial. I also used these exact metrics and had the same problem. What worked for me was to load the model with compile = False
and then compile it with the custom metrics. Then you should be able to use model.predict(....)
as expected.
import keras
model = keras.models.load_model('model.h5', compile = False)
METRICS = [
keras.metrics.TruePositives(name='tp'),
keras.metrics.FalsePositives(name='fp'),
keras.metrics.TrueNegatives(name='tn'),
keras.metrics.FalseNegatives(name='fn'),
keras.metrics.BinaryAccuracy(name='accuracy'),
keras.metrics.Precision(name='precision'),
keras.metrics.Recall(name='recall'),
keras.metrics.AUC(name='auc'),
]
model.compile(optimizer = keras.optimizers.Adam(learning_rate=1e-4),
loss = 'binary_crossentropy',
metrics = METRICS
)