1. 程式人生 > >在TensorFlow中對比兩大生成模型:VAE與GAN(附測試程式碼)

在TensorFlow中對比兩大生成模型:VAE與GAN(附測試程式碼)

 def GAN_loss_with_labels(true_logit, fake_logit):      """        Args:          true_logit : Given data from true distribution,                      `true_logit` is the output of Discriminator (a matrix now)          fake_logit : Given data generated from Generator,                      `fake_logit` is the output of Discriminator (a matrix now)      """
     d_true_loss = tf.nn.softmax_cross_entropy_with_logits(                    labels=self.labels, logits=self.true_logit, dim=1)      d_fake_loss = tf.nn.softmax_cross_entropy_with_logits(                    labels=1-self.labels, logits=self.fake_logit, dim=1)      g_loss = tf.nn.softmax_cross_entropy_with_logits(
                   labels=self.labels, logits=self.fake_logit, dim=1)      d_loss = d_true_loss + d_fake_loss      return tf.reduce_mean(d_loss), tf.reduce_mean(g_loss)