W3cubDocs

/TensorFlow 2.3

tf.keras.backend.print_tensor

View source on GitHub

Prints message and the tensor value when evaluated.

Note that print_tensor returns a new tensor identical to x which should be used in the following code. Otherwise the print operation is not taken into account during evaluation.

Example:

x = tf.constant([[1.0, 2.0], [3.0, 4.0]])
tf.keras.backend.print_tensor(x)
<tf.Tensor: shape=(2, 2), dtype=float32, numpy=
  array([[1., 2.],
         [3., 4.]], dtype=float32)>
Arguments
x Tensor to print.
message Message to print jointly with the tensor.
Returns
The same tensor x, unchanged.

© 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/r2.3/api_docs/python/tf/keras/backend/print_tensor