<s> from pylearn2 . utils import serial <EOL> import sys <EOL> _ , model_path = sys . argv <EOL> model = serial . load ( model_path ) <EOL> from pylearn2 . gui . patch_viewer import make_viewer <EOL> space = model . generator . get_output_space ( ) <EOL> from pylearn2 . config import yaml_parse <EOL> from pylearn2 . gui . patch_viewer import PatchViewer <EOL> import numpy as np <EOL> dataset = yaml_parse . load ( model . dataset_yaml_src ) <EOL> grid_shape = None <EOL> rows = <NUM_LIT:4> <EOL> sample_cols = <NUM_LIT:5> <EOL> samples = model . generator . sample ( rows * sample_cols ) . eval ( ) <EOL> topo_samples = dataset . get_topological_view ( samples ) <EOL> pv = PatchViewer ( grid_shape = ( rows , sample_cols + <NUM_LIT:1> ) , patch_shape = ( <NUM_LIT> , <NUM_LIT> ) , <EOL> is_color = False ) <EOL> X = dataset . X <EOL> topo = dataset . get_topological_view ( ) <EOL> index = <NUM_LIT:0> <EOL> for i in xrange ( samples . shape [ <NUM_LIT:0> ] ) : <EOL> topo_sample = topo_samples [ i , : , : , : ] <EOL> pv . add_patch ( topo_sample * <NUM_LIT> - <NUM_LIT:1.> , rescale = False ) <EOL> if ( i + <NUM_LIT:1> ) % sample_cols == <NUM_LIT:0> : <EOL> sample = samples [ i , : ] <EOL> dists = np . square ( X - sample ) . sum ( axis = <NUM_LIT:1> ) <EOL> j = np . argmin ( dists ) <EOL> match = topo [ j , : ] <EOL> pv . add_patch ( match * <NUM_LIT:2> - <NUM_LIT:1> , rescale = False , activation = <NUM_LIT:1> ) <EOL> pv . show ( ) </s>
