neon.callbacks.callbacks.DeconvCallback

class neon.callbacks.callbacks.DeconvCallback(train_set, valid_set, max_fm=16, dataset_pct=25)[source]

Bases: neon.callbacks.callbacks.Callback

Callback to store data after projecting activations back to pixel space using guided backpropagation. See [Springenberg2014] for details. Meant to be used for visualization purposes via nvis.

Parameters:
  • train_set (NervanaDataIterator) – the training dataset
  • max_fm (int, optional) – Maximum number of feature maps to visualize per layer. Defaults to 16.
  • dataset_pct (float, optional) – Initial portion of validation dataset to use in finding maximum activations. Defaults to 25.0 (25%).

Notes:

[Springenberg2014]http://arxiv.org/abs/1412.6806
__init__(train_set, valid_set, max_fm=16, dataset_pct=25)[source]

Methods

__init__(train_set, valid_set[, max_fm, ...])
gen_class(pdict)
get_description() Serialize callback configuration.
get_layer_acts(callback_data, model, x, ...) Get layer activations
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
scale_to_rgb(img) Convert float data to valid RGB values in the range [0, 255]
should_fire(callback_data, model, time, freq) Helper function for determining if a callback should do work at a given interval.
store_images(callback_data, batch_ind, ...) Store images
visualize_layer(callback_data, model, ...) Visualize layer

Attributes

be
classnm Returns the class name.
modulenm Returns the full module path.
be = None
classnm

Returns the class name.

gen_class(pdict)
get_description()

Serialize callback configuration.

get_layer_acts(callback_data, model, x, batch_ind)[source]

Get layer activations

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)

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)[source]

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

scale_to_rgb(img)[source]

Convert float data to valid RGB values in the range [0, 255]

Parameters:img (ndarray) – the image data
Returns:img – image array with valid RGB values
Return type:ndarray
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)
store_images(callback_data, batch_ind, imgs_to_store, img_batch_data, C, H, W)[source]

Store images

visualize_layer(callback_data, model, num_fm, act_size, layer_ind)[source]

Visualize layer