e09f411ffe0feee5034f73581054cb2c52e24e1d,art/classifiers/scikitklearn.py,ScikitlearnLogisticRegression,class_gradient,#ScikitlearnLogisticRegression#Any#Any#,368

Before Change



        num_samples, _ = x.shape
        gradients = np.zeros(x.shape)
        class_weight = compute_class_weight(class_weight=self.model_class_weight, classes=self.classes,
                                            y=np.argmax(label, axis=1))

        y_pred = self.model.predict_proba(X=x_preprocessed)

        w_weighted = np.matmul(y_pred, self.weights)

After Change


            raise ValueError(Model has not been fitted. Run function `fit(x, y)` of classifier first or provide a
            fitted model.)

        nb_samples = x.shape[0]

        if label is None:
            // Compute the gradients w.r.t all classses
            label = np.ones(shape=(nb_samples, self.nb_classes))
        elif isinstance(label, (int, np.integer)):
            // Compute the gradients only w.r.t. the provided label
            label = [label] * nb_samples
            label = to_categorical(labels=label, nb_classes=self.nb_classes)
        elif (isinstance(label, list) and len(label) == nb_samples) or isinstance(label,
             np.ndarray) and label.shape == (nb_samples,):
            // For each sample, compute the gradients w.r.t. the indicated target class (possibly distinct)
            label = to_categorical(labels=label, nb_classes=self.nb_classes)
        else:
            raise TypeError("Unrecognized type for argument `label` with type " + str(type(label)))

        // Apply preprocessing
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: e09f411ffe0feee5034f73581054cb2c52e24e1d
Time: 2019-07-18
Author: beat.buesser@ie.ibm.com
File Name: art/classifiers/scikitklearn.py
Class Name: ScikitlearnLogisticRegression
Method Name: class_gradient


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 7baa06c0a69e4e5d62483dd46690ac911b54c475
Time: 2018-08-24
Author: BJEdwards@gmail.com
File Name: art/attacks/iterative_method_unittest.py
Class Name: TestIterativeAttack
Method Name: _test_mnist_targeted


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 7baa06c0a69e4e5d62483dd46690ac911b54c475
Time: 2018-08-24
Author: BJEdwards@gmail.com
File Name: art/attacks/fast_gradient_unittest.py
Class Name: TestFastGradientMethod
Method Name: _test_mnist_targeted