32a9e66e0e45b1a6119fcb0e1ed5f74c0d5dab15,art/attacks/evasion/universal_simba_dct.py,Universal_SimBA_dct,generate,#Universal_SimBA_dct#Any#Any#,75

Before Change


        last_probs = preds[(range(nb_instances),original_labels)]

        n_dims = np.prod(x[0].shape)
        if self.max_iter > n_dims:
            self.max_iter = n_dims
            logger.info("`max_iter` was reset to %d because it needs to be //pixels x //channels or less", n_dims)

        indices = self._block_order(x.shape[2], 3, initial_size=self.freq_dim, stride=self.stride)[:self.max_iter]
        trans = lambda z: self._block_idct(z, block_size=x.shape[2])

        clip_min = -np.inf

After Change


        params = {"max_iter": max_iter, "epsilon": epsilon, "freq_dim": freq_dim, "stride": stride, "delta": delta, "eps": eps, "norm": norm, "batch_size": batch_size}
        self.set_params(**params)

    def generate(self, x, y=None, **kwargs):
        
        Generate adversarial samples and return them in an array.

        :param x: An array with the original inputs to be attacked.
        :type x: `np.ndarray`
        :param y: An array with the original labels to be predicted.
        :type y: `np.ndarray`
        :return: An array holding the adversarial examples.
        :rtype: `np.ndarray`
        
        x = x.astype(ART_NUMPY_DTYPE)
        nb_instances = x.shape[0]
        preds = self.classifier.predict(x, batch_size=self.batch_size)
        if y is None:
            y = np.argmax(preds, axis=1)
        original_labels = y
        current_labels = original_labels
        last_probs = preds[(range(nb_instances),original_labels)]

        n_dims = np.prod(x[0].shape)

        indices = self._block_order(x.shape[2], 3, initial_size=self.freq_dim, stride=self.stride)[:self.max_iter]
        indices_size = len(indices)
        while indices_size < self.max_iter:
            tmp_indices = self._block_order(x.shape[2], 3, initial_size=self.freq_dim, stride=self.stride)
            indices = np.hstack((indices, tmp_indices))[:self.max_iter]
            indices_size = len(indices)
        
        trans = lambda z: self._block_idct(z, block_size=x.shape[2])

        clip_min = -np.inf
        clip_max = np.inf 
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 17

Instances


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 32a9e66e0e45b1a6119fcb0e1ed5f74c0d5dab15
Time: 2020-05-28
Author: kz.takemoto@gmail.com
File Name: art/attacks/evasion/universal_simba_dct.py
Class Name: Universal_SimBA_dct
Method Name: generate


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 32a9e66e0e45b1a6119fcb0e1ed5f74c0d5dab15
Time: 2020-05-28
Author: kz.takemoto@gmail.com
File Name: art/attacks/evasion/universal_simba_pixel.py
Class Name: Universal_SimBA_pixel
Method Name: generate


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 32a9e66e0e45b1a6119fcb0e1ed5f74c0d5dab15
Time: 2020-05-28
Author: kz.takemoto@gmail.com
File Name: art/attacks/evasion/simba_dct.py
Class Name: SimBA_dct
Method Name: generate


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 32a9e66e0e45b1a6119fcb0e1ed5f74c0d5dab15
Time: 2020-05-28
Author: kz.takemoto@gmail.com
File Name: art/attacks/evasion/simba_pixel.py
Class Name: SimBA_pixel
Method Name: generate