Session

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:
  # sess.run like normal

See also the official TensorFlow docs on Session.

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

Wrap a Tensorflow Session.

See the documentation of tf.Session for more details.

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

See the documentation for tf.Session.run 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.

Parameters:
  • 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 tf.Session.run docs).
  • feed_dict (str->np.ndarray) – A dictionary that maps graph elements to values (described in tf.Session.run 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.