visualizer - visualizer class

The file yann.modules.visualizer.py contains the definition for the visualizer:

yann.modules.visualizer.save_images(imgs, prefix, is_color, verbose=2)[source]

This functions produces a visualiation of the filters.

Parameters:
  • imgs – images of shape .. [num_imgs, height, width, channels] Note the change in order. it can also be in lots of other shapes and they will be reshaped and saved as images.
  • prefix – address to save the image to
  • is_color – If the image is color or not. True only if image shape is of color images.
  • verbose – As Always
class yann.modules.visualizer.visualizer(visualizer_init_args, verbose=2)[source]

Visualizer saves down images to visualize. The initilizer only initializes the directories for storing visuals. Three types of visualizations are saved down:

  • filters of each layer
  • activations of each layer
  • raw images to check the activations against
Parameters:
  • verbose – Similar to any 3-level verbose in the toolbox.
  • visualizer_init_args

    visualer_params is a dictionary of the form:

    visualizer_init_args = {
        "root"       : <location to save the visualizations at>,
        "frequency"  : <integer>, after how many epochs do you need to
                        visualize. Default value is 1
        "sample_size": <integer, prefer squares>, simply save down random
                        images from the datasets saves down activations for the
                        same images also. Default value is 16
        "rgb_filters": <bool> flag. if True a 3D-RGB rendition of the CNN
                        filters is rendered. Default value is False.
        "debug_functions" : <bool> visualize train and test and other theano functions.
                            default is False. Needs pydot and dv2viz to be installed.
        "debug_layers" : <bool> Will print layer activities from input to that layer
                         output. ( this is almost always useless because test debug
                         function will combine all these layers and print directly.)
        "id"         : id of the visualizer
                    }
    
Returns:

A visualizer object.

Return type:

yann.modules.visualizer

initialize(batch_size, verbose=2)[source]

Function that cooks the visualizer for some dataset.

Parameters:
  • batch_size – form dataset
  • verbose – as always
theano_function_visualizer(function, short_variable_names=False, format='pdf', verbose=2)[source]

This basically prints a visualization of any theano function using the in-built theano visualizer. It will save both a interactive html file and a plain old png file. This is just a wrapper to theano’s visualization tools.

Parameters:
  • function – theano function to print
  • short_variable_names – If True will print variables in short.
  • format – Any pydot supported format. Default is ‘pdf’
  • verbose – As usual.
visualize_activities(layer_activities, epoch, index=0, verbose=2)[source]

This method saves down all activities.

Parameters:
  • layer_activities – network’s layer_activities as created
  • epoch – what epoch are we running currently.
  • verbose – as always
visualize_filters(layers, epoch, index=0, verbose=2)[source]

This method saves down all activities.

Parameters:
  • layers – network’s layer dictionary
  • epoch – what epoch are we running currently.
  • verbose – as always
visualize_images(imgs, loc=None, verbose=2)[source]

Visualize the images in the dataset. Assumes that the data in the tensor variable imgs is in shape (batch_size, height, width, channels). Assumes that batchsize does not change.

Parameters:
  • imgs – tensor of data
  • verbose – as usual.