neon.callbacks.callbacks.SerializeModelCallback

class neon.callbacks.callbacks.SerializeModelCallback(save_path, epoch_freq=1, history=1)[source]

Bases: neon.callbacks.callbacks.Callback

Callback for serializing the state of the model.

Parameters:
  • save_path (str) – where to save the model dataset
  • epoch_freq (int, optional) – how often (in epochs) to serialize the model. If not specified, we default to running every epoch.
  • history (int, optional) – number of checkpoint files to retain, newest files up to this count are retained. filename for the check point files will be <save_path>_<epoch>.
__init__(save_path, epoch_freq=1, history=1)[source]

Methods

__init__(save_path[, epoch_freq, history])
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
save_history(epoch, model) Save history
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

save_history(epoch, model)[source]

Save history

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)