【发布时间】:2021-09-27 11:53:03
【问题描述】:
我的 NN 模型预测图像的标签和分数(参见示例图像,分数是图像下方的浮点数,标签是右侧的属性)
我想制作一个直方图来显示哪些属性(标签)被预测得更多。所以我想索引标签并找到它们的数量,但我不知道该怎么做。
我将所有输出附加到数组 (preds_array) 中,attributes 是标签数组,然后我这样做了:
outputs_array = [j for i in zip(preds_array, attributes) for j in i] #zip the output scores with their labels
#The outputs_array looks like this#
[0.21103, array(['dirty'], dtype=object), 0.99764, array(['daylight'], dtype=object), 0.000802, array(['night'], dtype=object)
%matplotlib inline
np.random.seed(42)
plt.hist(outputs_array, density=False, bins=30)
plt.ylabel('Count')
plt.xlabel('Predicted Labels');
但它返回一个错误。 有什么想法吗?
【问题讨论】:
标签: python arrays matplotlib histogram