Binary-Neural-Networks-PyTorch-1.0 icon indicating copy to clipboard operation
Binary-Neural-Networks-PyTorch-1.0 copied to clipboard

BNNs (XNOR, BNN and DoReFa) implementation for PyTorch 1.0+

Binary Neural Networks on PyTorch

Binarization

This repository implements three popular papers that introduced the concept of Binary Neural Networks:

The project is organized as follows:

  • models folder contains CNN models (simple mlp, Network-in-Network, LeNet5, etc.)
  • classifiers/{type}_classifier.py contains the test and train procedures; where type = {bnn, xnor, dorefa}
  • models/{type}_layers.py contains the binarylayers implementation (binary activation, binary conv and fully-connected layers, gradient update); where type = {bnn, xnor, dorefa}
  • yml folder contains configuration files with hyperparameters
  • main.py represents the entry file

Installation

All packages are in requirement.txt Install the dependencies:

pip install -r requirements.txt

Basic usage

$ python main.py app:{yml_file}

Example

Network-in-Network on CIFAR10 dataset. All hyper parameters are in .yml file.

$ python main.py app:yml/nin_cifar10.yml

Related Applications

If you find this code useful in your research, please consider citing one of the works in this section.

License

MIT