Module Expr Str Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias alias alias alias alias alias ImportFrom alias alias alias alias ImportFrom alias alias ImportFrom alias alias alias alias ImportFrom alias alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ClassDef bases NameLoad NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad Str kwarg body If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr TupleLoad Num Num orelse Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad Call NameLoad ListLoad GeneratorExp Call NameLoad keyword NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword Call AttributeLoad Str attr NameLoad comprehension TupleStore NameStore TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad GeneratorExp Call NameLoad NameLoad keyword Call AttributeLoad Str attr NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad AttributeLoad NameLoad attr NameLoad keyword NameLoad Assign AttributeStore NameLoad attr Call NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad Assign NameStore ListLoad AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return SubscriptLoad AttributeLoad NameLoad attr Index Num decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Assign SubscriptStore AttributeLoad NameLoad attr Index Num NameLoad decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Assign AttributeStore AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Assign AttributeStore AttributeLoad NameLoad attr attr BinOpAdd ListLoad Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr decorator_list decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad Num NameLoad body If CompareIs NameLoad NameLoad body Assign NameStore ListLoad Num Num If CompareIs NameLoad NameLoad body Assign NameStore ListLoad Num If CompareIs NameLoad NameLoad body Assign NameStore ListLoad Num Num If CompareIs NameLoad NameLoad body Assign NameStore ListLoad Num Num Assign NameStore TupleLoad Num Num Assign NameStore Num Assign NameStore ListComp Call NameLoad comprehension NameStore NameLoad Assign NameStore BinOpAdd ListComp Call NameLoad comprehension NameStore NameLoad ListLoad Call NameLoad Assign NameStore Call NameLoad NameLoad Num NameLoad keyword Call NameLoad NameLoad NameLoad keyword NameLoad keyword Call NameLoad NameLoad NameLoad keyword NameLoad keyword BinOpAdd NameLoad ListLoad NameLoad keyword Str keyword Call NameLoad keyword Num keyword Call NameLoad Num Expr Call AttributeLoad NameLoad attr Assign AttributeStore SubscriptLoad AttributeLoad NameLoad attr Index Num attr Call NameLoad keyword Num Assign AttributeStore SubscriptLoad AttributeLoad NameLoad attr Index Num attr Call NameLoad keyword Num Assign AttributeStore SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num attr Call NameLoad keyword Num Assign AttributeStore SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num attr Call NameLoad keyword Num Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr Str For TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad AttributeLoad AttributeLoad NameLoad attr attr orelse Expr Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad Call NameLoad attr Call AttributeLoad NameLoad attr NameLoad attr keyword Str Assign NameStore Call AttributeLoad Call AttributeLoad Call NameLoad attr Call AttributeLoad NameLoad attr NameLoad attr keyword Str Assign NameStore Call NameLoad ListLoad NameLoad NameLoad Assign NameStore Call NameLoad TupleLoad Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Call NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad TupleLoad Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Call NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr keyword Call NameLoad keyword Num Assign NameStore ListLoad Call NameLoad Call NameLoad keyword NameLoad keyword NameLoad Call NameLoad ListLoad NameLoad NameLoad NameLoad keyword Str Call NameLoad ListLoad NameLoad NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword Str keyword NameLoad Call NameLoad NameLoad Call NameLoad Call NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr decorator_list If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr Assign NameStore Call NameLoad Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Num keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str keyword ListLoad Num Num keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str keyword ListLoad Num keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str keyword ListLoad Num Num keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str keyword ListLoad Num Num keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Num keyword Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call NameLoad Call NameLoad NameLoad
N/A N/A Convolutional network example.

