Reputation: 2923
It seems to be more convenient to simply use something like sub.eval()
instead of sess.run(eval)
, so would it be more convenient to always use InteractiveSession()
? Are there any tradeoffs if we were to use InteractiveSession()
all the time?
So far the only 'disadvantage' I see is that I can't use something like:
with tf.InteractiveSession() as sess:
result = product.eval() #Where product is a simple matmul
print result
sess.close()
Instead I've to just define sess = tf.InteractiveSession
right away.
Upvotes: 2
Views: 347
Reputation: 3358
From their implementation, the InteractiveSession
sets itself as the default session and your subsequent eval()
calls can use this session. You should be able to use the InteractiveSession
in almost all the cases where you use Session
.
One small difference is that you don't need to use InteractiveSession
in a with
block:
sess = tf.InteractiveSession()
# do your work
sess.close()
So don't forget to close the session after doing your work.
Here is an comparison between session.run()
and eval()
: In TensorFlow, what is the difference between Session.run() and Tensor.eval()?
Upvotes: 1