CounterCallback

Inheritance Diagram

Inheritance diagram of ashpy.callbacks.counter_callback.CounterCallback

class ashpy.callbacks.counter_callback.CounterCallback(event, fn, name, event_freq=1)[source]

Bases: ashpy.callbacks.callback.Callback

Count events of a specific type. Calls fn passing the context every event_freq.

Useful for logging or for measuring performance. If you want to implement a callback defining a certain behaviour every n_events you can just inherit from CounterCallback.

Methods

__init__(event, fn, name[, event_freq]) Initialize the CounterCallback.
on_event(event, context) Count events and calls fn.

Attributes

name Return the name of the callback.
name_scope Returns a tf.name_scope instance for this class.
submodules Sequence of all sub-modules.
trainable_variables Sequence of variables owned by this module and it’s submodules.
variables Sequence of variables owned by this module and it’s submodules.
__init__(event, fn, name, event_freq=1)[source]

Initialize the CounterCallback.

Parameters:
  • event (ashpy.events.Event) – event to count.
  • fn (Callable) – function to call every event_freq events.
  • event_freq (int) – event frequency.
  • name (str) – name of the Callback.
Raises:

ValueError – if event_freq is not valid.

Return type:

None

on_event(event, context)[source]

Count events and calls fn.

Parameters: