BorealisAI / advertorch

A Toolbox for Adversarial Robustness Research
GNU Lesser General Public License v3.0
1.29k stars 195 forks source link

Incorrect arguments for BasicIterativeAttack's superclass constructor #66

Closed samuelemarro closed 4 years ago

samuelemarro commented 4 years ago

BasicIterativeAttack's constructor calls PGDAttack using positional arguments. For example, the L2 variant looks like this:

super(L2BasicIterativeAttack, self).__init__(
            predict, loss_fn, eps, nb_iter, eps_iter, rand_init,
            clip_min, clip_max, ord, targeted)

However, PGDAttack's constructor looks like this:

def __init__(
            self, predict, loss_fn=None, eps=0.3, nb_iter=40,
            eps_iter=0.01, rand_init=True, clip_min=0., clip_max=1.,
            ord=np.inf, l1_sparsity=None, targeted=False):

Notice l1_sparsity=None between ord and targeted. This means that the value of targeted is assigned to PGDAttack.l1_sparsity instead of PGDAttack.targeted, while PGDAttack.targeted will always be the default value (False).

gwding commented 4 years ago

@samuelemarro Thanks for pointing this out! Do you want to submit a pull request fixing this?

samuelemarro commented 4 years ago

Done! See #67 .

gwding commented 4 years ago

Merged