Session is an extension of tf.Session that lets the graph run in a secure manner.

The aim of tf-encrypted is to look as close to TensorFlow as possible. With this goal in mind, you get and use a session the same way that you’re used to with Tensorflow:

import tf_encrypted as tfe

with tfe.Session() as sess:
  # like normal

See also the official TensorFlow docs on Session.

class tf_encrypted.session.Session(graph=None, config=None)[source]

Wrap a Tensorflow Session.

See the documentation of tf.Session for more details.

  • graph (Optional[tf.Graph]) – A tf.Graph. Used in the same as in tensorflow. This is the graph to be launched. If nothing is specified then the default session graph will be used.
  • config (Optional[Config]) – A Local or Remote config to be used to execute the graph.
run(fetches, feed_dict, tag, write_trace) → Any[source]

See the documentation for for more details.

This method functions just as the one from tensorflow.

The value returned by run() has the same shape as the fetches argument, where the leaves are replaced by the corresponding values returned by TensorFlow.

  • fetches (Any) – A single graph element, a list of graph elements, or a dictionary whose values are graph elements or lists of graph elements (described in docs).
  • feed_dict (str->np.ndarray) – A dictionary that maps graph elements to values (described in docs).
  • tag (str) – An optional namespace to run the session under.
  • write_trace (bool) – If true, the session logs will be dumped for use in Tensorboard.