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()