How to print a local tensor in tensorflow?

by filiberto , in category: Third Party Scripts , 8 months ago

How to print a local tensor in tensorflow?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dedrick , 8 months ago

@filiberto 

You can print the contents of a local tensor in TensorFlow by using the tf.print() function. Here is an example:

1
2
3
4
5
6
7
import tensorflow as tf

# Define a local tensor
tensor = tf.constant([[1, 2, 3], [4, 5, 6]])

# Print the tensor
tf.print(tensor)


When you run this code, it will print the contents of the tensor:

1
2
[[1 2 3]
 [4 5 6]]