ValueError: Classification metrics can‘t handle a mix of multiclass and continuous-multioutput targe

画混淆矩阵的时候,报的错误  因为真实与预测维度不一致导致

#原本的
predictions = model.predict(x_val, batch_size=BS)
truelabel = y_val.argmax(axis=-1)# 将one-hot转化为label
conf_mat = confusion_matrix(y_true=truelabel, y_pred=predictions)


#修改后的
predictions = model.predict(x_val, batch_size=BS).argmax(axis=1)
truelabel = y_val.argmax(axis=-1)# 将one-hot转化为label
conf_mat = confusion_matrix(y_true=truelabel, y_pred=predictions)

你可能感兴趣的:(python)