46b700a1b63488408121f1edf9df3df01d345a17,art/classifiers/detector_classifier.py,DetectorClassifier,loss_gradient,#DetectorClassifier#Any#Any#,132

Before Change


        import torch

        // Convert the inputs to Tensors
        inputs_t = torch.from_numpy(self._apply_processing(x)).to(self._device)
        inputs_t = inputs_t.float()
        inputs_t.requires_grad = True

        // Convert the labels to Tensors
        labels_t = torch.from_numpy(np.argmax(y, axis=1)).to(self._device)

        // Compute the gradient and return
        model_outputs = self._model(inputs_t)
        loss = self._loss(model_outputs[-1], labels_t)

        // Clean gradients
        self._model.zero_grad()
        // inputs_t.grad.data.zero_()

        // Compute gradients
        loss.backward()
        grds = inputs_t.grad.cpu().numpy().copy()
        grds = self._apply_processing_gradient(grds)
        assert grds.shape == x.shape

        return grds

    @property
    def layer_names(self):
        

After Change


        :return: Array of gradients of the same shape as `x`.
        :rtype: `np.ndarray`
        
        raise NotImplementedError

    def get_activations(self, x, layer, batch_size=128):
        
        Return the output of the specified layer for input `x`. `layer` is specified by layer index (between 0 and
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 46b700a1b63488408121f1edf9df3df01d345a17
Time: 2019-02-21
Author: M.N.Tran@ibm.com
File Name: art/classifiers/detector_classifier.py
Class Name: DetectorClassifier
Method Name: loss_gradient


Project Name: geomstats/geomstats
Commit Name: 9d6281d3b2f472e5e130dbf88078c433d0795f46
Time: 2020-04-24
Author: ninamio78@gmail.com
File Name: geomstats/_backend/pytorch/__init__.py
Class Name:
Method Name: all


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 705d7ff759a0b76ddf1b30ab8ef135c0b67efa8b
Time: 2020-04-23
Author: M.N.Tran@ibm.com
File Name: art/attacks/evasion/projected_gradient_descent/projected_gradient_descent_pytorch.py
Class Name: ProjectedGradientDescentPytorch
Method Name: generate