Skip to content

Instantly share code, notes, and snippets.

@RaphaelMeudec
Last active March 20, 2018 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaphaelMeudec/c9c07f61981dda4d4ff742e020b6c4ba to your computer and use it in GitHub Desktop.
Save RaphaelMeudec/c9c07f61981dda4d4ff742e020b6c4ba to your computer and use it in GitHub Desktop.
for epoch in range(epoch_num):
for index in range(batches):
# [Batch Preparation]
# Generate fake inputs
generated_images = g.predict(x=image_blur_batch, batch_size=batch_size)
# Train multiple times discriminator on real and fake inputs
for _ in range(critic_updates):
d_loss_real = d.train_on_batch(image_full_batch, output_true_batch)
d_loss_fake = d.train_on_batch(generated_images, output_false_batch)
d_loss = 0.5 * np.add(d_loss_fake, d_loss_real)
d.trainable = False
# Train generator only on discriminator's decision and generated images
d_on_g_loss = d_on_g.train_on_batch(image_blur_batch, [image_full_batch, output_true_batch])
d.trainable = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment