#NEWLINE# @ wraps ( Layer . fprop ) #NEWLINE# def fprop( self , state_below , return_all = False ) : #NEWLINE# #INDENT# if isinstance ( state_below , tuple ) : #NEWLINE# #INDENT# ( state_below , mask ) = state_below #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mask = None #NEWLINE# #UNINDENT# z0 = tensor . alloc ( np . cast [ config . floatX ] ( 0 ) , state_below . shape [ 1 ] , self . dim ) #NEWLINE# z0 = tensor . unbroadcast ( z0 , 0 ) #NEWLINE# if ( self . dim == 1 ) : #NEWLINE# #INDENT# z0 = tensor . unbroadcast ( z0 , 1 ) #NEWLINE# #UNINDENT# ( W , U , b ) = self . _params #NEWLINE# if self . weight_noise : #NEWLINE# #INDENT# W = self . add_noise ( W ) #NEWLINE# U = self . add_noise ( U ) #NEWLINE# #UNINDENT# state_below = ( tensor . dot ( state_below , W ) + b ) #NEWLINE# if ( mask is not None ) : #NEWLINE# #INDENT# ( z , updates ) = scan ( fn = self . fprop_step_mask , sequences = [ state_below , mask ] , outputs_info = [ z0 ] , non_sequences = [ U ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( z , updates ) = scan ( fn = self . fprop_step , sequences = [ state_below ] , outputs_info = [ z0 ] , non_sequences = [ U ] ) #NEWLINE# #UNINDENT# self . _scan_updates . update ( updates ) #NEWLINE# if return_all : #NEWLINE# #INDENT# return z #NEWLINE# #UNINDENT# if ( self . indices is not None ) : #NEWLINE# #INDENT# if ( len ( self . indices ) > 1 ) : #NEWLINE# #INDENT# return [ z [ i , : , : self . dim ] for i in self . indices ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return z [ self . indices [ 0 ] , : , : self . dim ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( mask is not None ) : #NEWLINE# #INDENT# return ( z [ : , : , : self . dim ] , mask ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return z [ : , : , : self . dim ]