for tmp in load_dataset(config.set_params["path"], subset="val") ] # ------ save hyperparameters ------- os.makedirs(train_params["save_path"][-1], exist_ok=True) with open(os.path.join(train_params["save_path"][-1], "hyperparameters.txt"), "w") as file: for key, value in subnet_params.items(): file.write(key + ": " + str(value) + "\n") for key, value in it_net_params.items(): file.write(key + ": " + str(value) + "\n") for key, value in train_params.items(): file.write(key + ": " + str(value) + "\n") file.write("train_phases" + ": " + str(train_phases) + "\n") # ------ construct network and train ----- subnet = subnet(**subnet_params).to(device) it_net = IterativeNet(subnet, **it_net_params).to(device) for i in range(train_phases): train_params_cur = {} for key, value in train_params.items(): train_params_cur[key] = (value[i] if isinstance(value, (tuple, list)) else value) print("Phase {}:".format(i + 1)) for key, value in train_params_cur.items(): print(key + ": " + str(value)) it_net.train_on((Y_train, X_train), (Y_val, X_val), **train_params_cur)
for key, value in subnet_params.items(): file.write(key + ": " + str(value) + "\n") for key, value in it_net_params.items(): file.write(key + ": " + str(value) + "\n") for key, value in train_params.items(): file.write(key + ": " + str(value) + "\n") for key, value in train_data_params.items(): file.write(key + ": " + str(value) + "\n") for key, value in val_data_params.items(): file.write(key + ": " + str(value) + "\n") file.write("train_phases" + ": " + str(train_phases) + "\n") # ------ construct network and train ----- subnet = subnet(**subnet_params).to(device) it_net = IterativeNet(subnet, **it_net_params).to(device) train_data = train_data("train", **train_data_params) val_data = val_data("val", **val_data_params) for i in range(train_phases): train_params_cur = {} for key, value in train_params.items(): train_params_cur[key] = (value[i] if isinstance(value, (tuple, list)) else value) print("Phase {}:".format(i + 1)) for key, value in train_params_cur.items(): print(key + ": " + str(value)) it_net.train_on(train_data, val_data, **train_params_cur)