def training_from_flag(flags): """ Training interface. 1. Read data 2. initialize network 3. train network 4. record flags :param flag: The training flags read from command line or parameter.py :return: None """ if flags.use_cpu_only: os.environ['CUDA_VISIBLE_DEVICES'] = '-1' # Get the data train_loader, test_loader = data_reader.read_data(flags) # Reset the boundary is normalized if flags.normalize_input: flags.geoboundary_norm = [-1, 1, -1, 1] print("Boundary is set at:", flags.geoboundary) print("Making network now") # Make Network ntwk = Network(Forward, flags, train_loader, test_loader) # Training process print("Start training now...") ntwk.train() # Do the house keeping, write the parameters and put into folder, also use pickle to save the flags obejct write_flags_and_BVE(flags, ntwk.best_validation_loss, ntwk.ckpt_dir)
def training_from_flag(flags): """ Training interface. 1. Read data 2. initialize network 3. train network 4. record flags :param flag: The training flags read from command line or parameter.py :return: None """ # Get the data train_loader, test_loader = data_reader.read_data(flags) print("Making network now") # Make Network ntwk = Network(VAE, flags, train_loader, test_loader) # Training process print("Start training now...") ntwk.train() # Do the house keeping, write the parameters and put into folder, also use pickle to save the flags obejct write_flags_and_BVE(flags, ntwk.best_validation_loss, ntwk.ckpt_dir)
# Read the parameters to be set flags = flag_reader.read_flag() # Get the data train_loader, test_loader = data_reader.read_data(x_range=flags.x_range, y_range=flags.y_range, geoboundary=flags.geoboundary, batch_size=flags.batch_size, normalize_input=flags.normalize_input, data_dir=flags.data_dir) # Reset the boundary is normalized if flags.normalize_input: flags.geoboundary = [-1, 1, -1, 1] print("Boundary is set at:", flags.geoboundary) print("Making network now") # Make Network ntwk = Network(Forward, flags, train_loader, test_loader) # Training process print("Start training now...") ntwk.train() # Do the house keeping, write the parameters and put into folder flag_reader.write_flags_and_BVE(flags, ntwk.best_validation_loss) put_param_into_folder()