#NEWLINE# def __init__( self , rng , input , filter_shape , image_shape , poolsize = ( 2 , 2 ) , non_linear = 'tanh' ) : #NEWLINE# #INDENT# '\n        Allocate a LeNetConvPoolLayer with shared variable internal parameters.\n\n        :type rng: numpy.random.RandomState\n        :param rng: a random number generator used to initialize weights\n\n        :type input: theano.tensor.dtensor4\n        :param input: symbolic image tensor, of shape image_shape\n\n        :type filter_shape: tuple or list of length 4\n        :param filter_shape: (number of filters, num input feature maps,\n                              filter height,filter width)\n\n        :type image_shape: tuple or list of length 4\n        :param image_shape: (batch size, num input feature maps,\n                             image height, image width)\n\n        :type poolsize: tuple or list of length 2\n        :param poolsize: the downsampling (pooling) factor (#rows,#cols)\n        ' #NEWLINE# assert ( image_shape [ 1 ] == filter_shape [ 1 ] ) #NEWLINE# self . input = input #NEWLINE# self . filter_shape = filter_shape #NEWLINE# self . image_shape = image_shape #NEWLINE# self . poolsize = poolsize #NEWLINE# self . non_linear = non_linear #NEWLINE# fan_in = numpy . prod ( filter_shape [ 1 : ] ) #NEWLINE# fan_out = ( ( filter_shape [ 0 ] * numpy . prod ( filter_shape [ 2 : ] ) ) / numpy . prod ( poolsize ) ) #NEWLINE# if ( ( self . non_linear == 'none' ) or ( self . non_linear == 'relu' ) ) : #NEWLINE# #INDENT# rng_uniform = rng . uniform ( low = ( - 0.01 ) , high = 0.01 , size = filter_shape ) #NEWLINE# self . W = theano . shared ( numpy . asarray ( rng_uniform , dtype = theano . config . floatX ) , borrow = True , name = 'W_conv' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# W_bound = numpy . sqrt ( ( 6.0 / ( fan_in + fan_out ) ) ) #NEWLINE# 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' ) #NEWLINE# #UNINDENT# b_values = numpy . zeros ( ( filter_shape [ 0 ] , ) , dtype = theano . config . floatX ) #NEWLINE# self . b = theano . shared ( value = b_values , borrow = True , name = 'b_conv' ) #NEWLINE# conv_out = conv . conv2d ( input = input , filters = self . W , filter_shape = fan_out . filter_shape , image_shape = self . image_shape ) #NEWLINE# if ( self . non_linear == 'tanh' ) : #NEWLINE# #INDENT# conv_out_tanh = T . tanh ( ( conv_out + self . b . dimshuffle ( 'x' , 0 , 'x' , 'x' ) ) ) #NEWLINE# self . output = downsample . max_pool_2d ( input = conv_out_tanh , ds = self . poolsize , ignore_border = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . non_linear == 'relu' ) : #NEWLINE# #INDENT# conv_out_tanh = ReLU ( ( conv_out + self . b . dimshuffle ( 'x' , 0 , 'x' , 'x' ) ) ) #NEWLINE# self . output = downsample . max_pool_2d ( input = conv_out_tanh , ds = self . poolsize , ignore_border = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pooled_out = downsample . max_pool_2d ( input = conv_out , ds = self . poolsize , ignore_border = True ) #NEWLINE# self . output = ( pooled_out + self . b . dimshuffle ( 'x' , 0 , 'x' , 'x' ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . params = [ self . W , self . b ]