(self, shape)
Initialize params including weights and biases.
        The weight matrix and bias matrix are concatenated from the weights
        for inputs and weights for recurrent inputs and bias.

        Arguments:
            shape (Tuple): contains number of outputs and number of inputs
Initialize params including weights and biases.
        The weight matrix and bias matrix are concatenated from the weights
        for inputs and weights for recurrent inputs and bias.
Initialize params including weights and biases . The weight matrix and bias matrix are concatenated from the weights for inputs and weights for recurrent inputs and bias .
def init_params(self, shape):
        """
        Initialize params including weights and biases.
        The weight matrix and bias matrix are concatenated from the weights
        for inputs and weights for recurrent inputs and bias.

        Arguments:
            shape (Tuple): contains number of outputs and number of inputs

        """
        (nout, nin) = shape
        g_nout = self.ngates * nout
        doFill = False
        weight_dim = (nout + nin + 1)

        if self.W is None:
            self.W = self.be.empty((weight_dim, g_nout))
            self.dW = self.be.zeros_like(self.W)
            doFill = True
        else:
            # Deserialized weights and empty grad
            if self.W.shape != (weight_dim, g_nout):
                raise ValueError('expected {} found {}'.format(
                    self.W.shape, (weight_dim, g_nout)))
            assert self.dW.shape == (weight_dim, g_nout)

        self.W_input = self.W[:nin].reshape((g_nout, nin))
        self.W_recur = self.W[nin:-1].reshape((g_nout, nout))

        self.b = self.W[-1:].reshape((g_nout, 1))

        if doFill:
            wtlist = ('W_input', 'W_recur')
            gatelist = [g * nout for g in range(0, self.ngates + 1)]
            for wtnm in wtlist:
                wtmat = getattr(self, wtnm)
                if wtnm == 'W_recur' and self.init_inner is not None:
                    initfunc = self.init_inner
                else:
                    initfunc = self.init

                for gb, ge in zip(gatelist[:-1], gatelist[1:]):
                    initfunc.fill(wtmat[gb:ge])
            self.b.fill(0.)

        self.dW_input = self.dW[:nin].reshape(self.W_input.shape)
        self.dW_recur = self.dW[nin:-1].reshape(self.W_recur.shape)
        self.db = self.dW[-1:].reshape(self.b.shape)
def init_params ( self , shape ) : ( nout , nin ) = shape g_nout = self . ngates * nout doFill = False weight_dim = ( nout + nin + 1 ) if self . W is None : self . W = self . be . empty ( ( weight_dim , g_nout ) ) self . dW = self . be . zeros_like ( self . W ) doFill = True else : # Deserialized weights and empty grad if self . W . shape != ( weight_dim , g_nout ) : raise ValueError ( 'expected {} found {}' . format ( self . W . shape , ( weight_dim , g_nout ) ) ) assert self . dW . shape == ( weight_dim , g_nout ) self . W_input = self . W [ : nin ] . reshape ( ( g_nout , nin ) ) self . W_recur = self . W [ nin : - 1 ] . reshape ( ( g_nout , nout ) ) self . b = self . W [ - 1 : ] . reshape ( ( g_nout , 1 ) ) if doFill : wtlist = ( 'W_input' , 'W_recur' ) gatelist = [ g * nout for g in range ( 0 , self . ngates + 1 ) ] for wtnm in wtlist : wtmat = getattr ( self , wtnm ) if wtnm == 'W_recur' and self . init_inner is not None : initfunc = self . init_inner else : initfunc = self . init for gb , ge in zip ( gatelist [ : - 1 ] , gatelist [ 1 : ] ) : initfunc . fill ( wtmat [ gb : ge ] ) self . b . fill ( 0. ) self . dW_input = self . dW [ : nin ] . reshape ( self . W_input . shape ) self . dW_recur = self . dW [ nin : - 1 ] . reshape ( self . W_recur . shape ) self . db = self . dW [ - 1 : ] . reshape ( self . b . shape )