简体   繁体   中英

Confusion Matrix for Deep Learning

I have been trying to print out the confusion matrix for my model but failed to do so.

However, I successfully obtained a (7x7) confusion matrix but in tensor format.

I am new to Tensorflow so please help me with displaying the tensor. Thank you.

code:

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))

output:

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"]()]]

It seems you are not feeding the input placeholder value to calculate the tensor correct.

feeddict = {your_placeholder: value}
with tf.Session() as sess:
    print('Confusion Matrix: \n\n', tf.Tensor.eval(con_mat, feed_dict=feeddict, session=sess))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM