conf_mat=np.zeros([5, 5])
# 先定义一个空的混淆矩阵
print("以下是输出的预测值和标签值")
print("预测值为:"+str(out_spikes_counter.max(1)[1]))
print("标签值为:"+str(label))
true_batch_i = label.cpu().numpy() # 这个是真实标签
pre_batch_i = out_spikes_counter.max(1)[1].cpu().numpy() # 这个是预测角标
for i in range(len(true_batch_i)):
# 这个地方如果range里面直接写64的话,会报错,因为最后一组数据没有64个
# 所以最好使用len(true_batch_i)的方式
true_i = np.array(true_batch_i[i])
pre_i = np.array(pre_batch_i[i])
conf_mat[true_i, pre_i] += 1.0
print('混淆矩阵为:')
print(conf_mat)
















