首页 > 解决方案 > CNN 预测

问题描述

我已经使用训练集和验证集使用 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)

标签: tensorflowkerasconv-neural-networkprediction

解决方案


import collections, numpy
collections.Counter(np.argmax(predictions, axis = 1)) 

推荐阅读