# 来自 CAL 代码
# Main
Run = ExptPeerRegC10CAL(
{"--is_train": True, # why 居然可以这么写?
"--is_plot_results": False,
"--is_class_resolved": False,
"--is_load": False,
"--exp_name": exp_name,
"--dataset": dataset,
"--netARCH": netARCH,
"--num_classes": 10,
"--lossfunc": lossfunc,
"--optimizer": "SGD",
"--lr": 0.1, # 0.1
"--lr_scheduler": "step",
"--weight_decay": 0.0005,
"--lr_decay_step_size": 60, # 60
"--lr_decay_rate": 0.1, # 0.1
"--batch_size": 128,
"--max_epoch": max_epoch,
"--is_validate": False,
"--val_ratio": 0.0,
"--with_noise": with_noise,
"--noise_label_fname": noise_file,
"--is_peerloss": is_peer,
"--alpha": 0.0,
"--alpha_scheduler": 'seg',
"--alpha_list": alpha_list,
"--milestones": milestones,
"--gpu_idx": gpu_idx,
"--chosen_classes": chosen_classes,
"--sample_weight_path": sample_weight_path,
"--beta_path": None,
},
json_path = json_path,
outputfile= outfile
)
Run.train()
# 来自 TopoFilter 的代码
if noise_type == "uniform":
noise_y_train, p, keep_indices = noisify_with_P(y_train, nb_classes=num_class, noise=noise_level, random_state=random_seed)
trainset.update_corrupted_label(noise_y_train) # 居然可以这样写代码? 但 trainloader 也不用重新装一遍更新后的 trainset
print("apply uniform noise")
# Dataset 写一个函数类的思想还是非常的妙
# TODO: 使用这个函数来进行更新: update_selected_data(self, selected_indices)
trainset.update_corrupted_label(noise_y_train) # 先转换为 noisy label 的 data
trainset.update_selected_data(select_train_ind) # 只使用部分选中的数据