Keras Frontend
Installing Dependencies
Updating pip
The pip version required in this subproject must be >= 19.3.
To upgrade pip:
pip install --upgrade pip
To check installed pip version:
pip -V
Importing Conda Environment:
conda env create -f keras_environment.yml --name ${KERAS_ENV_NAME}
Note: pip version MUST be > 19.3
Activating Conda Environment:
conda activate ${KERAS_ENV_NAME}
Building and Installing Frontend:
python setup.py build
python setup.py install
Download CNN Model Files
The weight (model) and data files to use with the CNN benchmarks are hosted on Git LFS and need to separately downloaded. This can be done using:
git lfs fetch
git lfs checkout
NOTE: Data donwload is necesary before running benchmarks
Running Benchmaks
Benchmarks under ./src/
List of benchmarks and the expected accuracies:
| Benchmark | Accuracy |
|---|---|
| AlexNet-CIFAR10 | 79.16 |
| AlexNet2-CIFAR10 | 85.10 |
| AlexNet-ImageNet | 56.30 |
| LeNet-MNIST | 99.11 |
| MobileNet-CIFAR10 | 82.40 |
| ResNet18-CIFAR10 | 89.52 |
| ResNet50-ImageNet | 75.10 |
| VGG16-CIFAR10 | 89.42 |
| VGG16-CIFAR100 | 66.20 |
| VGG16-ImageNet | 69.46 |
Activate conda environment (above) before running benchmarks
Synopsis
python src/${BENCH_NAME}.py [hpvm_reload|keras_reload] [frontend|keras_dump]
Parameters:
hpvm_reload : Reloads HPVM weights (format used in model_params found here: [ADD link to Google Drive]) from directory specified in Benchmark constructor.
keras_reload: Reloads weights in Keras .h5 file format
frontend: Invokes the HPVM frontend and dumps weights in directory specified in constructor
keras_dump: Dumps keras .h5 format model weights in directory specified in constructor
Building New Benchmarks
All benchmarks inherit from the commom parent Benchmark class.
Each benchmark overrides virtual functions for building the model, training, inference,
and data preprocessing.
def buildModel(self):
returns a keras model
def data_preprocess(self):
returns X_train, y_train, X_test, y_test, X_tuner, and y_tuner data — in that order; this data will be directly used later for training and inference
def trainModel(self, model, X_train, y_train, X_test, y_test):
returns a trained keras model