c7028b68792e65bcf820d0e7e24954dff586c921,foolbox/ext/native/attacks/newtonfool.py,NewtonFoolAttack,__call__,#NewtonFoolAttack#Any#Any#Any#,29

Before Change



            // (5) calculate & apply current perturbation
            x -= (
                atleast_kd(delta / gradients_l2_norm.square(), gradients.ndim)
                * gradients
            )
            x = ep.clip(x, min_, max_)

After Change


            // (1) get the scores and gradients
            _, (scores, pred_scores), gradients = ep.value_aux_and_grad(loss_fun, x)

            pred = scores.argmax(-1)
            num_classes = scores.shape[-1]

            // (2) calculate gradient norm
            gradients_l2_norm = flatten(gradients.square()).sum(1)

            // (3) calculate delta
            a = self.stepsize * x_l2_norm * gradients_l2_norm
            b = pred_scores - 1.0 / num_classes

            delta = ep.minimum(a, b)

            // (4) stop the attack if an adversarial example has been found
            // this is not described in the paper but otherwise once the prob. drops
            // below chance level the likelihood is not decreased but increased
            is_not_adversarial = (pred == classes).float32()
            delta *= is_not_adversarial

            // (5) calculate & apply current perturbation
            a = atleast_kd(delta / gradients_l2_norm.square(), gradients.ndim)
            x -= a * gradients

            x = ep.clip(x, min_, max_)

        return restore_type(x)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: bethgelab/foolbox
Commit Name: c7028b68792e65bcf820d0e7e24954dff586c921
Time: 2020-02-06
Author: 5895436+zimmerrol@users.noreply.github.com
File Name: foolbox/ext/native/attacks/newtonfool.py
Class Name: NewtonFoolAttack
Method Name: __call__


Project Name: bethgelab/foolbox
Commit Name: 914ed63ebb68c250490b7e2863ea9e9f2aba1c7a
Time: 2020-01-10
Author: git@jonasrauber.de
File Name: foolbox/ext/native/attacks/carlini_wagner.py
Class Name: L2CarliniWagnerAttack
Method Name: __call__


Project Name: bethgelab/foolbox
Commit Name: fa5137308a8eae6c24aca4f6c0146544d43581ed
Time: 2019-12-20
Author: git@jonasrauber.de
File Name: foolbox/ext/native/attacks/carlini_wagner.py
Class Name: L2CarliniWagnerAttack
Method Name: __call__