c7585e649aca88cf9e21eb754469630748bb1cfc,tests/attacks/test_knockoff_nets.py,TestKnockoffNets,test_pytorch_classifier,#TestKnockoffNets#,142

Before Change


        // Create random attack
        attack = KnockoffNets(classifier=victim_ptc, batch_size_fit=BATCH_SIZE, batch_size_query=BATCH_SIZE,
                              nb_epochs=NB_EPOCHS, nb_stolen=NB_STOLEN, sampling_strategy="random")
        self.x_train = np.swapaxes(self.x_train, 1, 3)
        thieved_ptc = attack.extract(x=self.x_train, thieved_classifier=thieved_ptc)

        victim_preds = np.argmax(victim_ptc.predict(x=self.x_train), axis=1)
        thieved_preds = np.argmax(thieved_ptc.predict(x=self.x_train), axis=1)
        acc = np.sum(victim_preds == thieved_preds) / len(victim_preds)

        self.assertGreater(acc, 0.3)

        // Create adaptive attack
        attack = KnockoffNets(classifier=victim_ptc, batch_size_fit=BATCH_SIZE, batch_size_query=BATCH_SIZE,
                              nb_epochs=NB_EPOCHS, nb_stolen=NB_STOLEN, sampling_strategy="adaptive", reward="all")
        thieved_ptc = attack.extract(x=self.x_train, y=self.y_train, thieved_classifier=thieved_ptc)

        victim_preds = np.argmax(victim_ptc.predict(x=self.x_train), axis=1)
        thieved_preds = np.argmax(thieved_ptc.predict(x=self.x_train), axis=1)
        acc = np.sum(victim_preds == thieved_preds) / len(victim_preds)

        self.assertGreater(acc, 0.4)
        self.x_train = np.swapaxes(self.x_train, 1, 3)


class TestKnockoffNetsVectors(unittest.TestCase):
    @classmethod

After Change



        self.assertGreater(acc, 0.4)

        self.x_train_mnist = np.reshape(self.x_train_mnist, (self.x_train_mnist.shape[0], 28, 28, 1)).astype(np.float32)


class TestKnockoffNetsVectors(TestBase):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: c7585e649aca88cf9e21eb754469630748bb1cfc
Time: 2020-01-27
Author: beat.buesser@ie.ibm.com
File Name: tests/attacks/test_knockoff_nets.py
Class Name: TestKnockoffNets
Method Name: test_pytorch_classifier


Project Name: arviz-devs/arviz
Commit Name: f7e16c6997c76bd77c06ea0284a784e2ef029a5c
Time: 2018-08-27
Author: ari.hartikainen@aalto.fi
File Name: arviz/utils/xarray_utils.py
Class Name: PyStanToNetCDF
Method Name: default_varnames_coords_dims


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 9e35d1e5ebdf1c379b6c84c642fa164a9fa22d9a
Time: 2020-01-16
Author: beat.buesser@ie.ibm.com
File Name: tests/attacks/test_copycat_cnn.py
Class Name: TestCopycatCNN
Method Name: test_pytorch_classifier