Previous topic

IO

This Page

Visualize

Module misc.visualize includes useful functions for visualizing datasets or image filters.

This module contains the following functions:

  • tsne_2D: plots in 2D a set of points using t-SNE.
  • show_filters: plots the filters in a weight matrix.
  • show_binary_images: plots samples from a dataset of images with binary pixels.
  • show_color_filters: plots the color filters from a weight matrix.
  • show_color_images: plots samples from a dataset of images with color pixels.
misc.visualize.tsne_2D(inputs, colors=None, labels=None, initial_dims=50, perplexity=30.0)[source]

Plots in 2D a set of points (the rows of NumPy 2D array inputs), using t-SNE.

A color coding can be specified with option colors (e.g. [‘b’,’r’,’k’,’k’] would yield one blue, one red and two black points). String labels for each data point can also be provided. initial_dims and perplexity are hyper-parameters of t-SNE.

This function requires t-SNE python code prodived by Laurens van der Maaten (see README in mlpython/misc/third_party/tsne/).

misc.visualize.show_filters(weights, nweights, d1, d2, nrows, ncols, scale)[source]

Plots the rows of NumPy 2D array weights as d1 by d2 images.

The images are layed out in a nrows by ncols grid.

Option scale sets the maximum absolute value of elements in weights that will be plotted (larger values will be clamped to scale, with the right sign).

misc.visualize.show_binary_images(samples, nsamples, d1, d2, nrows, ncols)[source]

Plots samples in a NumPy 2D array samples as d1 by d2 images. (one sample per row of samples).

The samples are assumed to be images with binary pixels. The images are layed out in a nrows by ncols grid.

misc.visualize.show_color_filters(filters, nfilters, d1, d2, nrows, ncols)[source]

Plots filters in a NumPy 2D array filters as d1 by d2 images. (one sample per row of filters).

The filters are assumed to be color images. The first d1*d2 elements of each row are the R channel values of each pixel, then follows the G and B channels. The images are layed out in a nrows by ncols grid.

The main difference with show_color_images is that each filter’s intensity is normalized, individually.

misc.visualize.show_color_images(samples, nsamples, d1, d2, nrows, ncols)[source]

Plots samples in a NumPy 2D array samples as d1 by d2 images. (one sample per row of samples).

The samples are assumed to be color images. The first d1*d2 elements of each row are the R channel values of each pixel, then follows the G and B channels. The images are layed out in a nrows by ncols grid.

Thanks to Ilya Sutskever for sharing his code, from which this code is inspired.