From c52cdcbed812218ce1984c59a67dec588d9d6bdc Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Fri, 15 Jun 2018 16:56:48 +0200 Subject: [PATCH] removed hard-coded instances of self.latent_dim = 100 --- gan/gan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gan/gan.py b/gan/gan.py index 899e072..b7033d4 100644 --- a/gan/gan.py +++ b/gan/gan.py @@ -34,7 +34,7 @@ class GAN(): self.generator = self.build_generator() # The generator takes noise as input and generates imgs - z = Input(shape=(100,)) + z = Input(shape=(self.latent_dim,)) img = self.generator(z) # For the combined model we will only train the generator @@ -112,7 +112,7 @@ class GAN(): idx = np.random.randint(0, X_train.shape[0], batch_size) imgs = X_train[idx] - noise = np.random.normal(0, 1, (batch_size, 100)) + noise = np.random.normal(0, 1, (batch_size, self.latent_dim)) # Generate a batch of new images gen_imgs = self.generator.predict(noise) @@ -126,7 +126,7 @@ class GAN(): # Train Generator # --------------------- - noise = np.random.normal(0, 1, (batch_size, 100)) + noise = np.random.normal(0, 1, (batch_size, self.latent_dim)) # Train the generator (to have the discriminator label samples as valid) g_loss = self.combined.train_on_batch(noise, valid) @@ -140,7 +140,7 @@ class GAN(): def sample_images(self, epoch): r, c = 5, 5 - noise = np.random.normal(0, 1, (r * c, 100)) + noise = np.random.normal(0, 1, (r * c, self.latent_dim)) gen_imgs = self.generator.predict(noise) # Rescale images 0 - 1