This is a python script for t-SNE visualization of multiple images in a square grid.
Dependencies:
Basic usage:
python tsne_grid.py --dir ./examples/inputs/ --size 4
--dir
: Path to directory containing image collection.--size
: Number of small images in a row/column in output image.
--res
: Width/height if small images (in pixels). Default is 224.--name
: Output filename. Default is tsne_grid.jpg--path
: Output image path. Default is current directory.--per
: Perplexity for t-SNE algorithm. Default is 50.--iter
: Number of iterations for t-SNE algorithm. Default is 5000.
VGG16 (without fc layers on top) is used to generate high dimensional feature representations of images. 2D representaions of these features are formed using scikit-learn's t-SNE implementation. These 2D representations are converted into a square grid using Jonker-Volgenant algorithm.
The script was tested with tensorflow (1.4.0) and keras (2.1.1) on Nvidia GeForce GT 740M
- L.J.P. van der Maaten and G.E. Hinton. Visualizing High-Dimensional Data Using t-SNE. Journal of Machine Learning Research 9(Nov):2579-2605, 2008. PDF [Supplemental material] [Talk] [Code]