Skip to main content
 首页 » 编程设计

python之如何使用keras在神经网络中打印预测类的名称

2024年10月01日7zhoujg

我在 keras 中使用预训练模型并最终预测类索引为一些整数值,但我似乎不明白如何打印这些类的名称?

我使用的模型是 ResNet 50。

编辑:仍然无法弄清楚,让我回答编辑它真的很重要。

请您参考如下方法:

看看https://martin-thoma.com/image-classification/

关键部分是:

from imagenet_utils import preprocess_input, decode_predictions 
 
preds = model.predict(x) 
print('Predicted:', decode_predictions(preds))