How to print a local tensor in tensorflow?

by filiberto , in category: Third Party Scripts , 11 days ago

How to print a local tensor in tensorflow?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dedrick , 11 days 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]]