I struggle to apply answers to similar questions, with Tensorflow 2.6.0.
I would like to inspect the values in my tensor during debugging. If I do a Python print
predicted_ids=tf.random.categorical(predicted_logits, num_samples=1)
predicted_ids=tf.squeeze(predicted_ids, axis=-1)
print(predicted_ids)
I get
Tensor("Squeeze:0", shape=(1,), dtype=int64)
I then try to
(1)
print(tf.Print(predicted_ids, [predicted_ids], message="This is predicted_ids: "))
(2)
with tf.Session() as sess: print(predicted_ids.eval())
(3)
sess = tf.InteractiveSession()
a = tf.Print(predicted_ids, [predicted_ids], message="This is predicted_ids: ")
All of which will throw errors. It seems to me this is a very common question, and there must be an elegant robust simple answer, in TF 2.6.0.