Skip to content
Snippets Groups Projects

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}

Activating Conda Environment:

conda activate ${KERAS_ENV_NAME}

Building and Installing Frontend:

python setup.py build

python setup.py install

Running Benchmaks

Benchmarks under ./src/

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
VGG16-ImageNet 72.50

Activate conda environment (above) before running benchmarks

Synopsis

python src/${BENCH_NAME}.py  [hpvm_reload|keras_reload]  [frontend] 

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

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