b09284f6ba59659a9819e68244a7a785016c87c5,art/attacks/evasion/shadow_attack.py,ShadowAttack,generate,#ShadowAttack#Any#Any#,119

Before Change


            )

        x = x.astype(ART_NUMPY_DTYPE)
        x_adv = np.zeros_like(x, dtype=ART_NUMPY_DTYPE)

        // Compute perturbation with implicit batching
        for i_batch in range(int(np.ceil(x.shape[0] / self.batch_size))):

After Change



        x_batch = x_batch + np.random.normal(scale=self.sigma, size=x_batch)

        y_batch = np.repeat(y, repeats=self.batch_size, axis=0)

        perturbation = (
            np.random.uniform(
                low=self.estimator.clip_values[0], high=self.estimator.clip_values[1], size=x.shape
            ).astype(ART_NUMPY_DTYPE)
            - (self.estimator.clip_values[1] - self.estimator.clip_values[0]) / 2
        )

        for _ in range(self.nb_steps):

            gradients_ce = np.mean(
                self.estimator.loss_gradient(x=x_batch + perturbation, y=y_batch, sampling=False)
                * (1 - 2 * int(self.targeted)),
                axis=0,
                keepdims=True,
            )

            gradients = gradients_ce - self._get_regularisation_loss_gradients(perturbation)

            perturbation += self.learning_rate * gradients

        x_p = x_batch + perturbation

        x_adv = np.clip(x_p, a_min=self.estimator.clip_values[0], a_max=self.estimator.clip_values[1]).astype(
            ART_NUMPY_DTYPE
        )

        return x_adv

    def _get_regularisation_loss_gradients(self, perturbation):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: b09284f6ba59659a9819e68244a7a785016c87c5
Time: 2020-05-24
Author: beat.buesser@ie.ibm.com
File Name: art/attacks/evasion/shadow_attack.py
Class Name: ShadowAttack
Method Name: generate


Project Name: dmlc/gluon-nlp
Commit Name: 1f9ad444b5dee8b2562b7bfa1cf9f576fa32a347
Time: 2020-07-31
Author: 37728728+ZheyuYe@users.noreply.github.com
File Name: src/gluonnlp/op.py
Class Name:
Method Name: updated_vectors_by_position


Project Name: NifTK/NiftyNet
Commit Name: ad66bf0a8faf1f230891faea92c31d8a3a0baa3f
Time: 2017-10-04
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/engine/sampler_selective.py
Class Name:
Method Name: candidate_indices