Fetching tensor values with tf.Session.run()
You can fetch the tensor values you want to print with tf.Session.run()
. The values are returned as a NumPy array and can be printed or logged with Python statements. This is the simplest and easiest approach, with the biggest drawback being that the computation graph executes all the dependent paths, starting from the fetched tensor, and if those paths include the training operations, then it advances one step or one epoch.Â
Therefore, most of the time you would not call tf.Session.run()
to fetch tensors in the middle of the graph, but you would execute the whole graph and fetch all the tensors, the ones you need to debug along with the ones you do not need to debug.
Note
The function tf.Session.partial_run()
 is also available for situations where you may want to execute part of the graph, but it is a highly experimental API and not ready for production use.