edflow.hooks.metric_hooks.tf_metric_hook module

Summary

Classes:

MetricHook

Applies a set of given metrics to the calculated data.

Reference

class edflow.hooks.metric_hooks.tf_metric_hook.MetricHook(metrics, save_root, consider_only_first=None)[source]

Bases: edflow.hooks.hook.Hook

Applies a set of given metrics to the calculated data.

__init__(metrics, save_root, consider_only_first=None)[source]
Parameters
  • metrics (list) –

    List of MetricTuple``s of the form ``: input names, output names, metric, name).

    • input names are the keys corresponding to the feeds of
      interest, e.g. an original image.
    • output names are the keys corresponding to the values
      in the results dict.
    • metric is a Callable that accepts all inputs and
      outputs keys as keyword arguments
    • name is a

    If nested feeds or results are expected the names can be passed as “path” like 'key1_key2' returning dict[key1][key2].

  • save_root (str) – Path to where the results are stored.

  • consider_only_first (int) – Metric is only evaluated on the first consider_only_first examples.

before_epoch(epoch)[source]

Called before each epoch.

Parameters

epoch (int) – Index of epoch that just started.

before_step(step, fetches, feeds, batch)[source]

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

Parameters
  • step (int) – Current training step.

  • fetches (list or dict) – Fetches for the next session.run call.

  • feeds (dict) – Data used at this step.

  • batch (list or dict) – All data available at this step.

after_step(step, results)[source]

Called after each step.

Parameters
  • step (int) – Current training step.

  • last_results (list) – Results from last time this hook was called.

after_epoch(epoch)[source]

Called after each epoch.

Parameters

epoch (int) – Index of epoch that just ended.