Skip to content

Commit

Permalink
test the output_layer argument passed to the callable model wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
npapernot authored and carlini committed Jul 12, 2017
1 parent 1df2e02 commit ac7b730
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests_tf/test_attacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from cleverhans.attacks import VirtualAdversarialMethod
from cleverhans.attacks import SaliencyMapMethod

from cleverhans.model import CallableModelWrapper


class TestAttackClassInitArguments(unittest.TestCase):
def test_model(self):
Expand Down Expand Up @@ -291,6 +293,19 @@ def test_generate_np_targeted_gives_adversarial_example(self):
worked = np.mean(np.argmax(feed_labs, axis=1) == new_labs)
self.assertTrue(worked > .9)

class TestCallableModelWrapperInitArguments(unittest.TestCase):
def test_output_layer(self):
def model():
return True

# The following two calls should not raise Exceptions
wrap = CallableModelWrapper(model, 'probs')
wrap = CallableModelWrapper(model, 'logits')

with self.assertRaises(Exception) as context:
wrap = CallableModelWrapper(model, 'dummy')
self.assertTrue(context.exception)


if __name__ == '__main__':
unittest.main()

0 comments on commit ac7b730

Please sign in to comment.