code: def build_custom_mlp(
      input_var=None,
      depth=2,
      width=800,
      drop_input=0.2,
      drop_hidden=0.5,
  ):
      # By default, this creates the same network as `build_mlp`, but it can be
      # customized with respect to the number and size of hidden layers. This
      # mostly showcases how creating a network in Python code can be a lot more
      # flexible than a configuration file. Note that to make the code easier,
      # all the layers are just called `network` -- there is no need to give them
      # different names if all we return is the last one we created anyway; we
      # just used different names above for clarity.
  
      # Input layer and dropout (with shortcut `dropout` for `DropoutLayer`):
      network = lasagne.layers.InputLayer(
          shape=(None, 1, 28, 28), input_var=input_var
      )
      if drop_input:
          network = lasagne.layers.dropout(network, p=drop_input)
      # Hidden layers and dropout:
      nonlin = lasagne.nonlinearities.rectify
      for _ in range(depth):
          network = lasagne.layers.DenseLayer(
              network, width, nonlinearity=nonlin
          )
          if drop_hidden:
              network = lasagne.layers.dropout(network, p=drop_hidden)
      # Output layer:
      softmax = lasagne.nonlinearities.softmax
      network = lasagne.layers.DenseLayer(
          network, 10, nonlinearity=softmax
      )
      return network
  
file_path: Lasagne/examples/mnist.py
imports: from __future__ import print_function
  import sys
  import os
  import time
  import numpy
  import theano
  import theano.tensor
  import lasagne
label_desc: Use image node_id 3 for calling a global function with example usage: build_custom_mlp(input_var, depth, width, drop_input, drop_hidden) and returns: network