Trustworthy-AI-Group / TransferAttack

TransferAttack is a pytorch framework to boost the adversarial transferability for image classification.
MIT License
268 stars 41 forks source link

BPA error #79

Closed jiamingzhang94 closed 3 months ago

jiamingzhang94 commented 3 months ago

Thanks for your sharing! an amazing work!

I found an error for running BPA when python main.py --attack=bpa --model resnet50:

Traceback (most recent call last): File "/home/baseline.py", line 181, in <module> main() File "/home/baseline.py", line 105, in main perturbations = attacker(images, labels) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/transferattack/attack.py", line 169, in __call__ return self.forward(*input, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/transferattack/model_related/bpa.py", line 57, in forward logits = bpa_forw_resnet(self.model, data+delta, self.bpa_layer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/transferattack/model_related/bpa.py", line 148, in bpa_forw_resnet x = layer_forw(jj, kk, 1, ind, x, mm) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/transferattack/model_related/bpa.py", line 144, in layer_forw x = block_func(mm, x, do_bpa=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/transferattack/model_related/bpa.py", line 177, in block_func out += identity RuntimeError: The size of tensor a (64) must match the size of tensor b (256) at non-singleton dimension 1

xiaosen-wang commented 3 months ago

We have fixed this error. You can try it again. Thanks.