在 keras 中获取各个时代的召回

Get the recall over the epochs in keras

我正在用

编译我的模型
metrics=["accuracy", keras.metrics.Recall()]

如文档中所述。但是,当我在训练完模型后尝试获取它时,我得到了 key_error“召回”。两个版本,

recall = estimator_bio.history["Recall"]
recall = estimator_bio.history["recall"]

结果

KeyError: 'Recall'

同时

accuracies = estimator_bio.history["accuracy"]

有效。召回的关键字是什么?

您始终可以将名称传递给指标:

metrics=["accuracy", keras.metrics.Recall(name='recall')]

这样你就可以方便的参考了。

无论如何,您应该打印或检查历史对象的内容以查看它包含的内容以及分配给 Recall 的实际 key/name(顺便说一下应该是 recall) .

通常你做的是:

# Fit the model
history = model.fit(.....)
# and then you can see what is available in the history with:
print(history.history.keys())