From 228446239a964a6655c9917d62490fbeab0a85da Mon Sep 17 00:00:00 2001
From: Hashim Sharif <hsharif3@miranda.cs.illinois.edu>
Date: Wed, 3 Feb 2021 17:23:32 -0600
Subject: [PATCH] Fixing 2 bugs in Keras sources + Cleaning up unused code

---
 hpvm/projects/keras/src/alexnet.py           | 4 ++--
 hpvm/projects/keras/src/alexnet2.py          | 2 --
 hpvm/projects/keras/src/mobilenet_cifar10.py | 6 +++---
 hpvm/projects/keras/src/resnet18_cifar10.py  | 6 ------
 hpvm/projects/keras/src/vgg16_cifar10.py     | 4 ++--
 hpvm/projects/keras/src/vgg16_cifar100.py    | 8 ++++----
 6 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/hpvm/projects/keras/src/alexnet.py b/hpvm/projects/keras/src/alexnet.py
index d611fc3f80..9b4d9dfdca 100644
--- a/hpvm/projects/keras/src/alexnet.py
+++ b/hpvm/projects/keras/src/alexnet.py
@@ -64,12 +64,12 @@ class AlexNet_CIFAR10(Benchmark):
         (X_train, y_train), (X_val, y_val) = cifar10.load_data()
 
         X_train = X_train / 255.0
-        X_val = X_val / 255.0
+        #X_val = X_val / 255.0
 
         mean = np.mean(X_train)
         std = np.std(X_train)
         X_train = (X_train - mean) / (std + 1e-7)
-        X_val = (X_val - mean) / (std + 1e-7)
+        #X_val = (X_val - mean) / (std + 1e-7)
 
 
         X_test = np.fromfile(MODEL_PARAMS_DIR + '/alexnet_cifar10/test_input.bin', dtype=np.float32)
diff --git a/hpvm/projects/keras/src/alexnet2.py b/hpvm/projects/keras/src/alexnet2.py
index 9c6c9ec621..554caf06e4 100644
--- a/hpvm/projects/keras/src/alexnet2.py
+++ b/hpvm/projects/keras/src/alexnet2.py
@@ -63,12 +63,10 @@ class AlexNet2_CIFAR10(Benchmark):
         (X_train, y_train), (X_val, y_val) = cifar10.load_data()
 
         X_train = X_train / 255.0
-        X_val = X_val / 255.0
 
         mean = np.mean(X_train)
         std = np.std(X_train)
         X_train = (X_train - mean) / (std + 1e-7)
-        X_val = (X_val - mean) / (std + 1e-7)
 
         X_test = np.fromfile(MODEL_PARAMS_DIR + '/alexnet2_cifar10/test_input.bin', dtype=np.float32)
         y_test = np.fromfile(MODEL_PARAMS_DIR + '/alexnet2_cifar10/test_labels.bin', dtype=np.uint32)
diff --git a/hpvm/projects/keras/src/mobilenet_cifar10.py b/hpvm/projects/keras/src/mobilenet_cifar10.py
index c1ea50c109..2406e13435 100644
--- a/hpvm/projects/keras/src/mobilenet_cifar10.py
+++ b/hpvm/projects/keras/src/mobilenet_cifar10.py
@@ -105,12 +105,12 @@ class MobileNet_CIFAR10(Benchmark):
         (X_train, y_train), (X_val, y_val) = cifar10.load_data()
 
         X_train = X_train / 255.0
-        X_val = X_val / 255.0
+        #X_val = X_val / 255.0
 
         mean = np.mean(X_train)
         std = np.std(X_train)
         X_train = (X_train - mean) / (std + 1e-7)
-        X_val = (X_val - mean) / (std + 1e-7)
+        #X_val = (X_val - mean) / (std + 1e-7)
 
         X_test = np.fromfile(MODEL_PARAMS_DIR + '/mobilenet_cifar10/test_input.bin', dtype=np.float32)
         y_test= np.fromfile(MODEL_PARAMS_DIR + '/mobilenet_cifar10/test_labels.bin', dtype=np.uint32)
