Reputation: 5743
An extreme case of what i am trying to ask is :
tf.Session().run(fetches = [a,a], feed_dict = feed_dict)
does tensorflow here run the same computations twice?
Upvotes: 1
Views: 29
Reputation: 32061
No, tensorflow will compute only what you request, no more and no less. If two computations depend on the same bit of code, for example two loss functions depending on the same neural network core, the core will not be computed twice. On the flip side of that note that if an OP in tensorflow is not needed to perform a computation, tensorflow will not compute it. This is the magic that the tensorflow dependency graph provides.
Note also that between calls to sess.run
any OPs (operations) will be re-computed because OPs are not stored between calls to sess.run
, the only thing that remains between calls to sess.run
are variables.
Upvotes: 2