5ee0f6c5fc31124eddffedddb7c2ce816dd329c8,hypergan/train_hooks/gradient_penalty_train_hook.py,GradientPenaltyTrainHook,__init__,#GradientPenaltyTrainHook#Any#Any#Any#Any#Any#Any#,19

Before Change



    gd = tf.gradients(target, target_vars)
    gds = [tf.square(tf.norm(_gd, ord=2)) for _gd in gd if _gd is not None]
    r = tf.add_n(gds)
    self.d_loss = self.d_lambda * tf.reduce_mean(r)
    self.gan.add_metric("gp", self.d_loss)

  def losses(self):

After Change


    if self.config.target:
        v = getattr(gan, self.config.target)
        target = v.sample
        if "components" in self.config:
            target_vars = []
            for component in self.config.components:
                c = getattr(gan, component)
                target_vars += c.variables()
        else:
            target_vars = v.variables()

    gd = tf.gradients(target, target_vars)
    gds = [tf.square(_gd) for _gd in gd if _gd is not None]
    self.loss = tf.add_n([self.d_lambda * tf.reduce_mean(_r) for _r in gds])
    self.gds = gds
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: HyperGAN/HyperGAN
Commit Name: 5ee0f6c5fc31124eddffedddb7c2ce816dd329c8
Time: 2019-02-26
Author: mikkel@255bits.com
File Name: hypergan/train_hooks/gradient_penalty_train_hook.py
Class Name: GradientPenaltyTrainHook
Method Name: __init__


Project Name: reinforceio/tensorforce
Commit Name: 0e6f7cea4abae753c8e496bbbe6465af6818ad92
Time: 2017-10-28
Author: aok25@cl.cam.ac.uk
File Name: tensorforce/models/distribution_model.py
Class Name: DistributionModel
Method Name: tf_regularization_losses


Project Name: reinforceio/tensorforce
Commit Name: 7deceb39597ea90e0f130448cf3616f0875b7f91
Time: 2017-10-28
Author: aok25@cl.cam.ac.uk
File Name: tensorforce/models/q_naf_model.py
Class Name: QNAFModel
Method Name: tf_regularization_losses