diff options
-rwxr-xr-x | cgan.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -141,6 +141,7 @@ class CGAN(): gen_imgs = self.generator.predict([noise, labels]) # Train the discriminator + d_loss_real = self.discriminator.train_on_batch([imgs, labels], valid*smooth_real) d_loss_fake = self.discriminator.train_on_batch([gen_imgs, labels], valid*smooth_fake) d_loss = 0.5 * np.add(d_loss_real, d_loss_fake) @@ -152,7 +153,10 @@ class CGAN(): # Condition on labels sampled_labels = np.random.randint(0, 10, batch_size).reshape(-1, 1) # Train the generator - g_loss = self.combined.train_on_batch([noise, sampled_labels], valid) + if epoch % 3 == 0 + g_loss = self.combined.train_on_batch([noise, sampled_labels], valid) + else: + g_loss = 0 # Plot the progress #print ("%d [D loss: %f, acc.: %.2f%%] [G loss: %f]" % (epoch, d_loss[0], 100*d_loss[1], g_loss)) |