我已经使用Keras的VGG16进行了一段时间的工作,在对我自己的4类数据集进行了微调之后,训练似乎进行得很顺利,训练和验证集的准确性提高了,最后,即使是使用model.evaluate()的评估在测试数据上也有很好的准确性。我尝试了confusion_matrix,它也显示了很好的分类结果。为了证实这一点,我尝试使用以下方法对我的数据集中的图像进行预测:
im = cv2.resize(frame,(image_size, image_size), interpolation = cv2.INTER_AREA)
#convert the image pixels to a numpy array
framer = img_to_array(im)
image = framer.reshape((1, framer.shape[0], framer.shape[1], framer.shape[2]))
# prepare the image for the VGG model
image = preprocess_input(image)
label = FLOW1_model.predict_classes(image, verbose=0)我只加载了一个类(类0)的流帧,但只有大约30%的图片被正确分类,在另一个类(类1)中,它是50%的正确分类。考虑到我训练时的准确率超过85%,而且混淆矩阵显示出非常好的结果,我发现这是非常不正常的。我在网上查看了所有可能的原因,但找不到哪里出了问题……有没有一个已知的问题可以解释结果中的这种差异?
编辑:
我基本上加载了没有top的Keras vgg,添加了我自己的分类器,并像这样编译模型:
# Compile the model method 2
sgd = SGD(lr=0.00001, decay = 1e-6, momentum=0.9, nesterov=True)
model.compile(optimizer=sgd, loss='categorical_crossentropy', metrics=['accuracy'])发布于 2018-11-06 09:02:22
据我所知,在多类输出的情况下不能使用predict_classes()方法。您是否已经尝试过:
FLOW1_model.predict(image, verbose=0)https://stackoverflow.com/questions/53152165
复制相似问题