Home

Awesome

Training Quantized Neural Networks

Introduction

Train your own Quantized Neural Networks (QNN) - networks trained with quantized weights and activations - in Keras / Tensorflow. If you use this code, please cite "B.Moons et al. "Minimum Energy Quantized Neural Networks", Asilomar Conference on Signals, Systems and Computers, 2017". Take a look at our presentation or at the paper on arxiv.

This code is based on a lasagne/theano and a Keras/Tensorflow version of BinaryNet.

Preliminaries

Running this code requires:

  1. Tensorflow
  2. Keras 2.0
  3. pylearn2 + the correct PYLEARN2_DATA_PATH in ./personal_config/shell_source.sh
  4. A GPU with recent versions of CUDA and CUDNN
  5. Correct paths in ./personal_config/shell_source.sh

Make sure your backend='tensorflow' and image_data_format='channels_last' in the ~/.keras/keras.json file.

Training your own QNN

This repo includes toy examples for CIFAR-10 and MNIST. Training can be done by running the following:

./train.sh <config_file> -o <override_parameters>

-o overrides parameters in the <config_file>.

The following parameters are crucial:

Examples


The included networks have parametrized sizes and are split into three blocks (A-B-C), each with a number of layers (nl) and a number of filters per layer (nf).