Exemplo n.º 1
0
    import sys
    from params import Params
    from dataset import qa
    import keras.backend as K
    import units
    from loss import *

    from models.match import keras as models
    from params import Params
    params = Params()

    config_file = 'config/qalocal.ini'  # define dataset in the config
    params.parse_config(config_file)

    reader = qa.setup(params)
    qdnn = models.setup(params)
    model = qdnn.getModel()

    from loss import *
    model.compile(loss=rank_hinge_loss({'margin': 0.2}),
                  optimizer=units.getOptimizer(name=params.optimizer,
                                               lr=params.lr),
                  metrics=['accuracy'])
    model.summary()

    #    generators = [reader.getTrain(iterable=False) for i in range(params.epochs)]
    #    [q,a,score] = reader.getPointWiseSamples()
    #    model.fit(x = [q,a,a],y = [q,a,q],epochs = 10,batch_size =params.batch_size)

    #    def gen():
    #        while True:
Exemplo n.º 2
0

def config_adapter(conf):
    conf.text1_maxlen = conf.max_sequence_length
    conf.embed = conf.lookup_table
    conf.vocab_size = len(conf.alphabet)
    conf.hidden_sizes = [20, 1]
    conf.num_layers = 2
    conf.embed_size = conf.embedding_size
    conf.bin_num =1
    conf.target_mode = "ranking"
    
    
    




if __name__ == "__main__":
    from params import Params
    params = Params()
    config_file = 'config/qalocal.ini'    # define dataset in the config
    params.parse_config(config_file)
    params.network_type = "anmm.ANMM"

    
    from dataset import qa
    reader = qa.setup(params)
    from models.match import keras as models
    model = models.setup(params)