05425c36bd27b0611f0ea202aaf9d3c3934bda59,cleverhans/attacks.py,MomentumIterativeMethod,generate,#MomentumIterativeMethod#Any#,482

Before Change



            if self.ord == np.inf:
                normalized_grad = tf.sign(momentum)
            elif self.ord in [1, 2]:
                reduc_ind = list(xrange(1, len(momentum.get_shape())))
                if self.ord == 1:
                    norm = tf.reduce_sum(tf.abs(momentum),

After Change


            // Normalize current gradient and add it to the accumulated gradient
            red_ind = list(xrange(1, len(grad.get_shape())))
            avoid_zero_div = 1e-12
            grad = grad / tf.maximum(avoid_zero_div, 
                                     tf.reduce_mean(tf.abs(grad),
                                                    red_ind,
                                                    keep_dims=True))
            momentum = self.decay_factor * momentum + grad

            if self.ord == np.inf:
                normalized_grad = tf.sign(momentum)
            elif self.ord == 1:
                norm = tf.maximum(avoid_zero_div,
                                  tf.reduce_sum(tf.abs(momentum),
                                                red_ind,
                                                keep_dims=True))
                normalized_grad = momentum / norm
            elif self.ord == 2:
                square = tf.reduce_sum(tf.square(momentum),
                                       red_ind,
                                       keep_dims=True)
                norm = tf.sqrt(tf.maximum(avoid_zero_div, square))
                normalized_grad = momentum / norm
            else:
                raise NotImplementedError("Only L-inf, L1 and L2 norms are "
                                          "currently implemented.")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: tensorflow/cleverhans
Commit Name: 05425c36bd27b0611f0ea202aaf9d3c3934bda59
Time: 2017-12-23
Author: dongyinpeng@gmail.com
File Name: cleverhans/attacks.py
Class Name: MomentumIterativeMethod
Method Name: generate


Project Name: rail-berkeley/softlearning
Commit Name: 0cef3e36b3283534bc0395d167e4e2a63c5ff9e2
Time: 2018-07-25
Author: kristian.hartikainen@gmail.com
File Name: softlearning/environments/image_pusher.py
Class Name: ImageForkReacherEnv
Method Name: reset


Project Name: rail-berkeley/softlearning
Commit Name: 04ebc156705ce228991bc25cb6a6e5d5fdb10909
Time: 2018-07-24
Author: kristian.hartikainen@gmail.com
File Name: softlearning/environments/image_pusher.py
Class Name: ImageForkReacherEnv
Method Name: reset