(discriminator)
Returns the L2 penalty for each matrix/vector excluding biases.

  Assumes a specific tensor naming followed throughout the compare_gan library.
  We penalize all fully connected, conv2d, and deconv2d layers.

  Args:
    discriminator: Instance of `AbstractDiscriminator`.

  Returns:
     A tensor with the computed penalty.
Returns the L2 penalty for each matrix/vector excluding biases.
Returns the L2 penalty for each matrix / vector excluding biases .
def l2_penalty(discriminator):
  """Returns the L2 penalty for each matrix/vector excluding biases.

  Assumes a specific tensor naming followed throughout the compare_gan library.
  We penalize all fully connected, conv2d, and deconv2d layers.

  Args:
    discriminator: Instance of `AbstractDiscriminator`.

  Returns:
     A tensor with the computed penalty.
  """
  with tf.name_scope("l2_penalty"):
    d_weights = [v for v in discriminator.trainable_variables
                 if v.name.endswith("/kernel:0")]
    return tf.reduce_mean(
        [tf.nn.l2_loss(i) for i in d_weights], name="l2_penalty")
def l2_penalty ( discriminator ) : with tf . name_scope ( "l2_penalty" ) : d_weights = [ v for v in discriminator . trainable_variables if v . name . endswith ( "/kernel:0" ) ] return tf . reduce_mean ( [ tf . nn . l2_loss ( i ) for i in d_weights ] , name = "l2_penalty" )