首页 > 解决方案 > 为什么要减小 text_label 形状?

问题描述

我已经拍摄了 160 张数据图像进行测试,在训练我的图像数据集和打印 test_label 形状和预测形状之后,

print("Test Label shape: ",test_labels.shape)
print("Predictions shape: ",predictions.shape)

Test Label shape:  (160,)
Predictions shape:  (10, 2)

从预测形状和测试标签形状我应该减少 test_label 形状否则它会显示错误所以我使用下面的代码来获取混淆矩阵,

cm = confusion_matrix(test_labels[:-150], predictions.argmax(axis=1))

在使用下面的代码后,它会打印出矩阵,

import itertools
cm_plot_labels = ['disease_leaf','fresh_leaf']
plot_confusion_matrix(cm, cm_plot_labels, title='Confusion Mtrix')

在矩阵下方, [[10, 0] [ 0, 0]]

注意: 现在我对矩阵感到困惑并有一些疑问,请分享一下谁知道为什么需要减小 test_label 形状的意见?

是否可以在不减小 test_label 形状的情况下打印混淆矩阵。因为为了减小形状,混淆矩阵提供了 10 个之间的混淆矩阵,但我认为它应该提供 160 个之间的混淆矩阵。

标签: pythondeep-learningconfusion-matrixmobilenet

解决方案


推荐阅读