A session in TensorFlow encapsulates the environment in which tensor objects are evaluated. Sessions can have their private variables, queues, and readers that are designated. We should use the close method at the end of the session.
The session has three arguments, which are optional:
- Target: The execution engine to connect to
- graph: The graph object to be started
- config: This is a ConfigProto protocol buffer
To run a single step of the TensorFlow computation, the step function is invoked and necessary dependencies of the graph are executed:
# session objectsa = tf.constant(6.0)b = tf.constant(7.0)c = a * bwith tf.Session() as sess: print(sess.run(c)) print(c.eval())
sess.run(c) in the currently active session!
The preceding ...