def test_show_weights():
 skip_if_no_matplotlib()
 with open('model.pkl', 'wb') as f:
  model = MLP(layers=[Linear(dim=1, layer_name='h0', irange=0.1)], nvis=784)
  model.dataset_yaml_src = "\n!obj:pylearn2.datasets.mnist.MNIST {\n        which_set: 'train'\n}\n"
  cPickle.dump(model, f, protocol=cPickle.HIGHEST_PROTOCOL)
 show_weights('model.pkl', rescale='individual', border=True, out='garbage.png')
 os.remove('model.pkl')
 os.remove('garbage.png')

def test_show_weights ( ) : skip_if_no_matplotlib ( ) with open ( 'model.pkl' , 'wb' ) as f : model = MLP ( layers = [ Linear ( dim = 1 , layer_name = 'h0' , irange = 0.1 ) ] , nvis = 784 ) model . dataset_yaml_src = "\n!obj:pylearn2.datasets.mnist.MNIST {\n        which_set: 'train'\n}\n" cPickle . dump ( model , f , protocol = cPickle . HIGHEST_PROTOCOL ) show_weights ( 'model.pkl' , rescale = 'individual' , border = True , out = 'garbage.png' ) os . remove ( 'model.pkl' ) os . remove ( 'garbage.png' )
create a pickled model and show the weights .