edflow.hooks.util_hooks module

Summary

Classes:

ExpandHook

Retrieve paths.

IntervalHook

This hook manages a set of hooks, which it will run each time its interval flag is set to True.

Reference

class edflow.hooks.util_hooks.ExpandHook(paths, interval, default=None)[source]

Bases: edflow.hooks.hook.Hook

Retrieve paths.

__init__(paths, interval, default=None)[source]
Parameters
  • paths (list of keypaths to expand.) –

  • interval (int) – The interval in which expansion is performed.

after_step(step, last_results)[source]

Called after each step.

class edflow.hooks.util_hooks.IntervalHook(hooks, interval, start=None, stop=None, modify_each=None, modifier=<function IntervalHook.<lambda>>, max_interval=None, get_step=None)[source]

Bases: edflow.hooks.hook.Hook

This hook manages a set of hooks, which it will run each time its interval flag is set to True.

__init__(hooks, interval, start=None, stop=None, modify_each=None, modifier=<function IntervalHook.<lambda>>, max_interval=None, get_step=None)[source]
Parameters
  • hook (list of Hook) – The set of managed hooks. Each must implement the methods of a Hook.

  • interval (int) – The number of steps after which the managed hooks are run.

  • start (int) – If start is not None, the first time the hooks are run ist after start number of steps have been made.

  • stop (int) – If given, this hook is not evaluated anymore after stop steps.

  • modify_each (int) – If given, modifier is called on the interval after this many executions of thois hook. If None it is set to interval. In case you do not want any mofification you can either set max_interval to interval or choose the modifier to be lambda x: x or set modify_each to float: inf).

  • modifier (Callable) – See modify_each.

  • max_interval (int) – If given, the modifier can only increase the interval up to this number of steps.

  • get_step (Callable) – If given, prefer over the use of batch index to determine run condition, e.g. to run based on global step.

run_condition(step, is_before=False)[source]
maybe_modify(step)[source]
before_epoch(*args, **kwargs)[source]

Called before each epoch.

before_step(step, *args, **kwargs)[source]

Called before each step. Can update any feeds and fetches.

after_step(step, *args, **kwargs)[source]

Called after each step.

after_epoch(*args, **kwargs)[source]

Called after each epoch.