forked from goodfeli/cleverhans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes cleverhans-lab#744 (PGD wrapper issue)
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Tests for the ProjectGradientDescent attack | ||
""" | ||
|
||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
from nose.tools import assert_raises | ||
import tensorflow as tf | ||
|
||
from cleverhans.attacks import ProjectedGradientDescent | ||
|
||
def test_callable_no_softmax(): | ||
batch_size = 2 | ||
nb_classes = 3 | ||
def model(x): | ||
return tf.ones((batch_size, nb_classes)) / nb_classes | ||
sess = tf.Session() | ||
attack = ProjectedGradientDescent(model, sess=sess) | ||
x = tf.ones((batch_size, 3)) | ||
# Currently ProjectedGradientDescent treats the output of a callable | ||
# as probs rather than logits. | ||
# Since our callable does not use a softmax, it is impossible to get | ||
# the logits back. The test confirms that this causes an error. | ||
assert_raises(TypeError, attack.generate, x) | ||
|
||
if __name__ == "__main__": | ||
test_callable() |