See the guide: Training > Distributed execution
Session-like object that handles initialization, restoring, and hooks.
Please note that this utility is not recommended for distributed settings.
For distributed settings, please use
AbortedError for distributed settings,
SingularMonitoredSession does not.
MonitoredSession can be created in
SingularMonitoredSession is always created as
* You can access the raw
tf.Session object used by
SingularMonitoredSession, whereas in MonitoredSession the raw session is
private. This can be used:
run without hooks.
- To save and restore.
* All other functionality is identical.
saver_hook = CheckpointSaverHook(...)
summary_hook = SummaryHook(...)
with SingularMonitoredSession(hooks=[saver_hook, summary_hook]) as sess:
while not sess.should_stop():
Initialization: At creation time the hooked session does following things in given order:
hook.begin()for each given hook
- finalizes the graph via
- create session
- initializes the model via initialization ops provided by
- restores variables if a checkpoint exists
- launches queue runners
run() is called, the hooked session does following things:
- calls TensorFlow
session.run()with merged fetches and feed_dict
- returns result of
session.run()asked by user
Exit: At the
close(), the hooked session does following things in order:
- closes the queue runners and the session
OutOfRangeerror which indicates that all inputs have been processed if the
SingularMonitoredSessionis used as a context.
The graph that was launched in this session.
__init__(hooks=None, scaffold=None, master='', config=None, checkpoint_dir=None)
Creates a SingularMonitoredSession.
hooks: An iterable of `SessionRunHook' objects.
Scaffoldused for gathering or building supportive ops. If not specified a default one is created. It's used to finalize the graph.
Stringrepresentation of the TensorFlow master to use.
ConfigProtoproto used to configure the session.
checkpoint_dir: A string. Optional path to a directory where to restore variables.
run(fetches, feed_dict=None, options=None, run_metadata=None)
Run ops in the monitored session.
This method is completely compatible with the
fetches: Same as
feed_dict: Same as
options: Same as
run_metadata: Same as