#NEWLINE# def _build_expression( self , input_tensor = None ) : #NEWLINE# #INDENT# if ( self . axis != 'channels' ) : #NEWLINE# #INDENT# raise NotImplementedError ( 'Only implemented for channels at this moment' ) #NEWLINE# #UNINDENT# if ( ( self . normalization_size % 2 ) == 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'Only accepting odd sized pooling regions in order to be able to identify a midpoint.' ) #NEWLINE# #UNINDENT# if ( input_tensor is None ) : #NEWLINE# #INDENT# self . input_ = self . input_type ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . input_ = input_tensor #NEWLINE# #UNINDENT# nsize = self . normalization_size #NEWLINE# fil = ( ( T . ones ( ( 1 , 1 , nsize , 1 ) , dtype = self . input_ . dtype ) / self . normalization_size ) * self . normalization_factor ) #NEWLINE# local_mean = T . nnet . conv2d ( ( self . input_ . reshape ( ( self . input_ . shape [ 0 ] , 1 , self . input_ . shape [ 1 ] , ( - 1 ) ) ) ** 2 ) , fil , border_mode = 'full' ) [ : , : , ( nsize // 2 ) : ( - ( nsize // 2 ) ) , : ] . reshape ( ( self . input_ . shape [ 0 ] , ( - 1 ) , self . input_ . shape [ 2 ] , self . input_ . shape [ 3 ] ) ) #NEWLINE# self . expression_ = ( self . input_ / ( ( 1 + local_mean ) ** self . normalization_exponent ) )