W3cubDocs

/TensorFlow 1.15

tf.Print

Prints a list of tensors. (deprecated)

This is an identity op (behaves like tf.identity) with the side effect of printing data when evaluating.

Note: This op prints to the standard error. It is not currently compatible with jupyter notebook (printing to the notebook server's output, not into the notebook).
Args
input_ A tensor passed through this op.
data A list of tensors to print out when op is evaluated.
message A string, prefix of the error message.
first_n Only log first_n number of times. Negative numbers log always; this is the default.
summarize Only print this many entries of each tensor. If None, then a maximum of 3 elements are printed per input tensor.
name A name for the operation (optional).
Returns
A Tensor. Has the same type and contents as input_.
sess = tf.compat.v1.Session()
with sess.as_default():
tensor = tf.range(10)
print_op = tf.print(tensor)
with tf.control_dependencies([print_op]):
out = tf.add(tensor, tensor)
sess.run(out)

Additionally, to use tf.print in python 2.7, users must make sure to import the following:

from __future__ import print_function

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/Print