From 07669ccbb9781dbc8697c26ac7cf6cd67e43bc85 Mon Sep 17 00:00:00 2001
From: Lukas Geiger <lukas.geiger94@gmail.com>
Date: Fri, 16 Feb 2018 18:43:54 +0100
Subject: [PATCH] Fix Python 3 compatibility
---
MNIST_GAN/MNIST_GAN.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/MNIST_GAN/MNIST_GAN.py b/MNIST_GAN/MNIST_GAN.py
index f7451fa..cc0d7e9 100644
--- a/MNIST_GAN/MNIST_GAN.py
+++ b/MNIST_GAN/MNIST_GAN.py
@@ -72,14 +72,14 @@ y[ntrain:, 0] = 1 # class 0 for generated images
discriminator.fit(X, y, epochs=1, batch_size=128)
# - Create a dataset of 5000 real test images and 5000 fake images.
-no = np.random.choice(10000, size=ntrain/2, replace='False')
+no = np.random.choice(10000, size=ntrain//2, replace='False')
real_test = X_test[no, :, :, :] # sample real images from test set
-noise_gen = np.random.uniform(0, 1, size=[ntrain/2, latent_dim])
+noise_gen = np.random.uniform(0, 1, size=[ntrain//2, latent_dim])
generated_images = generator.predict(noise_gen) # generate fake images with untrained generator
Xt = np.concatenate((real_test, generated_images))
yt = np.zeros([ntrain, 2]) # class vector: one-hot encoding
-yt[:ntrain/2, 1] = 1 # class 1 for real images
-yt[ntrain/2:, 0] = 1 # class 0 for generated images
+yt[:ntrain//2, 1] = 1 # class 1 for real images
+yt[ntrain//2:, 0] = 1 # class 0 for generated images
# - Evaluate the test accuracy of your network.
pretrain_loss, pretrain_acc = discriminator.evaluate(Xt, yt, verbose=0, batch_size=128)
@@ -99,7 +99,7 @@ def train_for_n(epochs=1, batch_size=32):
generated_images = generator.predict(noise)
plot_images(generated_images, fname=log_dir + '/generated_images_' + str(epoch))
- iterations_per_epoch = 60000/batch_size # number of training steps per epoch
+ iterations_per_epoch = 60000//batch_size # number of training steps per epoch
perm = np.random.choice(60000, size=60000, replace='False')
for i in range(iterations_per_epoch):
--
GitLab