Skip to content Skip to sidebar Skip to footer

Does Tensorflow Rerun For Each Eval() Call?

In Tensorflow and Python, I am doing the following sort of thing to understand Tensorflow and debug code by observing multiple variables at the end of a computation. with tf.Sessi

Solution 1:

When you call Tensor.eval(), TensorFlow (i) works out what subgraph of the whole graph it needs to run to produce the value of that tensor, then (ii) runs that entire graph.

It is often more efficient to use Session.run() to fetch the values of multiple tensors at once. For example, you could rewrite your code as follows to run the graph once:

with tf.Session() as sess:
    val1, val2 = sess.run([var1, var2], {x:myInputs, y:myOutputs})
    print"var1 =", val1
    print"var2 =", val2

Post a Comment for "Does Tensorflow Rerun For Each Eval() Call?"