tf.compat.v1.train.MonitoredSession.StepContext
Stay organized with collections
Save and categorize content based on your preferences.
Control flow instrument for the step_fn
from run_step_fn()
.
tf.compat.v1.train.MonitoredSession.StepContext(
session, run_with_hooks_fn
)
Users of step_fn
may perform run()
calls without running hooks
by accessing the session
. A run()
call with hooks may be performed
using run_with_hooks()
. Computation flow can be interrupted using
request_stop()
.
Args |
session
|
An instance of tf.compat.v1.Session .
|
run_with_hooks_fn
|
A function for running fetches and hooks.
|
Methods
request_stop
View source
request_stop()
Exit the training loop by causing should_stop()
to return True
.
Causes step_fn
to exit by raising an exception.
run_with_hooks
View source
run_with_hooks(
*args, **kwargs
)
Same as MonitoredSession.run
. Accepts the same arguments.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.train.MonitoredSession.StepContext\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/training/monitored_session.py#L840-L875) |\n\nControl flow instrument for the `step_fn` from `run_step_fn()`.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.train.SingularMonitoredSession.StepContext`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/train/MonitoredSession/StepContext)\n\n\u003cbr /\u003e\n\n tf.compat.v1.train.MonitoredSession.StepContext(\n session, run_with_hooks_fn\n )\n\nUsers of `step_fn` may perform `run()` calls without running hooks\nby accessing the `session`. A `run()` call with hooks may be performed\nusing `run_with_hooks()`. Computation flow can be interrupted using\n`request_stop()`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------|-------------------------------------------------------------------------------|\n| `session` | An instance of [`tf.compat.v1.Session`](../../../../../tf/compat/v1/Session). |\n| `run_with_hooks_fn` | A function for running fetches and hooks. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------|---------------|\n| `session` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `request_stop`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/training/monitored_session.py#L867-L875) \n\n request_stop()\n\nExit the training loop by causing `should_stop()` to return `True`.\n\nCauses `step_fn` to exit by raising an exception.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|---|---|\n| StopIteration ||\n\n\u003cbr /\u003e\n\n### `run_with_hooks`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/training/monitored_session.py#L863-L865) \n\n run_with_hooks(\n *args, **kwargs\n )\n\nSame as `MonitoredSession.run`. Accepts the same arguments."]]