#NEWLINE# def init_params( self , shape ) : #NEWLINE# #INDENT# '\n        Initialize params including weights and biases.\n        The weight matrix and bias matrix are concatenated from the weights\n        for inputs and weights for recurrent inputs and bias.\n\n        Arguments:\n            shape (Tuple): contains number of outputs and number of inputs\n\n        ' #NEWLINE# ( nout , nin ) = shape #NEWLINE# g_nout = ( self . ngates * nout ) #NEWLINE# doFill = False #NEWLINE# if ( self . W is None ) : #NEWLINE# #INDENT# self . W = self . be . empty ( ( ( ( nout + nin ) + 1 ) , g_nout ) ) #NEWLINE# self . dW = self . be . zeros_like ( self . W ) #NEWLINE# doFill = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert ( self . W . shape == ( ( ( nout + nin ) + 1 ) , g_nout ) ) #NEWLINE# assert ( self . dW . shape == ( ( ( nout + nin ) + 1 ) , g_nout ) ) #NEWLINE# #UNINDENT# self . W_input = self . W [ : nin ] . reshape ( ( g_nout , nin ) ) #NEWLINE# self . W_recur = self . W [ nin : ( - 1 ) ] . reshape ( ( g_nout , nout ) ) #NEWLINE# self . b = self . W [ ( - 1 ) : ] . reshape ( ( g_nout , 1 ) ) #NEWLINE# if doFill : #NEWLINE# #INDENT# gatelist = [ ( g * nout ) for g in range ( 0 , ( self . ngates + 1 ) ) ] #NEWLINE# for wtnm in ( 'W_input' , 'W_recur' ) : #NEWLINE# #INDENT# wtmat = getattr ( self , wtnm ) #NEWLINE# if ( ( wtnm is 'W_recur' ) and ( self . init_inner is not None ) ) : #NEWLINE# #INDENT# initfunc = self . init_inner #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# initfunc = self . init #NEWLINE# #UNINDENT# for ( gb , ge ) in zip ( gatelist [ : ( - 1 ) ] , gatelist [ 1 : ] ) : #NEWLINE# #INDENT# initfunc . fill ( wtmat [ gb : ge ] ) #NEWLINE# #UNINDENT# #UNINDENT# self . b . fill ( 0.0 ) #NEWLINE# #UNINDENT# self . dW_input = self . dW [ : nin ] . reshape ( self . W_input . shape ) #NEWLINE# self . dW_recur = self . dW [ nin : ( - 1 ) ] . reshape ( self . W_recur . shape ) #NEWLINE# self . db = self . dW [ ( - 1 ) : ] . reshape ( self . b . shape )