Exemple #1
0
    train_examples, val_examples = load_train_val_examples(args)
    trainer.train(args, train_examples, val_examples)
    def do_eval(args):
        args.model_path = args.best_model_path
        eval_examples = load_eval_examples(eval_text_file, eval_bio_file)
        model = load_model(args)
        trainer.evaluate(args, model, eval_examples)

    def do_predict(args):
        args.model_path = args.best_model_path
        test_examples = load_test_examples(args)
        model = load_model(args)
        trainer.predict(args, model, test_examples)

    #do_eval(args)
    #do_predict(args)
    #print(trainer.pred_results)

if __name__ == '__main__':

    def add_special_args(parser):
        parser.add_argument("--generate_submission",
                            action="store_true",
                            help="")
        return parser

    args = get_args(experiment_params=experiment_params,
                    special_args=[add_special_args])
    logger.info(f"args: {args}")
    main(args)
Exemple #2
0
                              args.train_file, test_data_generator,
                              args.test_file)

        elif args.do_train:
            train_examples, val_examples = load_train_val_examples(args)
            trainer.train(args, train_examples, val_examples)

        elif args.do_eval:
            _, eval_examples = load_train_val_examples(args)
            model = load_model(args)
            trainer.evaluate(args, model, eval_examples)

        elif args.do_predict:
            test_examples = load_test_examples(args)
            model = load_model(args)
            trainer.predict(args, model, test_examples)
            save_ner_preds(args, trainer.pred_results, test_examples)


if __name__ == '__main__':

    def add_special_args(parser):
        parser.add_argument("--do_eda", action="store_true", help="")
        parser.add_argument("--generate_submission",
                            action="store_true",
                            help="")
        return parser

    args = get_args([add_special_args])
    main(args)