Skip to content Skip to sidebar Skip to footer

When Trying To Run Tf.confusion Matrix It Gives End Of Sequence Error

I am preparing my dataset using new tensoflow input pipeline, here is my code: train_data = tf.data.Dataset.from_tensor_slices(train_images) train_labels = tf.data.Dataset.from_ten

Solution 1:

The problem is related with the graph flow execution. Look at this line:

print(sess.run(confusion, feed_dict={keep_prob: 1.0}))

You are running the graph for getting the 'confusion' value. So all dependent nodes will be also executed. Then:

finalprediction = tf.argmax(train_predict, 1)
actualprediction = tf.argmax(val_label_list, 1)
confusion = tf.confusion_matrix(...)

I guess that your call to train_predict will try to obtain a new element from the training iterator which has been already completely iterated and after this the error is triggered.

You should compute the confusion matrix directly in the loop and accumulate the results in a variable.

sess.run(valid_init_op)
confusion_matrix = np.zeros(n_labels,n_labels)
whileTrue:
      try:
          conf_matrix = sess.run(confusion)
          confusion_matrix += conf_matrix
      except tf.errors.OutOfRangeError:
          print("End of append.")
      break

Post a Comment for "When Trying To Run Tf.confusion Matrix It Gives End Of Sequence Error"