'Allocate a LeNetConvPoolLayer with shared variable internal parameters.
:type rng: numpy.random.RandomState
:param rng: a random number generator used to initialize weights
:type input: theano.tensor.dtensor4
:param input: symbolic image tensor, of shape image_shape
:type filter_shape: tuple or list of length 4
:param filter_shape: (number of filters, num input feature maps,
filter height,filter width)
:type image_shape: tuple or list of length 4
:param image_shape: (batch size, num input feature maps,
image height, image width)
:type poolsize: tuple or list of length 2
:param poolsize: the downsampling (pooling) factor (#rows,#cols)'

def __init__(self, rng, input, filter_shape, image_shape, poolsize=(2, 2), non_linear='tanh'):

    assert (image_shape[1] == filter_shape[1])
    self.input = input
    self.filter_shape = filter_shape
    self.image_shape = image_shape
    self.poolsize = poolsize
    self.non_linear = non_linear
    fan_in = numpy.prod(filter_shape[1:])
    fan_out = ((filter_shape[0] * numpy.prod(filter_shape[2:])) / numpy.prod(poolsize))
    if ((self.non_linear == 'none') or (self.non_linear == 'relu')):
        self.W = theano.shared(numpy.asarray(rng.uniform(low=(-0.01), high=0.01, size=filter_shape), dtype=theano.config.floatX), borrow=True, name='W_conv')
    else:
        W_bound = numpy.sqrt((6.0 / (fan_in + fan_out)))
        self.W = theano.shared(numpy.asarray(rng.uniform(low=(- W_bound), high=W_bound, size=filter_shape), dtype=theano.config.floatX), borrow=True, name='W_conv')
    b_values = numpy.zeros((filter_shape[0],), dtype=theano.config.floatX)
    self.b = theano.shared(value=b_values, borrow=True, name='b_conv')
    conv_out = conv.conv2d(input=input, filters=self.W, filter_shape=self.filter_shape, image_shape=self.image_shape)
    if (self.non_linear == 'tanh'):
        conv_out_tanh = T.tanh((conv_out + self.b.dimshuffle('x', 0, 'x', 'x')))
        self.output = downsample.max_pool_2d(input=conv_out_tanh, ds=self.poolsize, ignore_border=True)
    elif (self.non_linear == 'relu'):
        conv_out_tanh = ReLU((conv_out + self.b.dimshuffle('x', 0, 'x', 'x')))
        self.output = downsample.max_pool_2d(input=conv_out_tanh, ds=self.poolsize, ignore_border=True)
    else:
        pooled_out = downsample.max_pool_2d(input=conv_out, ds=self.poolsize, ignore_border=True)
        self.output = (pooled_out + self.b.dimshuffle('x', 0, 'x', 'x'))
    self.params = [self.W, self.b]
