我一直在尝试打印出我的模型的混乱矩阵,但未能如愿。深度学习的混乱矩阵
但是,我成功地获得了一个(7x7)混淆矩阵但是张量格式。
我是Tensorflow新手,所以请帮助我显示张量。谢谢。
代码:
con_mat = tf.confusion_matrix(labels=[0, 1, 2, 3, 4, 5, 6], predictions=correct, num_classes=n_classes,
dtype=tf.int32, name=None)
with tf.Session():
print('Confusion Matrix: \n\n', tf.Tensor.eval(con_mat, feed_dict=None, session=None))
输出:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape [-1,100,88] has negative dimensions
[[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[?,100,88], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
这不是你在TF中运行的东西。它应该是:'用tf.Session()as sess:print(sess.run(con_mat))'(也有其他错误,但是免得以基础开始;特别是 - 错误与占位符相关 - 你在哪里使用在你的代码中占位符?) – lejlot