Exemplo n.º 1
0
def train_dataset(dataset, config):
    config = configurations_qa[config](dataset)
    n_iters = dataset.n_iters if hasattr(dataset, "n_iters") else 25
    trainer = Trainer(dataset, config=config, _type=dataset.trainer_type)
    trainer.train(dataset.train_data,
                  dataset.dev_data,
                  n_iters=n_iters,
                  save_on_metric=dataset.save_on_metric)
    return trainer
Exemplo n.º 2
0
def train_dataset_and_get_atn_map(dataset, encoders, num_iters=15):
    for e in encoders:
        config = configurations_qa[e](dataset)
        trainer = Trainer(dataset, config=config, _type=dataset.trainer_type)
        trainer.train(dataset.train_data,
                      dataset.dev_data,
                      n_iters=num_iters,
                      save_on_metric=dataset.save_on_metric)
        # Get train losses as well?

        evaluator = Evaluator(dataset, trainer.model.dirname)
        _, attentions, scores = evaluator.evaluate(dataset.test_data,
                                                   save_results=True)
        return scores, attentions
Exemplo n.º 3
0
def train_dataset(dataset, config):
    try:
        config = configurations_qa[config](dataset)
        n_iters = dataset.n_iters if hasattr(dataset, "n_iters") else 25
        trainer = Trainer(dataset, config=config, _type=dataset.trainer_type)
        trainer.train(dataset.train_data,
                      dataset.dev_data,
                      n_iters=n_iters,
                      save_on_metric=dataset.save_on_metric)
        evaluator = Evaluator(dataset, trainer.model.dirname)
        _ = evaluator.evaluate(dataset.test_data, save_results=True)
        return trainer, evaluator
    except Exception as e:
        print(e)
        return