# predicting the new images
# defining the new function to classify images
def predictDigit( filePath ):
#doing image preprocessing
test_image = image.load_img( grayscale = True , path = filePath , target_size = ( 28 , 28 ))
plt.imshow( test_image )
test_image = image.img_to_array( test_image )
test_image = np.expand_dims( test_image , axis = 0 )
# predicting the digit
ans = classifier.predict(test_image )
print( ' I think the digit is probbably ' , ans )
filePath = 'Screenshot1.jpg'
predictDigit( filePath )
我在CNN中创建了一个模型,用于使用keras对anaconda(spyder)中的MNIST数据集进行分类。一切都很好,除了每当进行预测时输出总是[[0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]]的部分。即使在验证集上模型的准确性为99.84%,输入图像的精度也是如此。请帮助我确定错误原因。 预先感谢。
HERE是原始代码的链接:https://github.com/REDsake/KaggleWeekends/commit/bfff2fe9502b435a85725af6790076a721805c9a