Printing tensor values with tf.Print()
Another option to print values for debugging purposes is to use tf.Print()
. You can wrap a tensor in tf.Print()
to print its values in the standard error console when the path containing the tf.Print()
node is executed. The tf.Print()
function has the following signature:
tf.Print( input_, data, message=None, first_n=None, summarize=None, name=None )
The arguments to this function are as follows:
input_
is a tensor that gets returned from the function without anything being done to itdata
is the list of tensors that get printedmessage
is a string that gets printed as a prefix to the printed outputfirst_n
represents the number of steps to print the output; if this value is negative then the value is always printed whenever the path is executedsummarize
represents the number of elements to print from the tensor; by default, only three elements are printed
Note
You can follow along with the code in the Jupyter notebook ch-18_TensorFlow_Debugging...