4f5fad71c841a392237bf0c31c0175378e907c3b,art/attacks/carlini_unittest.py,TestCarliniL2,test_krclassifier,#TestCarliniL2#,177

Before Change


        self.assertTrue((x_test_adv >= -0.0001).all())
        target = np.argmax(params["y"], axis=1)
        y_pred_adv = np.argmax(krc.predict(x_test_adv), axis=1)
        logger.info("CW2 Target: %s", target)
        logger.info("CW2 Actual: %s", y_pred_adv)
        logger.info("CW2 Success Rate: %f", sum(target == y_pred_adv)/float(len(target)))
        self.assertTrue((target == y_pred_adv).any())

        // Second attack
        cl2m = CarliniL2Method(classifier=krc, targeted=False, max_iter=10, binary_search_steps=10,
                               learning_rate=2e-2, initial_const=3, decay=1e-2)
        params = {"y": random_targets(y_test, krc.nb_classes)}
        x_test_adv = cl2m.generate(x_test, **params)
        self.assertFalse((x_test == x_test_adv).all())
        self.assertTrue((x_test_adv <= 1.0001).all())
        self.assertTrue((x_test_adv >= -0.0001).all())
        target = np.argmax(params["y"], axis=1)
        y_pred_adv = np.argmax(krc.predict(x_test_adv), axis=1)
        logger.info("CW2 Target: %s", target)
        logger.info("CW2 Actual: %s", y_pred_adv)
        logger.info("CW2 Success Rate: %f", sum(target != y_pred_adv)/float(len(target)))
        self.assertTrue((target != y_pred_adv).all())

        // Third attack
        cl2m = CarliniL2Method(classifier=krc, targeted=False, max_iter=10, binary_search_steps=10,
                               learning_rate=2e-2, initial_const=3, decay=1e-2)
        params = {}
        x_test_adv = cl2m.generate(x_test, **params)
        self.assertFalse((x_test == x_test_adv).all())
        self.assertTrue((x_test_adv <= 1.0001).all())
        self.assertTrue((x_test_adv >= -0.0001).all())
        y_pred = np.argmax(krc.predict(x_test), axis=1)
        y_pred_adv = np.argmax(krc.predict(x_test_adv), axis=1)
        logger.info("CW2 Target: %s", y_pred)
        logger.info("CW2 Actual: %s", y_pred_adv)
        logger.info("CW2 Success Rate: %f", sum(y_pred != y_pred_adv)/float(len(y_pred)))
        self.assertTrue((y_pred != y_pred_adv).any())

    def test_ptclassifier(self):
        

After Change


        self.assertTrue((x_test_adv >= -0.0001).all())
        target = np.argmax(params["y"], axis=1)
        y_pred_adv = np.argmax(krc.predict(x_test_adv), axis=1)
        print("CW2 Target: %s" % target)
        print("CW2 Actual: %s" % y_pred_adv)
        print("CW2 Success Rate: %f" % (sum(target == y_pred_adv)/float(len(target))))
        self.assertTrue((target == y_pred_adv).any())
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 12

Instances


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 4f5fad71c841a392237bf0c31c0175378e907c3b
Time: 2018-07-26
Author: molloyim@us.ibm.com
File Name: art/attacks/carlini_unittest.py
Class Name: TestCarliniL2
Method Name: test_krclassifier


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 4f5fad71c841a392237bf0c31c0175378e907c3b
Time: 2018-07-26
Author: molloyim@us.ibm.com
File Name: art/attacks/carlini_unittest.py
Class Name: TestCarliniL2
Method Name: test_tfclassifier


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 4f5fad71c841a392237bf0c31c0175378e907c3b
Time: 2018-07-26
Author: molloyim@us.ibm.com
File Name: art/attacks/carlini_unittest.py
Class Name: TestCarliniL2
Method Name: test_ptclassifier


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 4f5fad71c841a392237bf0c31c0175378e907c3b
Time: 2018-07-26
Author: molloyim@us.ibm.com
File Name: art/attacks/carlini_unittest.py
Class Name: TestCarliniL2
Method Name: test_krclassifier