yiweifengyan / Pytorch-XNOR-Net

XNOR-Net, with binary gemm and binary conv2d kernels, support both CPU and GPU.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pytorch-XNOR-Net

Build

cd <Repository Root>/csrc/binop
make

MNIST

Usage

Train:

cd <Repository Root>/MNIST/
python3 main.py --arch Bin_LeNet
python3 main.py --arch LeNet

Evaluate:

cd <Repository Root>/MNIST/
python3 main.py --arch Bin_LeNet --evaluate --pretrained ./models/Bin_LeNet.best.pth # --no_cuda (Use CPU)
python3 main.py --arch LeNet --evaluate --pretrained ./models/LeNet.best.pth # --no_cuda (Use CPU)

Result

Network Accuracy Size
LeNet 99.50% 1.7 MB
Bin_LeNet 99.45% 102 KB

Cifar10

Usage

Train:

cd <Repository Root>/Cifar10/
python3 main.py --arch Bin_VGG16 #(11, 13, 16, 19)
python3 main.py --arch VGG16 #(11, 13, 16, 19)

Evaluate:

cd <Repository Root>/Cifar10/
python3 main.py --arch Bin_VGG16 --evaluate --pretrained ./models/Bin_VGG16.best.pth # --no_cuda (Use CPU)
python3 main.py --arch VGG16 --evaluate --pretrained ./models/VGG16.best.pth # --no_cuda (Use CPU)

Result

Network Accuracy Size  
VGG13 92.40% 37.7 MB
Bin_VGG13 88.74% 1.3 MB
VGG16 92.29% 59.0 MB
Bin_VGG16 87.78% 2.0 MB

Pre-trained models

Google Drive

Environment

Software

  • Ubuntu 16.04
  • Python 3.5
  • Pytorch 0.3.1
  • CUDA 8.0
  • gcc 5.4

Hardware

  • NVIDIA GTX 1080
  • Intel i5-6500 CPU @ 3.20GHz × 4

Reference

About

XNOR-Net, with binary gemm and binary conv2d kernels, support both CPU and GPU.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 47.5%Language:C 25.0%Language:C++ 21.1%Language:Cuda 5.4%Language:Makefile 1.0%Language:Shell 0.2%