简体   繁体   English

Keras:解释model.predict()进行图像分类

[英]Keras: Interpretation of model.predict() for image classification

I have created an image classifier using keras and I am trying to use model.predict() for a single image.我已经使用 keras 创建了一个图像分类器,我正在尝试将model.predict()用于单个图像。 My code looks like this:我的代码如下所示:

path = 's.jpg'

from keras.preprocessing import image

img_width, img_height = 224,224

img = image.load_img(path, target_size = (img_width, img_height))

img = image.img_to_array(img)

img = np.expand_dims(img, axis = 0)

a =model.predict(img)

But the output array 'a' with probability scores is always in descending order.但是具有概率分数的 output 数组“a”始终按降序排列。 Do you have any idea why??你知道为什么吗? I have three categories.我分为三类。

The predict returns class probability, [class1_prob, class2_prob, ....] assuming you have softmax in your model.假设您的 model 中有softmax ,预测返回 class 概率, [class1_prob, class2_prob, ....]

It should not be always decreasing unless you pass such data so that for which the class probability is always in decreasing order.它不应该总是递减,除非你传递这样的数据,这样 class 的概率总是按递减顺序排列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM