tf.set_random_seed()

tf.set_random_seed(seed) Sets the graph-level random seed. Operations that rely on a random seed actually derive it from two seeds: the graph-level and operation-level seeds. This sets the graph-level seed. Its interactions with operation-level seeds is as follows: If neither the graph-level nor the operation seed is set: A random seed is used for this op. If the graph-level seed is set, but the operation seed is not: The system deterministically picks an operation seed in conjunction with the

tf.Session.__init__()

tf.Session.__init__(target='', graph=None, config=None) Creates a new TensorFlow session. If no graph argument is specified when constructing the session, the default graph will be launched in the session. If you are using more than one graph (created with tf.Graph() in the same process, you will have to use different sessions for each graph, but each graph can be used in multiple sessions. In this case, it is often clearer to pass the graph to be launched explicitly to the session constructor

tf.Session.__exit__()

tf.Session.__exit__(exec_type, exec_value, exec_tb)

tf.Session.__enter__()

tf.Session.__enter__()

tf.Session.run()

tf.Session.run(fetches, feed_dict=None, options=None, run_metadata=None) Runs operations and evaluates tensors in fetches. This method runs one "step" of TensorFlow computation, by running the necessary graph fragment to execute every Operation and evaluate every Tensor in fetches, substituting the values in feed_dict for the corresponding input values. The fetches argument may be a single graph element, or an arbitrarily nested list, tuple, namedtuple, or dict containing graph elements at its

tf.Session.reset()

tf.Session.reset(target, containers=None, config=None) Resets resource containers on target, and close all connected sessions. A resource container is distributed across all workers in the same cluster as target. When a resource container on target is reset, resources associated with that container will be cleared. In particular, all Variables in the container will become undefined: they lose their values and shapes. NOTE: (i) reset() is currently only implemented for distributed sessions. (ii

tf.Session.graph

tf.Session.graph The graph that was launched in this session.

tf.Session.close()

tf.Session.close() Closes this session. Calling this method frees all resources associated with the session. Raises: tf.errors.OpError: Or one of its subclasses if an error occurs while closing the TensorFlow session.

tf.Session.as_default()

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

tf.Session

class tf.Session A class for running TensorFlow operations. A Session object encapsulates the environment in which Operation objects are executed, and Tensor objects are evaluated. For example: # Build a graph. a = tf.constant(5.0) b = tf.constant(6.0) c = a * b # Launch the graph in a session. sess = tf.Session() # Evaluate the tensor `c`. print(sess.run(c)) A session may own resources, such as variables, queues, and readers. It is important to release these resources when they are no long