예제 #1
0
    def test_parse(self):
        def model():
            return True

        import tensorflow as tf
        sess = tf.Session()

        test_attack = Attack(model, back='tf', sess=sess)
        self.assertTrue(test_attack.parse_params({}))
예제 #2
0
    def test_inf_loop(self):
        def model(x):
            return x

        import theano.tensor as T
        x = T.tensor4('x')
        test_attack = Attack(model, back='th', sess=None)

        with self.assertRaises(Exception) as context:
            test_attack.generate(x)
        self.assertTrue(context.exception)
예제 #3
0
    def test_inf_loop(self):
        def model(x):
            return x

        import numpy as np
        x_val = np.zeros((10, 5, 5, 1))

        test_attack = Attack(model, back='th', sess=None)
        with self.assertRaises(Exception) as context:
            test_attack.generate_np(x_val)
        self.assertTrue(context.exception)
    def test_inf_loop(self):
        def model(x):
            return x

        import numpy as np
        import tensorflow as tf
        sess = tf.Session()
        x_val = np.zeros((10, 5, 5, 1))

        test_attack = Attack(model, back='tf', sess=sess)
        with self.assertRaises(Exception) as context:
            test_attack.generate_np(x_val)
        self.assertTrue(context.exception)
    def test_inf_loop(self):
        def model(x):
            return x

        import numpy as np
        import tensorflow as tf
        sess = tf.Session()
        x = tf.placeholder(tf.float32, shape=(1, ))

        test_attack = Attack(model, back='tf', sess=sess)
        adv_x = test_attack.generate(x)

        with self.assertRaises(Exception) as context:
            sess.run(adv_x, feed_dict={x: np.asarray(1.0).reshape((1, ))})
        self.assertTrue(context.exception)
예제 #6
0
    def test_back(self):
        model = Model()

        # Exception is thrown when back is not tf or th
        with self.assertRaises(Exception) as context:
            Attack(model, back='test', sess=None)
        self.assertTrue(context.exception)
예제 #7
0
    def test_sess(self):
        # Define empty model
        def model():
            return True

        # Test that it is permitted to provide no session
        Attack(model, back='tf', sess=None)
예제 #8
0
    def test_model(self):
        import theano.tensor as T

        # Exception is thrown when model does not have __call__ attribute
        with self.assertRaises(Exception) as context:
            model = T.matrix('y')
            Attack(model, back='th', sess=None)
        self.assertTrue(context.exception)
예제 #9
0
    def test_model(self):
        sess = tf.Session()

        # Exception is thrown when model does not have __call__ attribute
        with self.assertRaises(Exception) as context:
            model = tf.placeholder(tf.float32, shape=(None, 10))
            Attack(model, sess=sess)
        self.assertTrue(context.exception)
예제 #10
0
    def test_back(self):
        # Define empty model
        def model():
            return True

        # Exception is thrown when back is not tf or th
        with self.assertRaises(Exception) as context:
            Attack(model, back='test', sess=None)
        self.assertTrue(context.exception)
예제 #11
0
    def test_sess(self):
        # Define empty model
        def model():
            return True

        # Exception is thrown when session provided with TH
        with self.assertRaises(Exception) as context:
            Attack(model, back='th', sess=1)
        self.assertTrue(context.exception)
예제 #12
0
    def test_parse(self):
        sess = tf.Session()

        test_attack = Attack(Model('model', 10, {}), sess=sess)
        self.assertTrue(test_attack.parse_params({}))
예제 #13
0
 def test_sess(self):
     # Test that it is permitted to provide no session
     Attack(Model('model', 10, {}), back='tf', sess=None)
예제 #14
0
    def test_sess(self):
        # Define empty model
        model = Model()

        # Test that it is permitted to provide no session
        Attack(model, back='tf', sess=None)
예제 #15
0
    def test_parse(self):
        sess = tf.Session()

        test_attack = Attack(Model(), back='tf', sess=sess)
        self.assertTrue(test_attack.parse_params({}))
예제 #16
0
    def test_parse(self):
        def model():
            return True

        test_attack = Attack(model, back='th', sess=None)
        self.assertTrue(test_attack.parse_params({}))
예제 #17
0
 def test_sess(self):
     # Test that it is permitted to provide no session.
     # The session still needs to be created prior to running the attack.
     with tf.Session() as sess:
         Attack(Model('model', 10, {}), sess=None)
예제 #18
0
    def test_parse(self):
        sess = tf.Session()

        test_attack = Attack(Model('model', 10, {}), back='tf', sess=sess)
        self.assertTrue(test_attack.parse_params({}))