(gan_model, **kwargs)
return gan_loss._replace(
      discriminator_loss=(
          gan_loss.discriminator_loss +
          kwargs['real_score_penalty_weight'] * real_score_penalty))
Defines progressive GAN losses.

  The generator and discriminator both use wasserstein loss. In addition,
  a small penalty term is added to the discriminator loss to prevent it getting
  too large.

  Args:
    gan_model: A `GANModel` namedtuple.
    **kwargs: A dictionary of
        'gradient_penalty_weight': A float of gradient norm target for
            wasserstein loss.
        'gradient_penalty_target': A float of gradient penalty weight for
            wasserstein loss.
        'real_score_penalty_weight': A float of Additional penalty to keep
            the scores from drifting too far from zero.

  Returns:
    A `GANLoss` namedtuple.
Defines progressive GAN losses.
Defines progressive GAN losses .
def define_loss(gan_model, **kwargs):
  """Defines progressive GAN losses.

  The generator and discriminator both use wasserstein loss. In addition,
  a small penalty term is added to the discriminator loss to prevent it getting
  too large.

  Args:
    gan_model: A `GANModel` namedtuple.
    **kwargs: A dictionary of
        'gradient_penalty_weight': A float of gradient norm target for
            wasserstein loss.
        'gradient_penalty_target': A float of gradient penalty weight for
            wasserstein loss.
        'real_score_penalty_weight': A float of Additional penalty to keep
            the scores from drifting too far from zero.

  Returns:
    A `GANLoss` namedtuple.
  """
  gan_loss = tfgan.gan_loss(
      gan_model,
      generator_loss_fn=tfgan.losses.wasserstein_generator_loss,
      discriminator_loss_fn=tfgan.losses.wasserstein_discriminator_loss,
      gradient_penalty_weight=kwargs['gradient_penalty_weight'],
      gradient_penalty_target=kwargs['gradient_penalty_target'],
      gradient_penalty_epsilon=0.0)

  real_score_penalty = tf.reduce_mean(
      tf.square(gan_model.discriminator_real_outputs))
  tf.summary.scalar('real_score_penalty', real_score_penalty)

  return gan_loss._replace(
      discriminator_loss=(
          gan_loss.discriminator_loss +
          kwargs['real_score_penalty_weight'] * real_score_penalty))
def define_loss ( gan_model , * * kwargs ) : gan_loss = tfgan . gan_loss ( gan_model , generator_loss_fn = tfgan . losses . wasserstein_generator_loss , discriminator_loss_fn = tfgan . losses . wasserstein_discriminator_loss , gradient_penalty_weight = kwargs [ 'gradient_penalty_weight' ] , gradient_penalty_target = kwargs [ 'gradient_penalty_target' ] , gradient_penalty_epsilon = 0.0 ) real_score_penalty = tf . reduce_mean ( tf . square ( gan_model . discriminator_real_outputs ) ) tf . summary . scalar ( 'real_score_penalty' , real_score_penalty ) return gan_loss . _replace ( discriminator_loss = ( gan_loss . discriminator_loss + kwargs [ 'real_score_penalty_weight' ] * real_score_penalty ) )