In which cases should tf.Session()
and tf.InteractiveSession()
be considered for what purpose?
When I tried to use the former one, some fun
Mainly taken from official documentation:
The only difference with a regular Session is that an InteractiveSession installs itself as the default session on construction. The methods Tensor.eval() and Operation.run() will use that session to run ops.
This allows to use interactive context, like shell, as it avoids having to pass an explicit Session object to run op:
sess = tf.InteractiveSession()
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b
# We can just use 'c.eval()' without passing 'sess'
print(c.eval())
sess.close()
It is also possible to say, that InteractiveSession
supports less typing, as allows to run variables without needing to constantly refer to the session object.