(self, input_depth, filter_size, output_depth, layer_config='ll', padding='left', dropout=0.0)
Parameters:
            input_depth: Size of last dimension of input
            filter_size: Hidden size of the middle layer
            output_depth: Size last dimension of the final output
            layer_config: ll -> linear + ReLU + linear
                          cc -> conv + ReLU + conv etc.
            padding: left -> pad on the left side (to mask future data), 
                     both -> pad on both sides
            dropout: Dropout probability (Should be non-zero only during training)
Parameters:
            input_depth: Size of last dimension of input
            filter_size: Hidden size of the middle layer
            output_depth: Size last dimension of the final output
            layer_config: ll -> linear + ReLU + linear
                          cc -> conv + ReLU + conv etc.
            padding: left -> pad on the left side (to mask future data), 
                     both -> pad on both sides
            dropout: Dropout probability (Should be non-zero only during training)
Parameters : input_depth : Size of last dimension of input filter_size : Hidden size of the middle layer output_depth : Size last dimension of the final output layer_config : ll - > linear + ReLU + linear cc - > conv + ReLU + conv etc . padding : left - > pad on the left side ( to mask future data ) both - > pad on both sides dropout : Dropout probability ( Should be non - zero only during training )
def __init__(self, input_depth, filter_size, output_depth, layer_config='ll', padding='left', dropout=0.0):
        """
        Parameters:
            input_depth: Size of last dimension of input
            filter_size: Hidden size of the middle layer
            output_depth: Size last dimension of the final output
            layer_config: ll -> linear + ReLU + linear
                          cc -> conv + ReLU + conv etc.
            padding: left -> pad on the left side (to mask future data), 
                     both -> pad on both sides
            dropout: Dropout probability (Should be non-zero only during training)
        """
        super(PositionwiseFeedForward, self).__init__()
        
        layers = []
        sizes = ([(input_depth, filter_size)] + 
                 [(filter_size, filter_size)]*(len(layer_config)-2) + 
                 [(filter_size, output_depth)])

        for lc, s in zip(list(layer_config), sizes):
            if lc == 'l':
                layers.append(nn.Linear(*s))
            elif lc == 'c':
                layers.append(Conv(*s, kernel_size=3, pad_type=padding))
            else:
                raise ValueError("Unknown layer type {}".format(lc))

        self.layers = nn.ModuleList(layers)
        self.relu = nn.ReLU()
        self.dropout = nn.Dropout(dropout)
def __init__ ( self , input_depth , filter_size , output_depth , layer_config = 'll' , padding = 'left' , dropout = 0.0 ) : super ( PositionwiseFeedForward , self ) . __init__ ( ) layers = [ ] sizes = ( [ ( input_depth , filter_size ) ] + [ ( filter_size , filter_size ) ] * ( len ( layer_config ) - 2 ) + [ ( filter_size , output_depth ) ] ) for lc , s in zip ( list ( layer_config ) , sizes ) : if lc == 'l' : layers . append ( nn . Linear ( * s ) ) elif lc == 'c' : layers . append ( Conv ( * s , kernel_size = 3 , pad_type = padding ) ) else : raise ValueError ( "Unknown layer type {}" . format ( lc ) ) self . layers = nn . ModuleList ( layers ) self . relu = nn . ReLU ( ) self . dropout = nn . Dropout ( dropout )