overrides = {} if args.device is not None: overrides["trainer"] = {"cuda_device": args.device} if args.lazy is not None: overrides["dataset_reader"] = {"lazy": args.lazy} configs.append(Params(overrides)) for config_file in args.config: configs.append(Params.from_file(config_file)) configs.append(Params.from_file(args.base_config)) else: serialization_dir = args.resume configs.append( Params.from_file(os.path.join(serialization_dir, "config.json"))) train_params = util.merge_configs(configs) if "vocabulary" in train_params: # Remove this key to make AllenNLP happy train_params["vocabulary"].pop("non_padded_namespaces", None) predict_params = train_params.duplicate() import_submodules("udify") try: util.cache_vocab(train_params) train_model(train_params, serialization_dir, recover=bool(args.resume)) except KeyboardInterrupt: logger.warning("KeyboardInterrupt, skipping training") dev_file = predict_params["validation_data_path"]
log_dir_name = args.name if not log_dir_name: file_name = args.dataset_config if args.dataset_config else args.parameters_config log_dir_name = os.path.basename(file_name).split(".")[0] if not args.resume: serialization_dir = os.path.join( "logs", log_dir_name, datetime.datetime.now().strftime("%Y.%m.%d_%H.%M.%S")) overrides = {} if args.device is not None: overrides["trainer"] = {"cuda_device": args.device} if args.lazy is not None: overrides["dataset_reader"] = {"lazy": args.lazy} train_params = util.merge_configs(args.parameters_config, args.dataset_config, overrides) #else: # serialization_dir = args.resume # train_params = Params.from_file(os.path.join(serialization_dir, "config.json")) #TODO override stuff! if "vocabulary" in train_params: # Remove this key to make AllenNLP happy train_params["vocabulary"].pop("non_padded_namespaces", None) predict_params = train_params.duplicate() import_submodules("udify") try: util.cache_vocab(train_params)