I've got some troubles during the model evaluation using Tensorflow with the Experimenter API.
I used to work using 2-classes NN, but this time I manage to train a 4-classes one and I need to figure out how to build a confusion matrix in this case. I tried using the tf.confusion_matrix function, but it doesn't work at all.
This is the fragment of code that I used:
if mode == ModeKeys.EVAL:
eval_metric_ops = {
'accuracy' : metrics.streaming_accuracy(predictions=predicted_classes, labels=labels),
# Other metrics...
'confusion_matrix': tf.confusion_matrix(prediction=predicted_classes, label=labels, num_classes=4)
}
return tf.estimator.EstimatorSpec(
mode=mode,
predictions=predicted_classes,
loss=loss,
eval_metric_ops=eval_metric_ops
)
And this is the error that I got:
TypeError: Values of eval_metric_ops must be (metric_value, update_op) tuples, given: (<tf.Operation 'test/group_deps' type=NoOp>, <tf.Tensor 'test/accuracy/value:0' shape=() dtype=float32>, <tf.Variable 'test/confusion:0' shape=(4, 4) dtype=int32_ref>) for key: confusion_matrix
I read other answers about to create a confusion matrix in Tensorflow and I understood how to do it, but I think that my question is more related to the Estimator/Experimenter API.