I'm running tf2.0 and simply can not print the confusion matrix values. The problem is described below.
@tf.function
def test_step(self, x , y):
predictions = model(x, training=False)
loss = self.loss(y, predictions)
y, predictions = tf.reshape(y,[-1,]), tf.reshape(predictions, [-1,])
# Cast into class labels
predictions = math_ops.cast(predictions > 0.5, predictions.dtype)
....
self.test_conf_matrix = tf.math.confusion_matrix(y, predictions, num_classes=2) <--- important line!
Everything is going well so far, and the confusion matrix will be computed properly.
But it is simply not possible to print it out in the end like:
print(str(self.test_conf_matrix.numpy()))
The error I get is:
AttributeError: 'Tensor' object has no attribute 'numpy'
But since tf2 and eagerExecution this should be done this way, right? See: TF2.0 Tutorial