def main(args):
    """
        main_func
    """
    if args.print_config:
        print_arguments(args)
    start_procs(args)
Exemplo n.º 2
0
    if 'kn' in args.task_name:
        args.use_knowledge = True
    else:
        args.use_knowledge = False

    processor, [train_data, dev_data], warmup_steps = build_data(args)

    args.voc_size = len(
        open(args.vocab_path, 'r', encoding='utf-8').readlines())
    num_labels = len(processor.get_labels())

    checkpoint = None
    if args.init_checkpoint:
        print('Loading checkpoint from %s' % args.init_checkpoint)
        checkpoint = torch.load(args.init_checkpoint,
                                map_location=lambda storage, loc: storage)

    retrieval_model = build_model(args, num_labels, checkpoint)

    optimizer = build_optim(retrieval_model, args, warmup_steps, checkpoint)

    train_model(retrieval_model, optimizer, train_data, dev_data, processor,
                args)


if __name__ == '__main__':
    args = base_parser()
    print_arguments(args)
    main(args)