在之前的步骤中,我们已经完成来训练,现在要使用test测试数据来评估模型准确率,用下面的程序带来来评估模型的准确率
scores = model.evaluate(x_Test4D,y_TestOneHot)
32/10000 […………………………] – ETA: 4s
192/10000 […………………………] – ETA: 3s
352/10000 [>………………………..] – ETA: 3s
512/10000 [>………………………..] – ETA: 3s
672/10000 [=>……………………….] – ETA: 3s
736/10000 [=>……………………….] – ETA: 3s
832/10000 [=>……………………….] – ETA: 3s
992/10000 [=>……………………….] – ETA: 3s
9152/10000 [==========================>…] – ETA: 0s
9312/10000 [==========================>…] – ETA: 0s
9472/10000 [===========================>..] – ETA: 0s
9600/10000 [===========================>..] – ETA: 0s
9760/10000 [============================>.] – ETA: 0s
9920/10000 [============================>.] – ETA: 0s
10000/10000 [==============================] – 4s 379us/step
0.9903
1.执行预测
下面程序代码使用model.predict_classes输入参数x_test4d_normalize进行预测
2.预测结果
我们查看前10项数据
prediction = model.predict_classes(x_Test4D_normalize)
print(prediction[:10])
显示前10项训练结果
3.显示混淆矩阵
predict 0 1 2 3 4 5 6 7 8 9
label
0 976 0 0 0 0 0 2 1 1 0
1 0 1130 1 0 0 1 1 1 1 0
2 1 0 1029 0 0 0 0 2 0 0
3 0 0 1 1002 0 2 0 3 2 0
4 0 0 0 0 975 0 1 0 1 5
5 1 1 0 5 0 882 2 0 0 1
6 4 2 0 1 1 1 948 0 1 0
7 0 1 6 0 0 0 0 1018 1 2
8 3 0 3 2 1 1 0 2 959 3
9 3 4 1 2 5 1 0 3 0 990