Skip to content
Snippets Groups Projects

Keras Frontend

Installing Dependencies

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

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.23
LeNet-MNIST 99.11
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

Synopsys

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