def get_training_parameters(opt): train = DD() static = DD() static.exp = opt.exp static.seed = opt.random_seed # weight decay static.l2 = opt.l2 static.vl2 = True static.lrsched = opt.learning_rate_schedule # 'warmup_linear' static.lrwarm = opt.learning_rate_warmup # 0.002 # gradient clipping static.clip = opt.clip # what loss function to use static.loss = opt.loss dynamic = DD() dynamic.lr = opt.learning_rate # learning rate dynamic.bs = opt.batch_size # batch size # optimizer to use {adam, rmsprop, etc.} dynamic.optim = opt.optimizer # rmsprop # alpha is interpolation average static.update(opt[dynamic.optim]) train.static = static train.dynamic = dynamic return train
def get_parameters(opt, exp_type="model"): params = DD() params.net = DD() params.mle = 0 params.dataset = opt.dataset params.net = get_net_parameters(opt) params.train = get_training_parameters(opt) params.model = params.net.model params.exp = opt.exp params.data = get_data_parameters(opt, params.exp, params.dataset) params.eval = get_eval_parameters(opt, params.data.get("categories", None)) #params.n_per_node = opt.n_per_node #params.max_path_len = opt.max_path_len #params.n_train = opt.n_train #params.n_dev = opt.n_dev #params.n_test = opt.n_test meta = DD() params.trainer = opt.trainer meta.iterations = int(opt.iterations) meta.cycle = opt.cycle params.cycle = opt.cycle params.iters = int(opt.iterations) global toy toy = opt.toy global do_gen do_gen = opt.do_gen global save save = opt.save global test_save test_save = opt.test_save global save_strategy save_strategy = opt.save_strategy print(params) return params, meta
return data_params gens_file = args.gens_file split = gens_file.split("/")[-1].split(".")[0] n = args.n def flatten(outer): return [el for key in outer for el in key] opt = DD() opt.data = DD() opt.dataset = "atomic" opt.exp = "generation" data_params = get_data_params(gens_file) categories = data_params[ "categories"] #sorted(["oReact", "oEffect", "oWant", "xAttr", "xEffect", "xIntent", "xNeed", "xReact", "xWant"]) opt.data.categories = data_params["categories"] if "maxe1" in data_params: opt.data.maxe1 = data_params["maxe1"] opt.data.maxe2 = data_params["maxe2"] opt.data.maxr = data_params["maxr"] path = "data/atomic/processed/generation/{}.pickle".format( utils.make_name_string(opt.data))