tf.compat.v1.train.SingularMonitoredSession

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 tf.compat.v1.train.MonitoredSession. The differences between MonitoredSession and SingularMonitoredSession are:

Example usage:

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:

Run: When run() is called, the hooked session does following things:

Exit: At the close(), the hooked session does following things in order:

Args:

Attributes:

Child Classes

class StepContext

Methods

__enter__

View source

__enter__()

__exit__

View source

__exit__(
    exception_type, exception_value, traceback
)

close

View source

close()

raw_session

View source

raw_session()

Returns underlying TensorFlow.Session object.

run

View source

run(
    fetches, feed_dict=None, options=None, run_metadata=None
)

Run ops in the monitored session.

This method is completely compatible with the tf.Session.run() method.

Args:

Returns:

Same as tf.Session.run().

run_step_fn

View source

run_step_fn(
    step_fn
)

Run ops using a step function.

Args:

Returns:

Returns the returned value of step_fn.

Raises:

should_stop

View source

should_stop()