Reputation: 2015
If I call x,y = sess.run([X,f(X)])
, is X
computed once or twice? I'm asking because in my case the value of X
is not deterministic, and it's necessary that f
be evaluated on the same 'instance' of X
.
Upvotes: 1
Views: 103
Reputation: 5326
It will only compute it once. It would not make sense if it recomputed the dependent variables. Just about all variables in a tensorflow model are dependent on one another.
Upvotes: 0
Reputation: 4918
To make sure that f
uses the current X
you can set up dependencies.
with tf.control_dependencies([X]):
y = f(X)
x, y_ = sess.run([X, y])
Upvotes: 1