简体   繁体   中英

what is meaning of hook that used in tensorflow

I couldn't understand the exact meaning of Hook in python, tensorflow

_LearningRateSetterHook(tf.train.SessionRun**Hook**):

I would greatly appreciate it if you explain it to me. Thank you

This could be a more general question about what hooks are.

Hooks are named appropriately in that they allow a way to 'hook into' certain points of the execution of a program. Thus you could trigger a function or logging after a certain part of the code executes.

To give an example I have listed the description of the SessionRunHook that you mentioned along with a link to its documentation. It specifically allows you to 'hook' into the mentioned points.

SessionRunHooks are useful to track training, report progress, request early stopping and more. SessionRunHooks use the observer pattern and notify at the following points:

  • when a session starts being used
  • before a call to the session.run()
  • after a call to the session.run()
  • when the session closed

A SessionRunHook encapsulates a piece of reusable/composable computation that can piggyback a call to MonitoredSession.run() . A hook can add any ops-or-tensor/feeds to the run call, and when the run call finishes with success gets the outputs it requested. Hooks are allowed to add ops to the graph in hook.begin() . The graph is finalized after the begin() method is called.

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/training/session_run_hook.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM