def main(): parser = ArgumentParser() parser.add_argument('mode', choices=['train', 'predict'], help='pipeline mode') parser.add_argument('model', choices=['rnn', 'cnn', 'multihead'], help='model to be used') parser.add_argument('dataset', choices=['QQP', 'SNLI'], help='dataset to be used') parser.add_argument('--gpu', default='0', help='index of GPU to be used (default: %(default))') args = parser.parse_args() set_visible_gpu(args.gpu) main_config = init_config() model_config = init_config(args.model) mode = args.mode if 'train' in mode: train(main_config, model_config, args.model, args.dataset) else: predict(main_config, model_config, args.model)
def main(): parser = ArgumentParser() parser.add_argument('--data-dir', default='./corpora', help='Path to original quora split') parser.add_argument('--model-dir', default='./model_dir', help='Path to save the trained model') parser.add_argument('--use-help', choices=[True, False], default=False, type=bool, help='should model use help on difficult examples') parser.add_argument('--gpu', default='0', help='index of GPU to be used (default: %(default))') parser.add_argument('--embeddings', choices=['no', 'fixed', 'tunable'], default='no', type=str, help='embeddings') parser.add_argument('--batch-size', choices=[4, 128, 256, 512], default=128, type=int, help='batch size') parser.add_argument('--syn-weight', default=1, type=float, help='Weight for loss function') args = parser.parse_args() logger.info(args) if args.embeddings == 'no': args.use_embed = False args.tune = False else: args.use_embed = True args.tune = False if args.embeddings == 'fixed' else True set_visible_gpu(args.gpu) args.model_dir = '{}_bilstm_{}_{}_{}'.format(args.model_dir, args.embeddings, args.batch_size, args.syn_weight ) main_config = init_config() args.max_seq_length, args.vocab_size = get_vocab(main_config, args, logger) logger.info(args) train(main_config, args)
def main(): parser = ArgumentParser() parser.add_argument( 'mode', choices=['train', 'predict'], help='pipeline mode', ) parser.add_argument( 'model', choices=['rnn', 'cnn', 'multihead'], help='model to be used', ) parser.add_argument( 'dataset', choices=['QQP', 'SNLI', 'ANLI'], nargs='?', help='dataset to be used', ) parser.add_argument( '--experiment_name', required=False, help='the name of run experiment', ) parser.add_argument( '--gpu', default='0', help='index of GPU to be used (default: %(default))', ) args = parser.parse_args() if 'train' in args.mode: if args.dataset is None: parser.error('Positional argument [dataset] is mandatory') set_visible_gpu(args.gpu) main_config = init_config() model_config = init_config(args.model) mode = args.mode experiment_name = args.experiment_name if experiment_name is None: experiment_name = create_experiment_name(args.model, main_config, model_config) if 'train' in mode: train(main_config, model_config, args.model, experiment_name, args.dataset) else: predict(main_config, model_config, args.model, experiment_name)