From e33168c1471e651527e6d4ae15faaebbcf6fa5d9 Mon Sep 17 00:00:00 2001 From: nunzip Date: Wed, 13 Mar 2019 22:25:16 +0000 Subject: Normalize labels --- ncdcgan.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ncdcgan.py b/ncdcgan.py index ccb99d3..ce6b907 100755 --- a/ncdcgan.py +++ b/ncdcgan.py @@ -157,6 +157,7 @@ class nCDCGAN(): X_train = (X_train.astype(np.float32) - 127.5) / 127.5 X_train = np.expand_dims(X_train, axis=3) y_train = y_train.reshape(-1, 1) + y_train = (y_train.astype(np.float32)-4.5)/4.5 # Adversarial ground truths valid = np.ones((batch_size, 1)) @@ -214,6 +215,7 @@ class nCDCGAN(): r, c = 2, 5 noise = np.random.normal(0, 1, (r * c, 100)) sampled_labels = np.arange(0, 10).reshape(-1, 1) + sampled_labels = (sampled_labels.astype(np.float32)-4.5)/4.5 #using dummy_labels would just print zeros to help identify image quality #dummy_labels = np.zeros(32).reshape(-1, 1) @@ -239,6 +241,7 @@ class nCDCGAN(): noise_test = np.random.normal(0, 1, (10000, 100)) noise_val = np.random.normal(0, 1, (5000, 100)) + ((labels_val.astype(np.float32)-4.5)/4.5) labels_train = np.zeros(55000).reshape(-1, 1) labels_test = np.zeros(10000).reshape(-1, 1) labels_val = np.zeros(5000).reshape(-1, 1) @@ -248,9 +251,9 @@ class nCDCGAN(): labels_test[i*1000:-1] = i labels_val[i*500:-1] = i - train_data = self.generator.predict([noise_train, labels_train]) - test_data = self.generator.predict([noise_test, labels_test]) - val_data = self.generator.predict([noise_val, labels_val]) + train_data = self.generator.predict([noise_train, ((labels_train.astype(np.float32)-4.5)/4.5)]) + test_data = self.generator.predict([noise_test, ((labels_test.astype(np.float32)-4.5)/4.5)]) + val_data = self.generator.predict([noise_val,((labels_val.astype(np.float32)-4.5)/4.5)]) labels_train = keras.utils.to_categorical(labels_train, 10) labels_test = keras.utils.to_categorical(labels_test, 10) -- cgit v1.2.3-54-g00ecf