@@ -120,7 +120,7 @@ class MobileNet_CIFAR10(Benchmark):
         X_tuner = np.fromfile(MODEL_PARAMS_DIR + '/mobilenet_cifar10/tune_input.bin', dtype=np.float32)
         y_tuner = np.fromfile(MODEL_PARAMS_DIR + '/mobilenet_cifar10/tune_labels.bin', dtype=np.uint32)
 
-        X_tuner = X_tune.reshape((-1,3,32,32))
+        X_tuner = X_tuner.reshape((-1,3,32,32))
 
 
         return X_train, y_train, X_test, y_test, X_tuner, y_tuner
diff --git a/hpvm/projects/keras/src/resnet18_cifar10.py b/hpvm/projects/keras/src/resnet18_cifar10.py
index 266f00dfa9..6f94a151e8 100644
--- a/hpvm/projects/keras/src/resnet18_cifar10.py
+++ b/hpvm/projects/keras/src/resnet18_cifar10.py
@@ -438,15 +438,9 @@ class ResNet18_CIFAR10(Benchmark):
         (X_train, y_train), (X_val, y_val) = cifar10.load_data()
 
         X_train = X_train / 255.0
-        X_val = X_val / 255.0
-
         mean = np.mean(X_train)
         std = np.std(X_train)
-#         X_train = (X_train - mean) / (std + 1e-7)
-#         X_val = (X_val - mean) / (std + 1e-7)
         X_train = (X_train - mean)
-        X_val = (X_val - mean)
-
 
         X_test = np.fromfile(MODEL_PARAMS_DIR + '/resnet18_cifar10/test_input.bin', dtype=np.float32)
         y_test = np.fromfile(MODEL_PARAMS_DIR + '/resnet18_cifar10/test_labels.bin', dtype=np.uint32)
diff --git a/hpvm/projects/keras/src/vgg16_cifar10.py b/hpvm/projects/keras/src/vgg16_cifar10.py
index 3870aa6dc9..9677fc2650 100644
--- a/hpvm/projects/keras/src/vgg16_cifar10.py
+++ b/hpvm/projects/keras/src/vgg16_cifar10.py
@@ -103,12 +103,12 @@ class VGG16_CIFAR10(Benchmark):
         (X_train, y_train), (X_val, y_val) = cifar10.load_data()
 
         X_train = X_train / 255.0
-        X_val = X_val / 255.0
+        #X_val = X_val / 255.0
 
         mean = np.mean(X_train)
         std = np.std(X_train)
         X_train = (X_train - mean) / (std + 1e-7)
-        X_val = (X_val - mean) / (std + 1e-7)
+        #X_val = (X_val - mean) / (std + 1e-7)
 
         X_test= np.fromfile(MODEL_PARAMS_DIR + '/vgg16_cifar10/test_input.bin', dtype=np.float32)
         y_test = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_cifar10/test_labels.bin', dtype=np.uint32)
diff --git a/hpvm/projects/keras/src/vgg16_cifar100.py b/hpvm/projects/keras/src/vgg16_cifar100.py
index d605e05bd9..5d68392934 100644
--- a/hpvm/projects/keras/src/vgg16_cifar100.py
+++ b/hpvm/projects/keras/src/vgg16_cifar100.py
@@ -119,20 +119,20 @@ class VGG16_CIFAR100(Benchmark):
         (X_train, y_train), (X_val, y_val) = cifar100.load_data()
 
         X_train = X_train / 255.0
-        X_val = X_val / 255.0
+        #X_val = X_val / 255.0
 
         mean = np.mean(X_train)
         std = np.std(X_train)
         X_train = (X_train - mean) / (std + 1e-7)
-        X_val = (X_val - mean) / (std + 1e-7)
+        #X_val = (X_val - mean) / (std + 1e-7)
 
         X_test = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_cifar100/test_input.bin', dtype=np.float32)
         y_test = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_cifar100/test_labels.bin', dtype=np.uint32)
 
         X_test = X_test.reshape((-1,3,32,32))
 
-        X_tuner = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_cifar100/tuner_input.bin', dtype=np.float32)
-        y_tuner = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_cifar100/tuner_labels.bin', dtype=np.uint32)
+        X_tuner = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_cifar100/tune_input.bin', dtype=np.float32)
+        y_tuner = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_cifar100/tune_labels.bin', dtype=np.uint32)
 
         X_tuner = X_tuner.reshape((-1,3,32,32))
 
-- 
GitLab