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: 7

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: castorini/honk
Commit Name: f411e5792861d96fc46b938aed98e55d6f263459
Time: 2017-10-17
Author: r33tang@uwaterloo.ca
File Name: service.py
Class Name: LabelService
Method Name: label


Project Name: arraiy/torchgeometry
Commit Name: e06eee5deec11dc03d6c4975eb9a57f2bc6edd30
Time: 2019-05-28
Author: jiangwei1993@gmail.com
File Name: kornia/utils/image.py
Class Name:
Method Name: tensor_to_image