当我测试模型时,我的CNN模型总是预测一个班级

时间:2020-05-25 16:13:29

标签: python keras tensor cnn

我是机器学习的新手。我试图制作一个模型,该模型是我从互联网上学到的,在两个物种上的准确率达到了81%,但是当我测试该模型时,我的模型总是能预测一个物种。请帮助我,我很困惑,谢谢

第50/50集 46/46 [==============================]-104s 2s / step-损耗:0.3790-精度:0.8185-val_loss :0.2218-val_accuracy:0.8050

import numpy as np
from keras.preprocessing import image

img_pred = image.load_img(r'D:\Know Wood Laptop\Anatomy-master\Test\ws3\1315_3.jpg' , target_size = (150 , 150))
#img_pred = image.load_img(r'D:\Know Wood Laptop\Anatomy-master\Test\ws1\806_1.jpg' , target_size = (150 , 150))

img_pred = image.img_to_array(img_pred)
image = img_pred/255.0
img_pred = np.expand_dims(img_pred,axis=0)

rslt = model.predict(img_pred)


print(rslt)
if rslt[0][0]==0:
    prediction = "ws1"
else:
    prediction = "ws3"

print (prediction)

[[0。]] ws1

0 个答案:

没有答案