且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

训练准确性和验证准确性良好,但预测准确性较差

更新时间:2022-11-28 21:04:56

您的评估准确性为89.9%.我测试了我提供给您的用于打印结果的代码,这些代码对于我使用的模型和数据是正确的.请显示您用于model.predict的代码.应该像下面这样.不要使用预测生成器fit_generator或valuate_generator,因为在将来的tensorflow版本中,它将被折旧.只需使用拟合,预测或评估即可.

your evaluation accuracy is 89.9%. I tested the code I gave you to print the results and they were correct for the model and data I was using. Please show the code you used for model.predict. Should be like below. DO not use predict-generator fit_generator or evaluate_generator as the will be depreciated in future versions of tensorflow. Just use fit, predict or evaluate.

length=len(labels)
test_steps=  int(length/batch_size) +1
preds=model.predict(test_gen,  verbose=0, steps=test_steps)

看一下您的pred,第一个预测应该是对于索引= 4,这是E类,所以是正确的;第二个预测概率最高的概率是1,这是B类,所以是正确的,其余的也是.您确定标签为labels = test_gen.labels

Looking at your preds print out the first prediction should have been for index=4 which is class E so that is correct, second prediction index with highest probability is 1 which is class B so that is correct, so are the rest. Are you sure you have the labels as labels=test_gen.labels