(self)
Helper function for configuring shapes depending on the merge concatenation type
Helper function for configuring shapes depending on the merge concatenation type
Helper function for configuring shapes depending on the merge concatenation type
def _configure_merge(self):
        """
        Helper function for configuring shapes depending on the merge concatenation type
        """
        in_shapes = [l.out_shape for l in self.layers]
        # Figure out how to merge
        if self.merge == "recurrent":
            catdims = [xs[1] for xs in in_shapes]
            self.out_shape = (in_shapes[0][0], sum(catdims))
            stride_size = self.be.bsz
        elif self.merge == "depth":
            catdims = [xs[0] for xs in in_shapes]
            self.out_shape = (sum(catdims),) + in_shapes[0][1:]
            stride_size = np.prod(in_shapes[0][1:])
        elif self.merge == "stack":
            catdims = [xs if isinstance(xs, int) else np.prod(xs) for xs in in_shapes]
            self.out_shape = sum(catdims)
            stride_size = 1
        end_idx = [idx * stride_size for idx in np.cumsum(catdims)]
        start_idx = [0] + end_idx[:-1]
        self.slices = [slice(s, e) for s, e in zip(start_idx, end_idx)]
def _configure_merge ( self ) : in_shapes = [ l . out_shape for l in self . layers ] # Figure out how to merge if self . merge == "recurrent" : catdims = [ xs [ 1 ] for xs in in_shapes ] self . out_shape = ( in_shapes [ 0 ] [ 0 ] , sum ( catdims ) ) stride_size = self . be . bsz elif self . merge == "depth" : catdims = [ xs [ 0 ] for xs in in_shapes ] self . out_shape = ( sum ( catdims ) , ) + in_shapes [ 0 ] [ 1 : ] stride_size = np . prod ( in_shapes [ 0 ] [ 1 : ] ) elif self . merge == "stack" : catdims = [ xs if isinstance ( xs , int ) else np . prod ( xs ) for xs in in_shapes ] self . out_shape = sum ( catdims ) stride_size = 1 end_idx = [ idx * stride_size for idx in np . cumsum ( catdims ) ] start_idx = [ 0 ] + end_idx [ : - 1 ] self . slices = [ slice ( s , e ) for s , e in zip ( start_idx , end_idx ) ]