Closed CQJhealer closed 3 years ago
是cifar10的里面需要有val吗 我的cifar10里面是data_batch_1这些文件。抱歉了,我看了你的介绍像是一个中国人,就打中文了。
为了回复有助于其他人我还是回英文吧。
The --data_root
argument is meant for specifying the ImageNet folder. Some changes are needed to adapt the code for CIFAR-10, namely https://github.com/cg563/simple-blackbox-attack/blob/master/run_simba.py#L173 should be changed to dset.CIFAR10
and the normalize
function in https://github.com/cg563/simple-blackbox-attack/blob/master/run_simba.py#L40 should be using CIFAR normalization constants.
Since running the code on CIFAR-10 seems to be in popular demand, I will update the repo with a CIFAR-10 version in the next few days if this helps.
def normalize(x):
return utils.apply_normalization(x, 'cifar')
testset = dset.ImageFolder(args.data_root + '/val', utils.CIFAR_TRANSFORM)
sugon@sugon-X795-G30:~/cqj/SimBA$ python run_simba.py --data_root dset.CIFAR10 --num_iters 10000 --pixel_attack --freq_dims 224
/home/sugon/miniconda3/envs/py36/lib/python3.6/site-packages/torchvision/transforms/transforms.py:280: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
"please use transforms.Resize instead.")
Traceback (most recent call last):
File "run_simba.py", line 173, in
I change the code ,but failed
I have added the CIFAR attack code to https://github.com/cg563/simple-blackbox-attack/blob/master/run_simba_cifar.py. Let me know if this resolves your issue.
I don't know how to express my thanks. I can only wish you good health and smooth work
I want to use cifar 10,but i don't konw how to set this . (py36) sugon@sugon-X795-G30:~/cqj/SimBA$ python run_simba.py --data_root cifar --num_iters 10000 --pixel_attack --freq_dims 224 /home/sugon/miniconda3/envs/py36/lib/python3.6/site-packages/torchvision/transforms/transforms.py:280: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead. "please use transforms.Resize instead.") Traceback (most recent call last): File "run_simba.py", line 173, in
testset = dset.ImageFolder(args.data_root + '/val', utils.IMAGENET_TRANSFORM)
File "/home/sugon/miniconda3/envs/py36/lib/python3.6/site-packages/torchvision/datasets/folder.py", line 229, in init
is_valid_file=is_valid_file)
File "/home/sugon/miniconda3/envs/py36/lib/python3.6/site-packages/torchvision/datasets/folder.py", line 108, in init
classes, class_to_idx = self._find_classes(self.root)
File "/home/sugon/miniconda3/envs/py36/lib/python3.6/site-packages/torchvision/datasets/folder.py", line 137, in _find_classes
classes = [d.name for d in os.scandir(dir) if d.is_dir()]
FileNotFoundError: [Errno 2] No such file or directory: 'cifar/val'