-
-
Notifications
You must be signed in to change notification settings - Fork 435
Open
Description
Hi,
I'd like to use attacks available in foolbox to run them over the full cifar10, 100, imagenet, and not the few images that are available from the sample folder. The tutorial only explains that and when I tested questions on issues, I was not successful in loading.
Basically I want to load a pretrained model, and load a batch of size 128, and see accuracies.`Any help would help a lot and appreciated. Thanks in advance.
model = timm.create_model("resnet18", pretrained=True, num_class=10)
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
testset = torchvision.datasets.CIFAR10(root='./data', train=False, download=True, transform=transform_test)
testloader = torch.utils.data.DataLoader(testset, batch_size=128, shuffle=False, num_workers=2)
processing =dict( mean=[0.491, 0.482, 0.446],std=[0.247, 0.243, 0.261], axis=-3)
bounds = ((0,1))
fmodel = fb.PyTorchModel(model, bounds=bounds, preprocessing=processing)
assert fmodel.bounds == (0, 1)
images, labels = next(iter(testloader))
fb.utils.accuracy(fmodel, images, labels)
attack = fb.attacks.LinfDeepFoolAttack()
raw, clipped, is_adv = attack(fmodel, images, labels, epsilons=0.03)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Even when I send everything to cuda, same error happens!! is there any miminal working code that I uses the full cifar10
that I use it as the start code?
Metadata
Metadata
Assignees
Labels
No labels