From d22c433216254d2e6ab33a849f922b4545d1f7dd Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Sat, 8 Jul 2017 16:49:51 -0700 Subject: Fix typos in comments. PiperOrigin-RevId: 161305803 --- tensorflow/python/training/monitored_session.py | 2 +- tensorflow/python/training/session_run_hook.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'tensorflow') diff --git a/tensorflow/python/training/monitored_session.py b/tensorflow/python/training/monitored_session.py index e7b296374a..2feb6bd3c3 100644 --- a/tensorflow/python/training/monitored_session.py +++ b/tensorflow/python/training/monitored_session.py @@ -92,7 +92,7 @@ class Scaffold(object): * `init_feed_dict`: A session feed dictionary that should be used when running the init op. - * `init_fn`: A callable to run run after the init op to perform additional + * `init_fn`: A callable to run after the init op to perform additional initializations. The callable will be called as `init_fn(scaffold, session)`. diff --git a/tensorflow/python/training/session_run_hook.py b/tensorflow/python/training/session_run_hook.py index 09da63eb68..dbeabd250e 100644 --- a/tensorflow/python/training/session_run_hook.py +++ b/tensorflow/python/training/session_run_hook.py @@ -42,23 +42,28 @@ For more specific needs, you can create custom hooks: print('Starting the session.') self.your_tensor = ... - def end(self, session): - print('Done with the session.') + def after_create_session(self, session, coord): + # When this is called, the graph is finalized and + # ops can no longer be added to the graph. + print('Session created.') def before_run(self, run_context): - print('before calling session.run) + print('Before calling session.run().') return SessionRunArgs(self.your_tensor) - def after_run(self, run_context, run_values) + def after_run(self, run_context, run_values): print('Done running one step. The value of my tensor: %s', run_values.results) if you-need-to-stop-loop: run_context.request_stop() + def end(self, session): + print('Done with the session.') + To understand how hooks interact with calls to `MonitoredSession.run()`, look at following code: - with SupervisedSession(hooks=your_hooks, ...) as sess - while not sess.should_stop() + with MonitoredTrainingSession(hooks=your_hooks, ...) as sess: + while not sess.should_stop(): sess.run(your_fetches) Above user code leads to following execution: @@ -68,7 +73,7 @@ Above user code leads to following execution: while not stop is requested: call hooks.before_run() try: - results = sess.run(merged_fetches) + results = sess.run(merged_fetches, feed_dict=merged_feeds) except (errors.OutOfRangeError, StopIteration): break call hooks.after_run() -- cgit v1.2.3