<commit_before>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
import unittest
import tensorflow as tf
import tensorflow.contrib.slim as slim

from cleverhans import attacks_tf

class TestAttacksTF(unittest.TestCase):
    def test_jsma_batch_with_feed(self):
        with tf.Session() as sess:
            X = np.random.rand(1, 13)

            # construct a simple graph that will require extra placeholders
            x = tf.placeholder('float', shape=(None, 13))
            b = tf.placeholder('bool')
            logits = slim.dropout(slim.fully_connected(x, 10),
                                  is_training=b)

            sess.run(tf.global_variables_initializer())
            
            # jsma should work without generating an error
            jacobian = attacks_tf.jacobian_graph(logits, x, 10)
            attacks_tf.jsma_batch(sess, x, logits, jacobian, X, theta=1.,
                                  gamma=0.25, clip_min=0, clip_max=1,
                                  nb_classes=10, feed={b: False})

if __name__ == '__main__':
    unittest.main()<commit_msg>remove testing dependency on slim<commit_after>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
import unittest
import tensorflow as tf

from cleverhans import attacks_tf

class TestAttacksTF(unittest.TestCase):
    def test_jsma_batch_with_feed(self):
        with tf.Session() as sess:
            X = np.random.rand(1, 13)

            # construct a simple graph that will require extra placeholders
            x = tf.placeholder('float', shape=(None, 13))
            keep_prob = tf.placeholder('float')
            W = tf.Variable(tf.random_normal([13, 10]))
            b = tf.Variable(tf.random_normal([10]))
            logits = tf.nn.dropout(tf.add(tf.matmul(x, W), b),
                                   keep_prob=keep_prob)
            sess.run(tf.global_variables_initializer())

            # jsma should work without generating an error
            jacobian = attacks_tf.jacobian_graph(logits, x, 10)
            attacks_tf.jsma_batch(sess, x, logits, jacobian, X, theta=1.,
                                  gamma=0.25, clip_min=0, clip_max=1,
                                  nb_classes=10, feed={keep_prob: 1.0})

if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.0852, 'fraction_numerical': 0.016, 'mean_word_length': 2.343582887700535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5188420', 'n_tokens_mistral': 763, 'n_tokens_neox': 717, 'n_words': 189}