Coder Social home page Coder Social logo

ml-lab / stochastic-quantization Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dongyp13/stochastic-quantization

0.0 3.0 0.0 8.21 MB

Training Low-bits DNNs with Stochastic Quantization

Shell 0.38% CMake 1.21% Makefile 0.27% HTML 0.08% CSS 0.10% Jupyter Notebook 57.19% C++ 33.16% Python 4.00% Cuda 2.59% MATLAB 0.36% M 0.01% Protocol Buffer 0.66%

stochastic-quantization's Introduction

Stochastic-Quantization

Introduction

This repository contains the codes for training and testing Stocastic Quantization described in the paper "Learning Accurate Low-bit Deep Neural Networks with Stochastic Quantization" (BMVC 2017, Oral).

We implement our codes based on Caffe framework. Our codes can be used for training BWN (Binary Weighted Networks), TWN (Ternary Weighted Networks), SQ-BWN and SQ-TWN.

Usage

Build Caffe

Please follow the standard installation of Caffe.

cd caffe/
make
cd ..

Training and Testing

CIFAR

For CIFAR-10(100), we provide two network architectures VGG-9 and ResNet-56 (See details in the paper). For example, use the following commands to train ResNet-56:

  • FWN
./CIFAR/ResNet-56/FWN/train.sh
  • BWN
./CIFAR/ResNet-56/BWN/train.sh
  • TWN
./CIFAR/ResNet-56/TWN/train.sh
  • SQ-BWN
./CIFAR/ResNet-56/SQ-BWN/train.sh
  • SQ-TWN
./CIFAR/ResNet-56/SQ-TWN/train.sh

ImageNet

For ImageNet, we provide AlexNet-BN and ResNet-18 network architectures. For example, use the following commands to train ResNet-18:

  • FWN
./ImageNet/ResNet-18/FWN/train.sh
  • BWN
./ImageNet/ResNet-18/BWN/train.sh
  • TWN
./ImageNet/ResNet-18/TWN/train.sh
  • SQ-BWN
./ImageNet/ResNet-18/SQ-BWN/train.sh
  • SQ-TWN
./ImageNet/ResNet-18/SQ-TWN/train.sh

Implementation

Layers

We add BinaryConvolution, BinaryInnerProduct, TernaryConvolution and TernaryInnerProduct layers to train binary or ternary networks. We also put useful functions of low-bits DNNs in lowbit-functions.

Params

We add two more parameters in convolution_param and inner_product_param, which are sq and ratio. sq means whether to use stochastic quantization (default to false). ratio is the SQ ratio (default to 100).

Note

Our codes can only run appropriately on GPU. CPU version should be further implemented.

Have fun to deploy your own low-bits DNNs!

stochastic-quantization's People

Contributors

dongyp13 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.