f7715f63c17832f66e54164cc0ae3cb0e4afc4a3,cleverhans/attacks.py,Attack,generate_np,#Attack#Any#,64

Before Change



        hash_key = tuple(sorted(fixed.items()))

        if not all(isinstance(value, collections.Hashable) for value in feedable.values()):
            //TODO this is bad
            raise

        // try our very best to create a TF placeholder for each of the
        // feedable keyword arguments by inferring the type

        num_types = [int, float, np.float16, np.float32, np.float64,
                     np.int8, np.int16, np.int32, np.int32, np.int64, 
                     np.uint8, np.uint16, np.uint32, np.uint64,
                     tf.float16, tf.float32, tf.float64,
                     tf.int8, tf.int16, tf.int32, tf.int32, tf.int64, 
                     tf.uint8, tf.uint16]

        new_kwargs = dict(x for x in fixed.items())
        for name, value in feedable.items():
            if isinstance(value, np.ndarray):
                new_shape = [None]+list(value.shape[1:])
                new_kwargs[name] = tf.placeholder(value.dtype, new_shape)
            if any(isinstance(value, num) for num in num_types):
                if isinstance(value, float):
                    new_kwargs[name] = tf.placeholder(tf.float32, shape=[])
                elif isinstance(value, int):

After Change


                // only save the graph if every fixed element is hashable
                self.graphs[hash_key] = (x, new_kwargs, x_adv)

            if len(self.graphs) == 10:
                warnings.warn("Calling generate_np() with multiple different "
                              "structural paramaters is inefficient and should "
                              "be avoided. Calling generate() is preferred.")

        if hash_key is not None:
            // if it is None, we must have constructed it already
            x, new_kwargs, x_adv = self.graphs[hash_key]
            
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: tensorflow/cleverhans
Commit Name: f7715f63c17832f66e54164cc0ae3cb0e4afc4a3
Time: 2017-07-09
Author: nicholas@carlini.com
File Name: cleverhans/attacks.py
Class Name: Attack
Method Name: generate_np


Project Name: Qiskit/qiskit-aqua
Commit Name: 2aae12b10a3411009a2802a077bb8c6c0365b6ad
Time: 2020-08-28
Author: 31178928+t-imamichi@users.noreply.github.com
File Name: qiskit/aqua/operators/converters/abelian_grouper.py
Class Name: AbelianGrouper
Method Name: group_subops


Project Name: rtqichen/torchdiffeq
Commit Name: 47ba6dedb917847460b098c5f2b776a4c8bd0c1b
Time: 2021-01-05
Author: rtqichen@gmail.com
File Name: torchdiffeq/_impl/adjoint.py
Class Name:
Method Name: odeint_adjoint