首页 > 解决方案 > Keras 确定错误的预测

问题描述

我有一个训练有素的 Keras 模型,并且我有一个验证集(即 X_val、y_val)。我想使用模型来预测 y_val,然后确定错误预测的索引。然后,我将使用这些索引来确定与错误分类相对应的原始数据点。我如何获得这些指数?

我的目标是显示我们错误分类的原始输入列表。这是我的错误分析的一部分。原始输入是文本,但这不应该是相关的。

标签: pythonkerasclassification

解决方案


I'd suggest to compare the prediction where it's incorrect using the model's predict_class.

incorrects = np.nonzero(model.predict_classes(X_val).reshape((-1,)) != y_val)

推荐阅读