|View source on GitHub|
Session-like object that handles initialization, restoring, and hooks.
tf.compat.v1.train.SingularMonitoredSession( hooks=None, scaffold=None, master='', config=None, checkpoint_dir=None, stop_grace_period_secs=120, checkpoint_filename_with_path=None )
Please note that this utility is not recommended for distributed settings.
For distributed settings, please use
UnavailableErrorfor distributed settings, but
MonitoredSessioncan be created in
SingularMonitoredSessionis always created as
- You can access the raw
tf.compat.v1.Sessionobject used by
SingularMonitoredSession, whereas in MonitoredSession the raw session is private. This can be used:
- To save and restore.
- All other functionality is identical.
saver_hook = CheckpointSaverHook(...) summary_hook = SummarySaverHook(...) with SingularMonitoredSession(hooks=[saver_hook, summary_hook]) as sess: while not sess.should_stop(): sess.run(train_op)
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.
An iterable of
||A string. Optional path to a checkpoint file from which to restore variables.|
||The graph that was launched in this session.|
run( fetches, feed_dict=None, options=None, run_metadata=None )
Run ops in the monitored session.
This method is completely compatible with the
run_step_fn( step_fn )
Run ops using a step function.
A function or a method with a single argument of type
Hooks interact with the
Returns the returned value of