Type InteractiveSession
Namespace tensorflow
Parent BaseSession
Interfaces IInteractiveSession
A TensorFlow `Session` for use in interactive contexts, such as a shell. The only difference with a regular `Session` is that an `InteractiveSession`
installs itself as the default session on construction.
The methods
tf.Tensor.eval
and tf.Operation.run
will use that session to run ops. This is convenient in interactive shells and [IPython
notebooks](http://ipython.org), as it avoids having to pass an explicit
`Session` object to run ops.
Note that a regular session installs itself as the default session when it
is created in a `with` statement. The common usage in non-interactive
programs is to follow that pattern:
Show Example
sess = tf.compat.v1.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()
Methods
Properties
Public instance methods
IList<_DeviceAttributes> list_devices()
object list_devices_dyn()
Public static methods
InteractiveSession NewDyn(ImplicitContainer<T> target, object graph, object config)
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.
Parameters
-
ImplicitContainer<T>
target - (Optional.) The execution engine to connect to. Defaults to using an in-process engine. See [Distributed TensorFlow](https://tensorflow.org/deploy/distributed) for more examples.
-
object
graph - (Optional.) The `Graph` to be launched (described above).
-
object
config - (Optional.) A [`ConfigProto`](https://www.tensorflow.org/code/tensorflow/core/protobuf/config.proto) protocol buffer with configuration options for the session.