def test_summarize_model(): """ Asks the summarize_model.py script to inspect a pickled model and check that it completes succesfully """ skip_if_no_matplotlib() with open('model.pkl', 'wb') as f: cPickle.dump(MLP(layers=[Linear(dim=5, layer_name='h0', irange=0.1)], nvis=10), f, protocol=cPickle.HIGHEST_PROTOCOL) summarize('model.pkl') os.remove('model.pkl')
def test_show_examples(): """ Create a YAML file of the MNIST dataset and show examples """ skip_if_no_matplotlib() skip_if_no_data() with open('temp.yaml', 'w') as f: f.write(""" !obj:pylearn2.datasets.mnist.MNIST { which_set: 'train' } """) show_examples('temp.yaml', 28, 28, out='garbage.png') os.remove('temp.yaml')
def test_show_weights(): """ Create a pickled model and show the 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 = """ !obj:pylearn2.datasets.mnist.MNIST { which_set: 'train' } """ 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')