Tensorflow CNN预测

Tensorflow CNN预测,tensorflow,keras,conv-neural-network,prediction,Tensorflow,Keras,Conv Neural Network,Prediction,我已经使用训练集和验证集使用Keras构建和训练了一个模型。 我想对未标记的数据进行预测,我有一个文件夹,其中包含300张狗、猫和马的图片。在预测中,我得到了每一类的概率 如何获得最终输出,告诉/显示这300张图片中有多少属于每个类 我上传模型 new_model = tf.keras.models.load_model('model') 然后我重新格式化测试图像 test_batches = train_datagen.flow_from_directory( 'test_image

我已经使用训练集和验证集使用Keras构建和训练了一个模型。 我想对未标记的数据进行预测,我有一个文件夹,其中包含300张狗、猫和马的图片。在预测中,我得到了每一类的概率

如何获得最终输出,告诉/显示这300张图片中有多少属于每个类

我上传模型

new_model = tf.keras.models.load_model('model')
然后我重新格式化测试图像

test_batches = train_datagen.flow_from_directory(
    'test_images',
    target_size=(224, 224),
    batch_size=10,
    classes = None,
    class_mode= None)
然后我终于做出了一个预测

predictions = new_model.predict(test_batches, steps=30, verbose=0)

是否显示类别名称而不是编号?标签是一个热编码标签,因此您可以检查哪个显示属于哪个类别。例如,猫[1,0,0],狗[0,1,0]和马[0,0,1],所以在我上面写的代码的输出中,数字0表示猫,数字1表示狗,数字2表示马。
import collections, numpy
collections.Counter(np.argmax(predictions, axis = 1))