HopSkipJumpAttack constraint is set to "linf" but is equal "l2"
- Dominant language
- Python
- Stars
- 3k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I test HopSkipJumpAttack with the following function:
```
def eval(model, attack="fgsm"):
fmodel = foolbox.models.PyTorchModel( model, bounds = get_dataset_min_max_val ("mnist_adversarial"), num_classes=10)
images, labels = foolbox.utils.samples(dataset='mnist', batchsize=1, data_format='channels_first',
bounds=(0, 1))
attack = foolbox.attacks.HopSkipJumpAttack(fmodel, distance=foolbox.distances.Linf)
adversarials = attack(images, labels, iterations=2)
print(np.mean(fmodel.forward(adversarials).argmax(axis=-1) == labels))
```
I see that although I configured distance=foolbox.distances.Linf, the self.constraint attribute in HopSkipJumpAttack.attack method always equal "l2".
I suspect that the problem occurs because in batching.py line 243:
```
attacks = [
create_attack_fn().as_generator(adv, **kwargs)
for adv, kwargs in zip(advs, individual_kwargs)
]
```
create_attack_fn which equals HopSkipJumpAttack class don't get any parameters telling it to use distance=Linf.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.