neon.callbacks.callbacks.EarlyStopCallback

class neon.callbacks.callbacks.EarlyStopCallback(stop_func)[source]

Bases: neon.callbacks.callbacks.Callback

Callback for stopping training when a threshold has been triggered.

Parameters:stop_func (Function) – Takes a function that receives a tuple (State, Val[t]) of the current state and the validation error at this time and returns a tuple (State’, Bool) that returns the updated state and an indication of whether to stop training.
__init__(stop_func)[source]

Methods

__init__(stop_func)
gen_class(pdict)
get_description() Serialize callback configuration.
on_epoch_begin(callback_data, model, epoch) Called when an epoch is about to begin
on_epoch_end(callback_data, model, epoch) Called when an epoch is about to end
on_minibatch_begin(callback_data, model, …) Called when a minibatch is about to begin
on_minibatch_end(callback_data, model, …) Called when a minibatch is about to end
on_train_begin(callback_data, model, epochs) Called when training is about to begin
on_train_end(callback_data, model) Called when training is about to end
recursive_gen(pdict, key) helper method to check whether the definition
should_fire(callback_data, model, time, freq) Helper function for determining if a callback should do work at a given interval.
be = None
classnm

Returns the class name.

gen_class(pdict)
get_description()

Serialize callback configuration.

modulenm

Returns the full module path.

on_epoch_begin(callback_data, model, epoch)

Called when an epoch is about to begin

Parameters:
  • callback_data (HDF5 dataset) – shared data between callbacks
  • model (Model) – model object
  • epoch (int) – index of epoch that is beginning
on_epoch_end(callback_data, model, epoch)[source]

Called when an epoch is about to end

Parameters:
  • callback_data (HDF5 dataset) – shared data between callbacks
  • model (Model) – model object
  • epoch (int) – index of epoch that is ending
on_minibatch_begin(callback_data, model, epoch, minibatch)

Called when a minibatch is about to begin

Parameters:
  • callback_data (HDF5 dataset) – shared data between callbacks
  • model (Model) – model object
  • epoch (int) – index of current epoch
  • minibatch (int) – index of minibatch that is beginning
on_minibatch_end(callback_data, model, epoch, minibatch)

Called when a minibatch is about to end

Parameters:
  • callback_data (HDF5 dataset) – shared data between callbacks
  • model (Model) – model object
  • epoch (int) – index of current epoch
  • minibatch (int) – index of minibatch that is ending
on_train_begin(callback_data, model, epochs)

Called when training is about to begin

Parameters:
  • callback_data (HDF5 dataset) – shared data between callbacks
  • model (Model) – model object
on_train_end(callback_data, model)

Called when training is about to end

Parameters:
  • callback_data (HDF5 dataset) – shared data between callbacks
  • model (Model) – model object
recursive_gen(pdict, key)

helper method to check whether the definition dictionary is defining a NervanaObject child, if so it will instantiate that object and replace the dictionary element with an instance of that object

should_fire(callback_data, model, time, freq)

Helper function for determining if a callback should do work at a given interval.

Parameters:
  • callback_data (HDF5 dataset) – shared data between callbacks
  • model (Model) – model object
  • time (int) – current time, in an arbitrary unit
  • freq (int, list, None) – firing frequency, in multiples of the unit used for time, or a list of times, or None (never fire)