raster - provides a visualization for rasterizing images.

The file yann.utils.raster.py contains the definition for the rasters. This code is not mine and is lifted from theano utils. This code is used to remove the dependency on now out-dated pylearn2 library. Yann uses pylearn2’s make_viewer to create images that are raster. Migrating to this tile_raster_images from theano tutorials. Obliging License, credit and conditions for Theano Deep Learning Tutorials: This entire file was completely and directly reproduced from the theano deep learning tutorials.

Copyright (c) 2010–2015, Deep Learning Tutorials Development Team All rights reserved.

This code is used to remove the dependency on now out-dated pylearn2 library. Yann uses pylearn2’s make_viewer to create images that are raster. Migrating to this tile_raster_images from theano tutorials.

Obliging License, credit and conditions for Theano Deep Learning Tutorials: This entire file was completely and directly reproduced from the theano deep learnign tutorials.

LICENSE

Copyright (c) 2010–2015, Deep Learning Tutorials Development Team All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Theano nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ‘’AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

yann.utils.raster.scale_to_unit_interval(ndar, eps=1e-08)[source]

Scales all values in the ndarray ndar to be between 0 and 1

yann.utils.raster.tile_raster_images(X, img_shape, tile_shape, tile_spacing=(0, 0), scale_rows_to_unit_interval=True, output_pixel_vals=True)[source]

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:Image.fromarray.) :rtype: a 2-d array with same dtype as X.