Package dimer :: Package nnet :: Module utils
[hide private]
[frames] | no frames]

Module utils

source code

This file contains different utility functions that are not connected in anyway to the networks presented in the tutorials, but rather help in processing the outputs into a more understandable way.

For example ``tile_raster_images`` helps in generating a easy to grasp image from a set of samples or weights.

Functions [hide private]
 
scale_to_unit_interval(ndar, eps=1e-08)
Scales all values in the ndarray ndar to be between 0 and 1
source code
 
tile_raster_images(X, img_shape, tile_shape, tile_spacing=(0, 0), scale_rows_to_unit_interval=True, output_pixel_vals=True)
Transform an array with one flattened image per row, into an array in which images are reshaped and layed out like tiles on a floor.
source code
 
cnn_filters2raster_image(X) source code
Variables [hide private]
  __package__ = 'dimer.nnet'
Function Details [hide private]

tile_raster_images(X, img_shape, tile_shape, tile_spacing=(0, 0), scale_rows_to_unit_interval=True, output_pixel_vals=True)

source code 

Transform an array with one flattened image per row, into an array in which images are reshaped and layed out like tiles on a floor.

This function is useful for visualizing datasets whose rows are images, and also columns of matrices for transforming those rows (such as the first layer of a neural net).

:type X: a 2-D ndarray or a tuple of 4 channels, elements of which can be 2-D ndarrays or None; :param X: a 2-D array in which every row is a flattened image.

:type img_shape: tuple; (height, width) :param img_shape: the original shape of each image

:type tile_shape: tuple; (rows, cols) :param tile_shape: the number of images to tile (rows, cols)

:param output_pixel_vals: if output should be pixel values (i.e. int8 values) or floats

:param scale_rows_to_unit_interval: if the values need to be scaled before being plotted to [0,1] or not

:returns: array suitable for viewing as an image. (See:`PIL.Image.fromarray`.) :rtype: a 2-d array with same dtype as X.