From ab17f3f128c0d462596ee0338fb3457e3c15bc81 Mon Sep 17 00:00:00 2001 From: Hashim Sharif <hsharif3@miranda.cs.illinois.edu> Date: Tue, 2 Feb 2021 17:33:41 -0600 Subject: [PATCH] Fixing LeNet model --- hpvm/projects/keras/src/lenet.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hpvm/projects/keras/src/lenet.py b/hpvm/projects/keras/src/lenet.py index 4b58e65314..01c84719e6 100644 --- a/hpvm/projects/keras/src/lenet.py +++ b/hpvm/projects/keras/src/lenet.py @@ -26,7 +26,7 @@ class LeNet_MNIST(Benchmark): def buildModel(self): - # Network Compostion: 3 Conv Layers, 2 Dense Layers + # Network Compostion: 2 Conv Layers, 2 Dense Layers model = Sequential() # ConvLayer1 @@ -40,10 +40,10 @@ class LeNet_MNIST(Benchmark): model.add(Flatten()) # DenseLayer1 - model.add(Dense(1024, activation='relu')) + model.add(Dense(1024, activation='tanh')) # DenseLayer2 - model.add(Dense(self.num_classes, activation='relu')) + model.add(Dense(self.num_classes, activation='tanh')) # Softmax Layer model.add(Activation('softmax')) @@ -55,18 +55,16 @@ class LeNet_MNIST(Benchmark): test_labels = y_val X_train = X_train.reshape(X_train.shape[0], 1, 28, 28) - X_val = X_val.reshape(X_val.shape[0], 1, 28, 28) - - X_train = X_train.astype('float32') - X_val = X_val.astype('float32') X_train /= 255 - X_val /= 255 - X_test = X_val[0:5000] - y_test = y_val[0:5000] - X_tuner = X_val[5000:] - y_tuner = y_val[5000:] + X_test = np.fromfile(MODEL_PARAMS_DIR + '/lenet_mnist/test_input.bin', dtype=np.float32) + X_test = X_test.reshape((-1, 1, 28, 28)) + y_test = np.fromfile(MODEL_PARAMS_DIR + '/lenet_mnist/test_labels.bin', dtype=np.uint32) + + X_tuner = np.fromfile(MODEL_PARAMS_DIR + '/lenet_mnist/tune_input.bin', dtype=np.float32) + X_tuner = X_tuner.reshape((-1, 1, 28, 28)) + y_tuner = np.fromfile(MODEL_PARAMS_DIR + '/lenet_mnist/tune_labels.bin', dtype=np.uint32) return X_train, y_train, X_test, y_test, X_tuner, y_tuner -- GitLab