Run the training for 50 epochs with
```
python __init__.py --num-epochs 50
```
It is going to reach around 0.8% error rate on the test set.

 N/A logging N/A numpy argparse ArgumentParser theano tensor blocks.algorithms GradientDescent Scale blocks.bricks MLP Rectifier Initializable FeedforwardSequence Softmax Activation blocks.bricks.conv Convolutional ConvolutionalSequence Flattener MaxPooling blocks.bricks.cost CategoricalCrossEntropy MisclassificationRate blocks.extensions FinishAfter Timing Printing ProgressBar blocks.extensions.monitoring DataStreamMonitoring TrainingDataMonitoring blocks.extensions.saveload Checkpoint blocks.graph ComputationGraph blocks.initialization Constant Uniform blocks.main_loop MainLoop blocks.model Model blocks.monitoring aggregation fuel.datasets MNIST fuel.schemes ShuffledScheme fuel.streams DataStream toolz.itertoolz interleave LeNet N/A FeedforwardSequence Initializable N/A N/A LeNet-like convolutional network.

    The class implements LeNet, which is a convolutional sequence with
    an MLP on top (several fully-connected layers). For details see
    [LeCun95]_.

    .. [LeCun95] LeCun, Yann, et al.
       *Comparison of learning algorithms for handwritten digit
       recognition.*,
       International conference on artificial neural networks. Vol. 60.

    Parameters
    ----------
    conv_activations : list of :class:`.Brick`
        Activations for convolutional network.
    num_channels : int
        Number of channels in the input image.
    image_shape : tuple
        Input image shape.
    filter_sizes : list of tuples
        Filter sizes of :class:`.blocks.conv.ConvolutionalLayer`.
    feature_maps : list
        Number of filters for each of convolutions.
    pooling_sizes : list of tuples
        Sizes of max pooling for each convolutional layer.
    top_mlp_activations : list of :class:`.blocks.bricks.Activation`
        List of activations for the top MLP.
    top_mlp_dims : list
        Numbers of hidden units and the output dimension of the top MLP.
    conv_step : tuples
        Step of convolution (similar for all layers).
    border_mode : str
        Border mode of convolution (similar for all layers).

     __init__ N/A N/A self conv_activations num_channels image_shape filter_sizes feature_maps pooling_sizes top_mlp_activations top_mlp_dims conv_step border_mode N/A None valid kwargs N/A N/A N/A conv_step None N/A N/A N/A self conv_step N/A 1 1 N/A N/A N/A self conv_step conv_step N/A N/A self num_channels num_channels N/A N/A self image_shape image_shape N/A N/A self top_mlp_activations top_mlp_activations N/A N/A self top_mlp_dims top_mlp_dims N/A N/A self border_mode border_mode N/A conv_parameters N/A zip filter_sizes feature_maps N/A N/A self layers N/A list N/A interleave N/A N/A N/A Convolutional filter_size filter_size num_filters num_filter step N/A self conv_step border_mode N/A self border_mode name N/A N/A conv_{} format i N/A N/A i N/A filter_size num_filter N/A enumerate conv_parameters conv_activations N/A N/A MaxPooling size name N/A N/A pool_{} format i N/A N/A i size N/A enumerate pooling_sizes N/A N/A self conv_sequence N/A ConvolutionalSequence N/A self layers num_channels image_size image_shape N/A N/A self top_mlp N/A MLP top_mlp_activations top_mlp_dims N/A N/A self flattener N/A Flattener N/A application_methods N/A N/A N/A self conv_sequence apply N/A N/A self flattener apply N/A N/A self top_mlp apply N/A N/A N/A N/A super LeNet self __init__ application_methods kwargs N/A output_dim N/A N/A self N/A N/A N/A N/A N/A self top_mlp_dims N/A -1 N/A property output_dim N/A N/A self value N/A N/A N/A N/A N/A self top_mlp_dims N/A -1 value N/A N/A output_dim setter _push_allocation_config N/A N/A self N/A N/A N/A N/A N/A N/A self conv_sequence _push_allocation_config N/A conv_out_dim N/A N/A N/A self conv_sequence get_dim output N/A N/A N/A self top_mlp activations N/A self top_mlp_activations N/A N/A N/A self top_mlp dims N/A N/A N/A N/A numpy prod conv_out_dim N/A self top_mlp_dims N/A N/A main N/A N/A save_to num_epochs feature_maps mlp_hiddens conv_sizes pool_sizes batch_size num_batches N/A None None None None 500 None N/A N/A N/A feature_maps None N/A N/A feature_maps N/A 20 50 N/A N/A mlp_hiddens None N/A N/A mlp_hiddens N/A 500 N/A N/A conv_sizes None N/A N/A conv_sizes N/A 5 5 N/A N/A pool_sizes None N/A N/A pool_sizes N/A 2 2 N/A image_size N/A 28 28 N/A output_size 10 N/A conv_activations N/A N/A Rectifier N/A _ feature_maps N/A mlp_activations N/A N/A N/A Rectifier N/A _ mlp_hiddens N/A N/A Softmax N/A convnet N/A LeNet conv_activations 1 image_size filter_sizes N/A zip conv_sizes conv_sizes feature_maps feature_maps pooling_sizes N/A zip pool_sizes pool_sizes top_mlp_activations mlp_activations top_mlp_dims N/A mlp_hiddens N/A output_size border_mode full weights_init N/A Uniform width 0.2 biases_init N/A Constant 0 N/A N/A N/A convnet push_initialization_config N/A N/A N/A N/A convnet layers N/A 0 weights_init N/A Uniform width 0.2 N/A N/A N/A N/A convnet layers N/A 1 weights_init N/A Uniform width 0.09 N/A N/A N/A N/A N/A convnet top_mlp linear_transformations N/A 0 weights_init N/A Uniform width 0.08 N/A N/A N/A N/A N/A convnet top_mlp linear_transformations N/A 1 weights_init N/A Uniform width 0.11 N/A N/A N/A convnet initialize N/A N/A N/A logging info N/A N/A Input dim: {} {} {} format N/A N/A N/A N/A convnet children N/A 0 get_dim input_ N/A N/A i layer N/A enumerate N/A convnet layers N/A N/A N/A isinstance layer Activation N/A N/A N/A N/A logging info N/A N/A Layer {} ({}) format i N/A N/A layer __class__ __name__ N/A N/A N/A N/A logging info N/A N/A Layer {} ({}) dim: {} {} {} format i N/A N/A layer __class__ __name__ N/A N/A layer get_dim output N/A x N/A N/A tensor tensor4 features N/A y N/A N/A tensor lmatrix targets N/A probs N/A N/A convnet apply x N/A cost N/A N/A N/A N/A N/A CategoricalCrossEntropy apply N/A N/A y flatten probs copy name cost N/A error_rate N/A N/A N/A N/A N/A MisclassificationRate apply N/A N/A y flatten probs copy name error_rate N/A cg N/A ComputationGraph N/A cost error_rate N/A mnist_train N/A MNIST N/A train N/A mnist_train_stream N/A N/A DataStream default_stream mnist_train iteration_scheme N/A ShuffledScheme N/A mnist_train num_examples batch_size N/A mnist_test N/A MNIST N/A test N/A mnist_test_stream N/A N/A DataStream default_stream mnist_test iteration_scheme N/A ShuffledScheme N/A mnist_test num_examples batch_size N/A algorithm N/A GradientDescent cost cost parameters N/A cg parameters step_rule N/A Scale learning_rate 0.1 N/A extensions N/A N/A Timing N/A FinishAfter after_n_epochs num_epochs after_n_batches num_batches N/A DataStreamMonitoring N/A cost error_rate mnist_test_stream prefix test N/A TrainingDataMonitoring N/A cost error_rate N/A N/A aggregation mean N/A algorithm total_gradient_norm prefix train after_epoch True N/A Checkpoint save_to N/A ProgressBar N/A Printing N/A model N/A Model cost N/A main_loop N/A MainLoop algorithm mnist_train_stream model model extensions extensions N/A N/A N/A main_loop run N/A N/A N/A __name__ __main__ N/A N/A N/A N/A logging basicConfig level N/A logging INFO N/A parser N/A ArgumentParser An example of training a convolutional network on the MNIST dataset. N/A N/A N/A parser add_argument --num-epochs type int default 2 help Number of training epochs to do. N/A N/A N/A parser add_argument save_to default mnist.pkl nargs ? help Destination to save the state of the training process. N/A N/A N/A parser add_argument --feature-maps type int nargs + default N/A 20 50 help List of feature maps numbers. N/A N/A N/A parser add_argument --mlp-hiddens type int nargs + default N/A 500 help List of numbers of hidden units for the MLP. N/A N/A N/A parser add_argument --conv-sizes type int nargs + default N/A 5 5 help Convolutional kernels sizes. The kernels are always square. N/A N/A N/A parser add_argument --pool-sizes type int nargs + default N/A 2 2 help Pooling sizes. The pooling windows are always square. Should be the same length as --conv-sizes. N/A N/A N/A parser add_argument --batch-size type int default 500 help Batch size. N/A args N/A N/A parser parse_args N/A N/A main N/A vars args