How to print the value of a Tensor object in TensorFlow?

Answers • 2 Asked • Mar 16 2019
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
When I print the product, it is displaying it as a Tensor object:
<tensorflow.python.framework.ops.Tensor object at 0x10470fcd0>

But how do I know the value of product? The following doesn't help:
print product
Tensor("MatMul:0", shape=TensorShape([Dimension(1), Dimension(1)]), dtype=float32)

I know that graphs run on Sessions, but isn't there any way I can check the output of a Tensorobject without running the graph in a session?

Write your answer...

On a mission to build Next-Gen Community Platform for Developers