advboxes / AdvBox

Advbox is a toolbox to generate adversarial examples that fool neural networks in PaddlePaddle、PyTorch、Caffe2、MxNet、Keras、TensorFlow and Advbox can benchmark the robustness of machine learning models. Advbox give a command line tool to generate adversarial examples with Zero-Coding.
Apache License 2.0
1.39k stars 265 forks source link

imagenet_tutorial_fgsm_pytorch.py报错 #15

Closed weitianli closed 5 years ago

weitianli commented 5 years ago

imagenet_tutorial_fgsm_pytorch.py[line:52] INFO CUDA Available: True cuda pytorch.py[line:63] INFO Finish PytorchModel init (1, 3, 224, 224) Traceback (most recent call last): File "imagenet_tutorial_fgsm_pytorch.py", line 132, in <module> main("cropped_panda.jpg") File "imagenet_tutorial_fgsm_pytorch.py", line 108, in main adversary = attack(adversary, **attack_config) File "../advbox/attacks/base.py", line 47, in __call__ self._preprocess(adversary) File "../advbox/attacks/base.py", line 72, in _preprocess self.model.predict(adversary.original)) File "../advbox/models/pytorch.py", line 86, in predict predict = np.squeeze(predict, axis=0) File "/home/.../anaconda3/envs/bdbox/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 1292, in squeeze return squeeze(axis=axis) TypeError: squeeze() missing 1 required positional arguments: "dim" 按照官方的实例运行,环境也是按照requirement安装的,出现了这个squeeze()的问题。

duoergun0729 commented 5 years ago

你贴下你numpy的版本 看着是np的问题

weitianli commented 5 years ago

1.15.4

duoergun0729 commented 5 years ago

你看下我的requrement 不是这个版本 pip install numpy==1.14.5试试把

weitianli commented 5 years ago

解决了,谢谢你。