How to print the value of a Tensor object in TensorFlow ?
Here is an solution print a value of a tensor whenever the graph is evaluated by using run or eval function:
# Initialize session import tensorflow as tf sess = tf.InteractiveSession() # Some tensor we want to print the value of a = tf.constant([1.0, 3.0]) # Add print operation a = tf.Print(a, [a], message="This is a: ") # Add more elements of the graph using a b = tf.add(a, a)
To evaluate the Whole graph use b.eval(), for example:
I tensorflow/core/kernels/logging_ops.cc:79] This is a: [1 3]