I want to dump the data so that I can load it back for training my model.
My code snipped for dumping the data:
for batch_idx, (image, label) in enumerate(dataloader):
image, label = image.to(device), label.to(device)
perturbed_image = attack.perturb(image, label)
#---------- Classifier ----------
predict_A = classifier(perturbed_image)
pred_label = torch.max(predict_A.data, 1)[1]
if pred_label != label:
adv_data.append( (perturbed_image.to("cpu"), label.to("cpu")) )
Is there any other way I can dump it correctly so as to load it in the torch.utils.data.DataLoader
.