(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(LSTM, self).allocate(shared_outputs)
        # indices for slicing gate buffers
        (ifo1, ifo2) = (0, self.nout * 3)
        (i1, i2) = (0, self.nout)
        (f1, f2) = (self.nout, self.nout * 2)
        (o1, o2) = (self.nout * 2, self.nout * 3)
        (g1, g2) = (self.nout * 3, self.nout * 4)

        # States: hidden, cell, previous hidden, previous cell
        self.c_buffer = self.be.iobuf(self.out_shape)
        self.c = get_steps(self.c_buffer, self.out_shape)
        self.c_prev = self.c[-1:] + self.c[:-1]
        self.c_prev_bprop = [0] + self.c[:-1]

        self.c_act_buffer = self.be.iobuf(self.out_shape)
        self.c_act = get_steps(self.c_act_buffer, self.out_shape)

        # Gates: input, forget, output, input modulation
        self.ifog_buffer = self.be.iobuf(self.gate_shape)
        self.ifog = get_steps(self.ifog_buffer, self.gate_shape)
        self.ifo = [gate[ifo1:ifo2] for gate in self.ifog]
        self.i = [gate[i1:i2] for gate in self.ifog]
        self.f = [gate[f1:f2] for gate in self.ifog]
        self.o = [gate[o1:o2] for gate in self.ifog]
        self.g = [gate[g1:g2] for gate in self.ifog]

        # State deltas
        self.c_delta_buffer = self.be.iobuf((self.out_shape))
        self.c_delta = get_steps(self.c_delta_buffer, self.out_shape)
        self.c_delta_prev = [None] + self.c_delta[:-1]

        # Pre activation gate deltas
        self.ifog_delta_buffer = self.be.iobuf(self.gate_shape)
        self.ifog_delta = get_steps(self.ifog_delta_buffer, self.gate_shape)
        self.i_delta = [gate[i1:i2] for gate in self.ifog_delta]
        self.f_delta = [gate[f1:f2] for gate in self.ifog_delta]
        self.o_delta = [gate[o1:o2] for gate in self.ifog_delta]
        self.g_delta = [gate[g1:g2] for gate in self.ifog_delta]
        self.bufs_to_reset.append(self.c_buffer)
def allocate ( self , shared_outputs = None ) : super ( LSTM , self ) . allocate ( shared_outputs ) # indices for slicing gate buffers ( ifo1 , ifo2 ) = ( 0 , self . nout * 3 ) ( i1 , i2 ) = ( 0 , self . nout ) ( f1 , f2 ) = ( self . nout , self . nout * 2 ) ( o1 , o2 ) = ( self . nout * 2 , self . nout * 3 ) ( g1 , g2 ) = ( self . nout * 3 , self . nout * 4 ) # States: hidden, cell, previous hidden, previous cell self . c_buffer = self . be . iobuf ( self . out_shape ) self . c = get_steps ( self . c_buffer , self . out_shape ) self . c_prev = self . c [ - 1 : ] + self . c [ : - 1 ] self . c_prev_bprop = [ 0 ] + self . c [ : - 1 ] self . c_act_buffer = self . be . iobuf ( self . out_shape ) self . c_act = get_steps ( self . c_act_buffer , self . out_shape ) # Gates: input, forget, output, input modulation self . ifog_buffer = self . be . iobuf ( self . gate_shape ) self . ifog = get_steps ( self . ifog_buffer , self . gate_shape ) self . ifo = [ gate [ ifo1 : ifo2 ] for gate in self . ifog ] self . i = [ gate [ i1 : i2 ] for gate in self . ifog ] self . f = [ gate [ f1 : f2 ] for gate in self . ifog ] self . o = [ gate [ o1 : o2 ] for gate in self . ifog ] self . g = [ gate [ g1 : g2 ] for gate in self . ifog ] # State deltas self . c_delta_buffer = self . be . iobuf ( ( self . out_shape ) ) self . c_delta = get_steps ( self . c_delta_buffer , self . out_shape ) self . c_delta_prev = [ None ] + self . c_delta [ : - 1 ] # Pre activation gate deltas self . ifog_delta_buffer = self . be . iobuf ( self . gate_shape ) self . ifog_delta = get_steps ( self . ifog_delta_buffer , self . gate_shape ) self . i_delta = [ gate [ i1 : i2 ] for gate in self . ifog_delta ] self . f_delta = [ gate [ f1 : f2 ] for gate in self . ifog_delta ] self . o_delta = [ gate [ o1 : o2 ] for gate in self . ifog_delta ] self . g_delta = [ gate [ g1 : g2 ] for gate in self . ifog_delta ] self . bufs_to_reset . append ( self . c_buffer )