mila-iqia / blocks

A Theano framework for building and training neural networks
Other
1.16k stars 351 forks source link

I want to know how the file named 'main_loop.tar"came about #1203

Open DL15879104631 opened 4 years ago

DL15879104631 commented 4 years ago

from theano import tensor

from blocks.main_loop import MainLoop from blocks.bricks import MLP, Tanh, Softmax from blocks.model import Model mlp = MLP([Tanh(), None], [784, 10, 10]) x = tensor.matrix('features') y = tensor.lmatrix('targets') cost = Softmax().categorical_cross_entropy( ... y.flatten(), mlp.apply(tensor.flatten(x, outdim=2))) main_loop = MainLoop(None, None, model=Model(cost)) Let's see how the main loop is dumped by :func:dump from blocks.serialization import dump, load import tarfile with open(' main_loop.tar', 'wb') as dst: ... dump(main_loop, dst) tarball = tarfile.open('main_loop.tar', 'r') tarball # doctest: +ELLIPSIS <tarfile.TarFile object at ...> tarball.getnames() ['_pkl'] tarball.close()