diff --git a/hpvm/projects/keras/README.md b/hpvm/projects/keras/README.md index 9cb2bb31236196f48555c47df4785d89dd386e42..892c8f0402c8c02acca50405b7305dd7ceefc89c 100644 --- a/hpvm/projects/keras/README.md +++ b/hpvm/projects/keras/README.md @@ -7,6 +7,7 @@ ``` conda env create -f keras_environment.yml --name ${KERAS_ENV_NAME} ``` +Note: pip version MUST be > 19.3 ### Activating Conda Environment: @@ -30,14 +31,15 @@ List of benchmarks and the expected accuracies: | Benchmark | Accuracy | | ----------- | ----------- | -| AlexNet-CIFAR10 | 79.03 | -| AlexNet2-CIFAR10 | 84.87 | -| AlexNet-ImageNet | 56.23 | -| LeNet-MNIST | 99.11 | -| MobileNet-CIFAR10 | 84.74 | -| ResNet18-CIFAR10 | 89.48 | -| VGG16-CIFAR10 | 89.58 | -| VGG16-CIFAR100 | 67.46 | +| AlexNet-CIFAR10 | 79.16 | +| AlexNet2-CIFAR10 | 85.10 | +| AlexNet-ImageNet | 56.23 | todo: fix broken +| LeNet-MNIST | 99.11 | todo: fix broken +| MobileNet-CIFAR10 | 82.40 | +| ResNet18-CIFAR10 | 89.52 | +| ResNet50-ImageNet | 74.50 | +| VGG16-CIFAR10 | 89.42 | +| VGG16-CIFAR100 | 66.20 | | VGG16-ImageNet | 72.50 | Activate conda environment (above) before running benchmarks diff --git a/hpvm/projects/keras/src/Config.py b/hpvm/projects/keras/src/Config.py index 9b0c4d07685cbb73808be3b91b2227cf16ef171d..2edc5c1add5542edabdd052097ccb4b45d608472 100644 --- a/hpvm/projects/keras/src/Config.py +++ b/hpvm/projects/keras/src/Config.py @@ -1,3 +1,3 @@ # Path Relative to Model Params Directory -MODEL_PARAMS_DIR = "../../build/model_params/" +MODEL_PARAMS_DIR = "../../../hpvm/test/dnn_benchmarks/model_params/" diff --git a/hpvm/projects/keras/src/alexnet.py b/hpvm/projects/keras/src/alexnet.py index 4682a96eb5e18b8ae79cb4a2ad645ae3665e4bff..4b23fd995ffcc5a4f3234566a8a76dac8c12c6aa 100644 --- a/hpvm/projects/keras/src/alexnet.py +++ b/hpvm/projects/keras/src/alexnet.py @@ -4,7 +4,6 @@ import glob import numpy as np import tensorflow as tf -import cv2 import scipy import scipy.io import keras @@ -56,7 +55,7 @@ class AlexNet_CIFAR10(Benchmark): #model.add(Dense(256)) model.add(Dense(self.num_classes)) model.add(Activation('softmax')) - + return model @@ -69,8 +68,8 @@ class AlexNet_CIFAR10(Benchmark): 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) / (std + 1e-7) + X_val = (X_val - mean) / (std + 1e-7) X_test = X_val[0:5000] y_test = y_val[0:5000] @@ -140,7 +139,7 @@ if __name__ == '__main__': src_dir = 'data/alexnet_cifar10_src/' num_classes = 10 batch_size = 500 - + model = AlexNet_CIFAR10('AlexNet_CIFAR10', reload_dir, keras_model_file, data_dir, src_dir, num_classes, batch_size) model.run(sys.argv) diff --git a/hpvm/projects/keras/src/alexnet2.py b/hpvm/projects/keras/src/alexnet2.py index 8f068e4d6e1a264f52c8d9c02265ff91b6a4bf2e..de69d8c12972df7a1fa51338b30676ffafc65f4e 100644 --- a/hpvm/projects/keras/src/alexnet2.py +++ b/hpvm/projects/keras/src/alexnet2.py @@ -4,7 +4,6 @@ import glob import numpy as np import tensorflow as tf -import cv2 import scipy import scipy.io import keras @@ -68,8 +67,8 @@ class AlexNet2_CIFAR10(Benchmark): 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) / (std + 1e-7) + X_val = (X_val - mean) / (std + 1e-7) X_test = X_val[0:5000] y_test = y_val[0:5000] diff --git a/hpvm/projects/keras/src/alexnet_imagenet.py b/hpvm/projects/keras/src/alexnet_imagenet.py index 4c00650abd910ea622567d6090925f4a5ce67b42..c05f757a7ca44a86258e5b9d7889c4f45ea44d39 100644 --- a/hpvm/projects/keras/src/alexnet_imagenet.py +++ b/hpvm/projects/keras/src/alexnet_imagenet.py @@ -141,7 +141,7 @@ class AlexNet(Benchmark): x = Activation('relu')(x) x = Dense(self.num_classes)(x) x = Activation('softmax')(x) - + model = Model(input_layer, x) return model diff --git a/hpvm/projects/keras/src/lenet.py b/hpvm/projects/keras/src/lenet.py index 72e77f756d83a5ade1b06b284132e7c24c928c63..0210baee268f5a0a3a2d8f36873d023380f7e5f2 100644 --- a/hpvm/projects/keras/src/lenet.py +++ b/hpvm/projects/keras/src/lenet.py @@ -4,7 +4,6 @@ import glob import numpy as np import tensorflow as tf -import cv2 import scipy import scipy.io import keras diff --git a/hpvm/projects/keras/src/mobilenet_cifar10.py b/hpvm/projects/keras/src/mobilenet_cifar10.py index 2fba7612503ad3cb39893476e91dcb1a3452697a..367a4dfc6244228b7b1336d1a63044273cebd2fb 100644 --- a/hpvm/projects/keras/src/mobilenet_cifar10.py +++ b/hpvm/projects/keras/src/mobilenet_cifar10.py @@ -4,7 +4,6 @@ import glob import numpy as np import tensorflow as tf -import cv2 import scipy import scipy.io import keras @@ -45,7 +44,7 @@ class MobileNet_CIFAR10(Benchmark): def _depthwise_conv_block(pointwise_conv_filters, alpha, depth_multiplier=1, strides=(1, 1)): channel_axis = 1 - model.add(ZeroPadding2D(padding = ((1,1), (1,1) ))) + model.add(ZeroPadding2D(padding=((1,1), (1,1)))) model.add(DepthwiseConv2D((3, 3), padding='valid', @@ -110,8 +109,8 @@ class MobileNet_CIFAR10(Benchmark): 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) / (std + 1e-7) + X_val = (X_val - mean) / (std + 1e-7) X_test = X_val[0:5000] y_test = y_val[0:5000] diff --git a/hpvm/projects/keras/src/resnet18_cifar10.py b/hpvm/projects/keras/src/resnet18_cifar10.py index 8842ff7c677cec0290a5a10e8bcef538355ac2ad..1367c0830bdb96f3d5a310c36ce9022e314eba03 100644 --- a/hpvm/projects/keras/src/resnet18_cifar10.py +++ b/hpvm/projects/keras/src/resnet18_cifar10.py @@ -39,7 +39,6 @@ import glob import numpy as np import tensorflow as tf -#import cv2 import scipy import scipy.io import keras @@ -443,8 +442,10 @@ class ResNet18_CIFAR10(Benchmark): 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) / (std + 1e-7) +# X_val = (X_val - mean) / (std + 1e-7) + X_train = (X_train - mean) + X_val = (X_val - mean) X_test = X_val[0:5000] y_test = y_val[0:5000] diff --git a/hpvm/projects/keras/src/vgg16_cifar10.py b/hpvm/projects/keras/src/vgg16_cifar10.py index d8b26f9386e132359652e67123ca1d8080f303d9..873e23b766ffbd58c1d5db89141da60fee88126e 100644 --- a/hpvm/projects/keras/src/vgg16_cifar10.py +++ b/hpvm/projects/keras/src/vgg16_cifar10.py @@ -4,7 +4,6 @@ import glob import numpy as np import tensorflow as tf -#import cv2 import scipy import scipy.io import keras @@ -108,8 +107,8 @@ class VGG16_CIFAR10(Benchmark): 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) / (std + 1e-7) + X_val = (X_val - mean) / (std + 1e-7) X_test = X_val[0:5000] y_test = y_val[0:5000] diff --git a/hpvm/projects/keras/src/vgg16_cifar100.py b/hpvm/projects/keras/src/vgg16_cifar100.py index 0dd47ac992ad206d09126f282e527b18c97ec930..03bb852e00bb61a7b17836f5c4df5bbf56c4b466 100644 --- a/hpvm/projects/keras/src/vgg16_cifar100.py +++ b/hpvm/projects/keras/src/vgg16_cifar100.py @@ -4,7 +4,6 @@ import glob import numpy as np import tensorflow as tf -#import cv2 import scipy import scipy.io import keras @@ -124,8 +123,8 @@ class VGG16_CIFAR100(Benchmark): 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) / (std + 1e-7) + X_val = (X_val - mean) / (std + 1e-7) X_test = X_val[0:5000] y_test = y_val[0:5000]