From 9945d9fe431f0b01c528b311acb685bebd99ab48 Mon Sep 17 00:00:00 2001 From: nunzip Date: Wed, 13 Mar 2019 18:52:18 +0000 Subject: Introduce gd balancing in DCGAN --- dcgan.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dcgan.py b/dcgan.py index 7844843..4317994 100644 --- a/dcgan.py +++ b/dcgan.py @@ -113,7 +113,7 @@ class DCGAN(): return Model(img, validity) - def train(self, epochs, batch_size=128, save_interval=50, VBN=False): + def train(self, epochs, batch_size=128, save_interval=50, VBN=False, gdstep=1): # Load the dataset (X_train, _), (_, _) = mnist.load_data() @@ -153,7 +153,10 @@ class DCGAN(): # --------------------- # Train the generator (wants discriminator to mistake images as real) - g_loss = self.combined.train_on_batch(noise, valid) + if epoch % gdstep == 0: + g_loss = self.combined.train_on_batch(noise, 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