Skip to content

Commit e39663e

Browse files
author
Beat Buesser
committed
Update tests for removed feature
Signed-off-by: Beat Buesser <[email protected]>
1 parent 6cebc5b commit e39663e

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

tests/attacks/test_input_filter.py

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@
1818
from __future__ import absolute_import, division, print_function, unicode_literals
1919

2020
import logging
21-
# import unittest
21+
22+
import unittest
23+
2224
# import numpy as np
23-
# import pandas as pd
24-
#
25+
import pandas as pd
26+
2527
# from art.attacks.evasion.projected_gradient_descent.projected_gradient_descent import ProjectedGradientDescent
2628
# from art.estimators.classification.keras import KerasClassifier
2729
# from art.estimators.estimator import BaseEstimator, LossGradientsMixin
28-
# from art.utils import load_dataset, get_labels_np_array
29-
#
30-
# from tests.utils import get_image_classifier_tf, get_image_classifier_pt
30+
from art.utils import load_dataset # , get_labels_np_array
31+
32+
# from tests.utils import get_image_classifier_tf, get_image_classifier_pt, get_tabular_classifier_pt
3133
# from tests.utils import get_tabular_classifier_tf, get_tabular_classifier_kr
32-
# from tests.utils import get_tabular_classifier_pt, master_seed
34+
from tests.utils import master_seed
35+
3336
# from tests.attacks.utils import backend_test_classifier_type_check_fail
3437

3538
logger = logging.getLogger(__name__)
@@ -39,34 +42,37 @@
3942
NB_TEST = 11
4043

4144

42-
# class TestInputFilter(unittest.TestCase):
43-
# """
44-
# A unittest class for testing the input filtering using
45-
# PGD tests.
46-
# """
47-
#
48-
# @classmethod
49-
# def setUpClass(cls):
50-
# # MNIST
51-
# (x_train, y_train), (x_test, y_test), _, _ = load_dataset("mnist")
52-
# x_train = list(x_train[:NB_TRAIN])
53-
# y_train = list(y_train[:NB_TRAIN])
54-
# x_test = list(x_test[:NB_TEST])
55-
# y_test = list(y_test[:NB_TEST])
56-
# cls.mnist = (x_train, y_train), (x_test, y_test)
57-
#
58-
# # Iris
59-
# (x_train, y_train), (x_test, y_test), _, _ = load_dataset("iris")
60-
# x_train = pd.DataFrame(x_train)
61-
# y_train = pd.DataFrame(y_train)
62-
# x_test = pd.DataFrame(x_test)
63-
# y_test = pd.DataFrame(y_test)
64-
# cls.iris = (x_train, y_train), (x_test, y_test)
65-
#
66-
# def setUp(self):
67-
# master_seed(1234)
68-
#
69-
# def test_2_tensorflow_mnist(self):
45+
class TestInputFilter(unittest.TestCase):
46+
"""
47+
A unittest class for testing the input filtering using
48+
PGD tests.
49+
"""
50+
51+
@classmethod
52+
def setUpClass(cls):
53+
# MNIST
54+
(x_train, y_train), (x_test, y_test), _, _ = load_dataset("mnist")
55+
x_train = list(x_train[:NB_TRAIN])
56+
y_train = list(y_train[:NB_TRAIN])
57+
x_test = list(x_test[:NB_TEST])
58+
y_test = list(y_test[:NB_TEST])
59+
cls.mnist = (x_train, y_train), (x_test, y_test)
60+
61+
# Iris
62+
(x_train, y_train), (x_test, y_test), _, _ = load_dataset("iris")
63+
x_train = pd.DataFrame(x_train)
64+
y_train = pd.DataFrame(y_train)
65+
x_test = pd.DataFrame(x_test)
66+
y_test = pd.DataFrame(y_test)
67+
cls.iris = (x_train, y_train), (x_test, y_test)
68+
69+
def setUp(self):
70+
master_seed(1234)
71+
72+
def test_2_tensorflow_mnist(self):
73+
pass
74+
75+
7076
# (x_train, y_train), (x_test, y_test) = self.mnist
7177
# classifier, sess = get_image_classifier_tf()
7278
#
@@ -140,7 +146,8 @@
140146
# logger.info("Accuracy on adversarial test examples with 3 random initialisations: %.2f%%", acc * 100)
141147
#
142148
# # Check that x_test has not been modified by attack and classifier
143-
# self.assertAlmostEqual(float(np.max(np.abs(np.array(x_test_original) - np.array(x_test)))), 0.0, delta=0.00001)
149+
# self.assertAlmostEqual(float(np.max(np.abs(np.array(x_test_original) - np.array(x_test)))), 0.0,
150+
# delta=0.00001)
144151
#
145152
# def test_1_classifier_type_check_fail(self):
146153
# backend_test_classifier_type_check_fail(ProjectedGradientDescent, [BaseEstimator, LossGradientsMixin])

0 commit comments

Comments
 (0)