MNIST CNN model with Lasagne
The Lasagne library has packaged layers and tools to handle neural nets easily. Let's first install the latest version of Lasagne:
pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip
Let us reprogram the MNIST model from Chapter 2, Classifying Handwritten Digits with a Feedforward Network with Lasagne:
def model(l_input, input_dim=28, num_units=256, num_classes=10, p=.5): network = lasagne.layers.Conv2DLayer( l_input, num_filters=32, filter_size=(5, 5), nonlinearity=lasagne.nonlinearities.rectify, W=lasagne.init.GlorotUniform()) network = lasagne.layers.MaxPool2DLayer(network, pool_size=(2, 2)) network = lasagne.layers.Conv2DLayer( network, num_filters=32, filter_size=(5, 5), nonlinearity=lasagne.nonlinearities.rectify) network = lasagne.layers.MaxPool2DLayer(network, pool_size=(2, 2)) if num_units > 0: network = lasagne.layers.DenseLayer( ...