tree: 2fc9200b6dbc1d811527c2097a879bbbf1894e38 [path history] [tgz]
  1. python/
  2. __init__.py
  3. BUILD
  4. README.md
tensorflow/contrib/hooks/README.md

TensorFlow Experimental SessionRunHooks

These hooks complement those in tensorflow/python/training. They are instances of SessionRunHook and are to be used with helpers like MonitoredSession and learn.Estimator that wrap tensorflow.Session.

The hooks are called between invocations of Session.run() to perform custom behavior.

For example the ProfilerHook periodically collects RunMetadata after Session.run() and saves profiling information that can be viewed in a neat timeline through a Chromium-based web browser (via about:tracing) or the standalone Catapult tool.

from tensorflow.contrib.hooks import ProfilerHook

hooks = [ProfilerHook(save_secs=30, output_dir="profiling")]
with SingularMonitoredSession(hooks=hooks) as sess:
  while not sess.should_stop():
    sess.run(some_op)

Or similarly with contrib.learn:

hooks = [ProfilerHook(save_steps=10, output_dir="profiling")]
estimator = learn.Estimator(...)
estimator.fit(input_fn, monitors=hooks)