9b825ea2437603451cbbdfe07596b820f4523f36,src/metrics_unittest.py,TestMinimalPerturbations,test_mnist,#TestMinimalPerturbations#,45
Before Change
// get classifier
im_shape = X_train[0].shape
model = cnn.cnn_model(im_shape, act="relu")
model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])
// Fit the model
model.fit(X_train, Y_train, epochs=1, batch_size=BATCH_SIZE)
After Change
session = tf.Session()
K.set_session(session)
comp_params = {"loss": "categorical_crossentropy",
"optimizer": "adam",
"metrics": ["accuracy"]}
// get MNIST
(X_train, Y_train), (_, _) = load_mnist()
X_train, Y_train = X_train[:NB_TRAIN], Y_train[:NB_TRAIN]
// get classifier
im_shape = X_train[0].shape
classifier = CNN(im_shape, act="relu")
classifier.compile(comp_params)
// Fit the classifier
classifier.fit(X_train, Y_train, epochs=1, batch_size=BATCH_SIZE)
// Compute minimal perturbations
params = {"eps_step":1.1,
"clip_min":0.,
"clip_max":1.}
emp_robust = empirical_robustness(X_train, classifier.model, session, "fgsm", params)
self.assertEqual(emp_robust, 0.)
params = {"eps_step": 1.,
"eps_max": 1.,
"clip_min": None,
"clip_max": None}
emp_robust = empirical_robustness(X_train, classifier.model, session, "fgsm", params)
self.assertAlmostEqual(emp_robust*LA.norm(X_train), 1., emp_robust**LA.norm(X_train))
// params = {"theta": 1.,
In pattern: SUPERPATTERN
Frequency: 5
Non-data size: 6
Instances
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 9b825ea2437603451cbbdfe07596b820f4523f36
Time: 2017-06-14
Author: valentina.zantedeschi@ibm.com
File Name: src/metrics_unittest.py
Class Name: TestMinimalPerturbations
Method Name: test_mnist
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 9b825ea2437603451cbbdfe07596b820f4523f36
Time: 2017-06-14
Author: valentina.zantedeschi@ibm.com
File Name: src/metrics_unittest.py
Class Name: TestMinimalPerturbations
Method Name: test_mnist
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: ea7431d469f23f190330c01a280e1702f3319479
Time: 2017-06-14
Author: valentina.zantedeschi@ibm.com
File Name: src/attackers/fast_gradient_unittest.py
Class Name: TestFastGradientMethod
Method Name: test_mnist
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: ea7431d469f23f190330c01a280e1702f3319479
Time: 2017-06-14
Author: valentina.zantedeschi@ibm.com
File Name: src/attackers/deepfool_unittest.py
Class Name: TestDeepFool
Method Name: test_mnist
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: ea7431d469f23f190330c01a280e1702f3319479
Time: 2017-06-14
Author: valentina.zantedeschi@ibm.com
File Name: src/attackers/universal_perturbation_unittest.py
Class Name: TestUniversalPerturbation
Method Name: test_mnist
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: ea7431d469f23f190330c01a280e1702f3319479
Time: 2017-06-14
Author: valentina.zantedeschi@ibm.com
File Name: src/attackers/saliency_map_unittest.py
Class Name: TestSaliencyMap
Method Name: test_mnist