plt.imshow 不显示“子”图片

时间:2021-03-31 11:46:06

标签: python matplotlib

我正在尝试使用 CNN 在包含感染疟疾和未感染疟疾的细胞的数据集上可视化分类错误的图像。

这是我的代码:

index=0
index_errors= []

for label, predict in zip(y_test,y_pred):
    if label != predict:
        index_errors.append(index)
    index +=1

plt.figure(figsize=(20,8))

for i,img_index in zip(range(1,17),random.sample(index_errors,k=16)):
    plt.subplot(2,8,i)
    plt.imshow(X_test[img_index])
    plt.title('Actual: '+str(y_test[img_index])+' Predict: '+str(y_pred[img_index]))
plt.show()

The output

由于某种原因,个别图像没有显示,但我无法弄清楚是什么导致了这种情况,因为我没有遇到任何错误?

提前致谢!

0 个答案:

没有答案