tf.Session.as_default()
Returns a context manager that makes this object the default session.
Use with the with keyword to specify that calls to Operation.run() or Tensor.eval() should be executed in this session.
c = tf.constant(..)
sess = tf.Session()
with sess.as_default():
assert tf.get_default_session() is sess
print(c.eval())
To get the current default session, use tf.get_default_session().
N.B. The as_default context manager does not close the session when you exit the context, an