def main_bs2sg(num_epoch: int = 1): device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") model = base_model.get_bs2sg() model = model.to(device) optimizer = torch.optim.Adam(model.parameters(), lr=0.01) scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.75) criterion = torch.nn.CrossEntropyLoss() dataset = data_loader.SetBs2Sg([ "data/actual/spacegroup_list_{}.txt".format(i) for i in range(1, 231) ], 0.1) train_loader, valid_loader = data_loader.get_valid_train_loader( dataset, 32) network.validate_train_loop(device, model, optimizer, scheduler, criterion, valid_loader, train_loader, num_epoch) data_processing.create_empty_list_files(230, "data/guess/", "spacegroup_list_{}.txt") data_processing.create_guess_list_files(device, model, 230, "data/actual/valid_list.txt", "data/guess/", "spacegroup_list_{}.txt")
def main_cs2sg_all(num_epoch: int = 1): data_processing.create_empty_list_files(230, "data/guess/", "spacegroup_list_{}.txt") input_sizes = [800, 2800, 2100, 1000, 1300, 600, 1100] cs_sizes = crystal.crystal_system_sizes() output_sizes = [ cs_sizes[i - 1] - cs_sizes[i - 2] + 1 if i > 1 else 3 for i in range(1, 8) ] for i in range(1, 8): main_cs2sg_one(i, (input_sizes[i], 128, 128, output_sizes[i]), num_epoch)
def main_crys2sg_all(num_epoch: int = 1): data_processing.create_empty_list_files(230, "data/guess/", "spacegroup_list_{}.txt") for i in range(1, 8): main_crys2sg_one(i, num_epoch)