Skip to content

Instantly share code, notes, and snippets.

@pythonlessons
Created April 18, 2023 13:04
Show Gist options
  • Select an option

  • Save pythonlessons/2259986e4c0ae48ac041d4b072f42732 to your computer and use it in GitHub Desktop.

Select an option

Save pythonlessons/2259986e4c0ae48ac041d4b072f42732 to your computer and use it in GitHub Desktop.
gan_introduction
def discriminator_loss(real_output, fake_output):
real_loss = tf.keras.losses.BinaryCrossentropy(from_logits=True)(tf.ones_like(real_output), real_output)
fake_loss = tf.keras.losses.BinaryCrossentropy(from_logits=True)(tf.zeros_like(fake_output), fake_output)
total_loss = real_loss + fake_loss
return total_loss
def generator_loss(fake_output):
return tf.keras.losses.BinaryCrossentropy(from_logits=True)(tf.ones_like(fake_output), fake_output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment