繁体   English   中英

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

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

我已经使用 keras 创建了一个图像分类器,我正在尝试将model.predict()用于单个图像。 我的代码如下所示:

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)

但是具有概率分数的 output 数组“a”始终按降序排列。 你知道为什么吗? 我分为三类。

假设您的 model 中有softmax ,预测返回 class 概率, [class1_prob, class2_prob, ....]

它不应该总是递减,除非你传递这样的数据,这样 class 的概率总是按递减顺序排列。

暂无
暂无

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

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