(vocab_size, rlayer_type)
return Model(layers=layers)
Create LSTM/GRU model for bAbI dataset.

    Args:
        vocab_size (int) : String of bAbI data.
        rlayer_type (string) : Type of recurrent layer to use (gru or lstm).

    Returns:
        Model : Model of the created network
Create LSTM/GRU model for bAbI dataset.
Create LSTM / GRU model for bAbI dataset .
def create_model(vocab_size, rlayer_type):
    """
    Create LSTM/GRU model for bAbI dataset.

    Args:
        vocab_size (int) : String of bAbI data.
        rlayer_type (string) : Type of recurrent layer to use (gru or lstm).

    Returns:
        Model : Model of the created network
    """
    # recurrent layer parameters (default gru)
    rlayer_obj = GRU if rlayer_type == 'gru' else LSTM
    rlayer_params = dict(output_size=100, reset_cells=True,
                         init=GlorotUniform(), init_inner=Orthonormal(0.5),
                         activation=Tanh(), gate_activation=Logistic())

    # if using lstm, swap the activation functions
    if rlayer_type == 'lstm':
        rlayer_params.update(dict(activation=Logistic(), gate_activation=Tanh()))

    # lookup layer parameters
    lookup_params = dict(vocab_size=vocab_size, embedding_dim=50, init=Uniform(-0.05, 0.05))

    # Model construction
    story_path = [LookupTable(**lookup_params), rlayer_obj(**rlayer_params)]
    query_path = [LookupTable(**lookup_params), rlayer_obj(**rlayer_params)]

    layers = [MergeMultistream(layers=[story_path, query_path], merge="stack"),
              Affine(vocab_size, init=GlorotUniform(), activation=Softmax())]

    return Model(layers=layers)
def create_model ( vocab_size , rlayer_type ) : # recurrent layer parameters (default gru) rlayer_obj = GRU if rlayer_type == 'gru' else LSTM rlayer_params = dict ( output_size = 100 , reset_cells = True , init = GlorotUniform ( ) , init_inner = Orthonormal ( 0.5 ) , activation = Tanh ( ) , gate_activation = Logistic ( ) ) # if using lstm, swap the activation functions if rlayer_type == 'lstm' : rlayer_params . update ( dict ( activation = Logistic ( ) , gate_activation = Tanh ( ) ) ) # lookup layer parameters lookup_params = dict ( vocab_size = vocab_size , embedding_dim = 50 , init = Uniform ( - 0.05 , 0.05 ) ) # Model construction story_path = [ LookupTable ( * * lookup_params ) , rlayer_obj ( * * rlayer_params ) ] query_path = [ LookupTable ( * * lookup_params ) , rlayer_obj ( * * rlayer_params ) ] layers = [ MergeMultistream ( layers = [ story_path , query_path ] , merge = "stack" ) , Affine ( vocab_size , init = GlorotUniform ( ) , activation = Softmax ( ) ) ] return Model ( layers = layers )