def main_bs2cs(num_epoch: int = 1): device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") model = base_model.get_bs2cs() 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.SetBs2Cs( [0, 1, 3, 4, 5, 7, 8, 13, 31, 34, 37 ], # 12 hs points in Brillouin zone ["data/actual/crystal_list_{}.txt".format(i) for i in range(1, 8)], 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_guess_list_files( device, model, 7, [0, 1, 3, 4, 5, 7, 8, 13, 31, 34, 37 ], # 12 hs points in Brillouin zone "data/actual/valid_list.txt", "data/guess/", "crystal_list_{}.txt")
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")