From 79d666afdf6517ea15bfc9b882f7e4e77bff295b Mon Sep 17 00:00:00 2001 From: nunzip Date: Wed, 13 Mar 2019 17:25:54 +0000 Subject: Try GD --- cgan.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cgan.py b/cgan.py index a34a0e3..d579e33 100755 --- a/cgan.py +++ b/cgan.py @@ -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)) -- cgit v1.2.3-54-g00ecf