(self, shared_outputs=None)
Allocate output buffer to store activations from fprop.

        Arguments:
            shared_outputs (Tensor, optional): pre-allocated tensor for activations to be
                                               computed into
Allocate output buffer to store activations from fprop.
Allocate output buffer to store activations from fprop .
def allocate(self, shared_outputs=None):
        """
        Allocate output buffer to store activations from fprop.

        Arguments:
            shared_outputs (Tensor, optional): pre-allocated tensor for activations to be
                                               computed into
        """
        super(GRU, self).allocate(shared_outputs)
        self.h_prev_bprop = [0] + self.h[:-1]

        # indices for slicing gate buffers
        (rz1, rz2) = (0, self.nout * 2)
        (r1, r2) = (0, self.nout)
        (z1, z2) = (self.nout, self.nout * 2)
        (c1, c2) = (self.nout * 2, self.nout * 3)

        # buffers for:
        # rh_prev_buffer: previous hidden multiply with r;
        # wrc_T_dc: wc_recur.T dot with hcan_delta
        self.rh_prev_buffer = self.be.iobuf(self.out_shape)
        self.rh_prev = get_steps(self.rh_prev_buffer, self.out_shape)
        self.wrc_T_dc = self.be.iobuf(self.nout)

        # Gates: reset: r; update: z; candidate h: hcan
        self.rzhcan_buffer = self.be.iobuf(self.gate_shape)
        self.rzhcan = get_steps(self.rzhcan_buffer, self.gate_shape)
        self.rz = [gate[rz1:rz2] for gate in self.rzhcan]
        self.r = [gate[r1:r2] for gate in self.rzhcan]
        self.z = [gate[z1:z2] for gate in self.rzhcan]
        self.hcan = [gate[c1:c2] for gate in self.rzhcan]

        # the buffer only deals with recurrent inputs to the gates
        self.rzhcan_rec_buffer = self.be.iobuf(self.gate_shape)
        self.rzhcan_rec = get_steps(self.rzhcan_rec_buffer, self.gate_shape)
        self.rz_rec = [gate[rz1:rz2] for gate in self.rzhcan_rec]
        self.hcan_rec = [gate[c1:c2] for gate in self.rzhcan_rec]

        # Pre activation gate deltas
        self.rzhcan_delta_buffer = self.be.iobuf(self.gate_shape)
        self.rzhcan_delta = get_steps(self.rzhcan_delta_buffer, self.gate_shape)
        self.rz_delta = [gate[rz1:rz2] for gate in self.rzhcan_delta]
        self.r_delta = [gate[r1:r2] for gate in self.rzhcan_delta]
        self.z_delta = [gate[z1:z2] for gate in self.rzhcan_delta]
        self.hcan_delta = [gate[c1:c2] for gate in self.rzhcan_delta]
def allocate ( self , shared_outputs = None ) : super ( GRU , self ) . allocate ( shared_outputs ) self . h_prev_bprop = [ 0 ] + self . h [ : - 1 ] # indices for slicing gate buffers ( rz1 , rz2 ) = ( 0 , self . nout * 2 ) ( r1 , r2 ) = ( 0 , self . nout ) ( z1 , z2 ) = ( self . nout , self . nout * 2 ) ( c1 , c2 ) = ( self . nout * 2 , self . nout * 3 ) # buffers for: # rh_prev_buffer: previous hidden multiply with r; # wrc_T_dc: wc_recur.T dot with hcan_delta self . rh_prev_buffer = self . be . iobuf ( self . out_shape ) self . rh_prev = get_steps ( self . rh_prev_buffer , self . out_shape ) self . wrc_T_dc = self . be . iobuf ( self . nout ) # Gates: reset: r; update: z; candidate h: hcan self . rzhcan_buffer = self . be . iobuf ( self . gate_shape ) self . rzhcan = get_steps ( self . rzhcan_buffer , self . gate_shape ) self . rz = [ gate [ rz1 : rz2 ] for gate in self . rzhcan ] self . r = [ gate [ r1 : r2 ] for gate in self . rzhcan ] self . z = [ gate [ z1 : z2 ] for gate in self . rzhcan ] self . hcan = [ gate [ c1 : c2 ] for gate in self . rzhcan ] # the buffer only deals with recurrent inputs to the gates self . rzhcan_rec_buffer = self . be . iobuf ( self . gate_shape ) self . rzhcan_rec = get_steps ( self . rzhcan_rec_buffer , self . gate_shape ) self . rz_rec = [ gate [ rz1 : rz2 ] for gate in self . rzhcan_rec ] self . hcan_rec = [ gate [ c1 : c2 ] for gate in self . rzhcan_rec ] # Pre activation gate deltas self . rzhcan_delta_buffer = self . be . iobuf ( self . gate_shape ) self . rzhcan_delta = get_steps ( self . rzhcan_delta_buffer , self . gate_shape ) self . rz_delta = [ gate [ rz1 : rz2 ] for gate in self . rzhcan_delta ] self . r_delta = [ gate [ r1 : r2 ] for gate in self . rzhcan_delta ] self . z_delta = [ gate [ z1 : z2 ] for gate in self . rzhcan_delta ] self . hcan_delta = [ gate [ c1 : c2 ] for gate in self . rzhcan_delta ]