def new_net(): net = netter.CustomResNet18() net = net.to("cuda:0") criterion = nn.CrossEntropyLoss() optimizer = optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9, weight_decay=1e-4) return nf.NetTrainer(net=net, criterion=criterion, optimizer=optimizer)
def new_network(): # net = netter.ResNet18() net = netter.CustomResNet18() net = net.to("cuda:0") criterion = nn.CrossEntropyLoss() # probabilmente la dovremo cambiare optimizer = optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9, weight_decay=1e-4) return nf.NetTrainer(net=net, criterion=criterion, optimizer=optimizer)
have_to_save_it = False thename = "starting_net" if have_to_save_it: save_the_net(thename=thename) net, b, c, d = load_the_net(thename=thename) net = net.to("cuda:0") criterion = nn.CrossEntropyLoss() optimizer = optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9, weight_decay=1e-4) net_trainer = nf.NetTrainer(net=net, criterion=criterion, optimizer=optimizer) dataset = CifarLoader(transform=None, first_time_multiplier=first_time_multiplier, name=None, joking=True).restore(b, c, d, transform=traintrans_01, name=None) el_for_active = [x for x in dataset.already_selected_indices] # active_indices = net_trainer.bestofn(dataset, [x for x in dataset.train_indices if x not in el_for_active], tslp) net_trainer.distance_and_varratio( dataset, [x for x in dataset.train_indices if x not in el_for_active], tslp, el_for_active) # net_trainer.greedy_k_centers(dataset, [x for x in dataset.train_indices if x not in el_for_active], tslp, dataset.select_for_train(el_for_active))