From 504ad4e9ffaab82a1bd0171ee87912c954361526 Mon Sep 17 00:00:00 2001 From: Nathan Zhao <nz11@tyler.cs.illinois.edu> Date: Mon, 1 Feb 2021 20:39:59 -0600 Subject: [PATCH] fix imagenet benchmark bugs --- hpvm/projects/keras/src/alexnet_imagenet.py | 23 ++++++------------- hpvm/projects/keras/src/lenet.py | 1 - hpvm/projects/keras/src/resnet50_imagenet.py | 24 ++++++-------------- hpvm/projects/keras/src/vgg16_imagenet.py | 23 ++++++------------- 4 files changed, 21 insertions(+), 50 deletions(-) diff --git a/hpvm/projects/keras/src/alexnet_imagenet.py b/hpvm/projects/keras/src/alexnet_imagenet.py index 5fceb31b31..e3ab937e9b 100644 --- a/hpvm/projects/keras/src/alexnet_imagenet.py +++ b/hpvm/projects/keras/src/alexnet_imagenet.py @@ -21,28 +21,19 @@ from Config import MODEL_PARAMS_DIR -IMAGENET_DIR = '/home/nz11/ILSVRC2012/' -NUM_TUNE_CLASSES = 200 -IMAGES_PER_CLASS = 50 - - - class AlexNet(Benchmark): def data_preprocess(self): - - X_val = np.fromfile(MODEL_PARAMS_DIR + '/alexnet_imagenet/test_input.bin', dtype=np.float32) - y_val = np.fromfile(MODEL_PARAMS_DIR + '/alexnet_imagenet/test_labels.bin', dtype=np.uint32) - - X_val = X_val.reshape((-1, 3, 224, 224)) X_train, y_train = None, None - - 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 + '/alexnet_imagenet/test_input.bin', dtype=np.float32) + X_test = X_test.reshape((-1, 3, 224, 224)) + y_test = np.fromfile(MODEL_PARAMS_DIR + '/alexnet_imagenet/test_labels.bin', dtype=np.uint32) + X_tuner = np.fromfile(MODEL_PARAMS_DIR + '/alexnet_imagenet/tune_input.bin', dtype=np.float32) + X_tuner = X_tuner.reshape((-1, 3, 224, 224)) + y_tuner = np.fromfile(MODEL_PARAMS_DIR + '/alexnet_imagenet/tune_labels.bin', dtype=np.uint32) + return X_train, y_train, X_test, y_test, X_tuner, y_tuner diff --git a/hpvm/projects/keras/src/lenet.py b/hpvm/projects/keras/src/lenet.py index 83f4d3cf52..4b58e65314 100644 --- a/hpvm/projects/keras/src/lenet.py +++ b/hpvm/projects/keras/src/lenet.py @@ -51,7 +51,6 @@ class LeNet_MNIST(Benchmark): def data_preprocess(self): - (X_train, y_train), (X_val, y_val) = mnist.load_data() test_labels = y_val diff --git a/hpvm/projects/keras/src/resnet50_imagenet.py b/hpvm/projects/keras/src/resnet50_imagenet.py index bca4799b75..0c3006213d 100644 --- a/hpvm/projects/keras/src/resnet50_imagenet.py +++ b/hpvm/projects/keras/src/resnet50_imagenet.py @@ -16,18 +16,11 @@ from keras.utils import to_categorical from keras.preprocessing.image import ImageDataGenerator from keras.callbacks import LearningRateScheduler -from keras.applications.resnet50 import preprocess_input from Benchmark import Benchmark from Config import MODEL_PARAMS_DIR -IMAGENET_DIR = '/home/nz11/ILSVRC2012/' -NUM_TUNE_CLASSES = 200 -IMAGES_PER_CLASS = 50 - - - class ResNet50(Benchmark): def buildModel(self): @@ -120,19 +113,16 @@ class ResNet50(Benchmark): def data_preprocess(self): - - X_val = np.fromfile(MODEL_PARAMS_DIR + '/resnet50_imagenet/test_input.bin', dtype=np.float32) - y_val = np.fromfile(MODEL_PARAMS_DIR + '/resnet50_imagenet/test_labels.bin', dtype=np.uint32) - - X_val = X_val.reshape((-1, 3, 224, 224)) X_train, y_train = None, None - - 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 + '/resnet50_imagenet/test_input.bin', dtype=np.float32) + X_test = X_test.reshape((-1, 3, 224, 224)) + y_test = np.fromfile(MODEL_PARAMS_DIR + '/resnet50_imagenet/test_labels.bin', dtype=np.uint32) + X_tuner = np.fromfile(MODEL_PARAMS_DIR + '/resnet50_imagenet/tune_input.bin', dtype=np.float32) + X_tuner = X_tuner.reshape((-1, 3, 224, 224)) + y_tuner = np.fromfile(MODEL_PARAMS_DIR + '/resnet50_imagenet/tune_labels.bin', dtype=np.uint32) + return X_train, y_train, X_test, y_test, X_tuner, y_tuner diff --git a/hpvm/projects/keras/src/vgg16_imagenet.py b/hpvm/projects/keras/src/vgg16_imagenet.py index 5e2bef9c34..35ab92479e 100644 --- a/hpvm/projects/keras/src/vgg16_imagenet.py +++ b/hpvm/projects/keras/src/vgg16_imagenet.py @@ -21,12 +21,6 @@ from Config import MODEL_PARAMS_DIR -IMAGENET_DIR = '/home/nz11/ILSVRC2012/' -NUM_TUNE_CLASSES = 200 -IMAGES_PER_CLASS = 50 - - - class VGG16(Benchmark): def buildModel(self): @@ -104,19 +98,16 @@ class VGG16(Benchmark): def data_preprocess(self): - - X_val = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_imagenet/test_input.bin', dtype=np.float32) - y_val = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_imagenet/test_labels.bin', dtype=np.uint32) - - X_val = X_val.reshape((-1, 3, 224, 224)) X_train, y_train = None, None - - 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 + '/vgg16_imagenet/test_input.bin', dtype=np.float32) + X_test = X_test.reshape((-1, 3, 224, 224)) + y_test = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_imagenet/test_labels.bin', dtype=np.uint32) + X_tuner = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_imagenet/tune_input.bin', dtype=np.float32) + X_tuner = X_tuner.reshape((-1, 3, 224, 224)) + y_tuner = np.fromfile(MODEL_PARAMS_DIR + '/vgg16_imagenet/tune_labels.bin', dtype=np.uint32) + return X_train, y_train, X_test, y_test, X_tuner, y_tuner -- GitLab