https://github.com/mit-han-lab/bnn-icestick
Binary Neural Network on IceStick FPGA.
https://github.com/mit-han-lab/bnn-icestick
fpga hardware-acceleration low-power-vision on-device-ai
Last synced: 5 months ago
JSON representation
Binary Neural Network on IceStick FPGA.
- Host: GitHub
- URL: https://github.com/mit-han-lab/bnn-icestick
- Owner: mit-han-lab
- License: mit
- Created: 2018-05-23T21:57:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-11T02:54:14.000Z (about 7 years ago)
- Last Synced: 2023-10-20T21:50:38.577Z (almost 2 years ago)
- Topics: fpga, hardware-acceleration, low-power-vision, on-device-ai
- Language: Jupyter Notebook
- Homepage:
- Size: 229 KB
- Stars: 47
- Watchers: 5
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Binary Neural Network on IceStick FPGA
## Introduction
This project is from Magma Hackathon by Yujun Lin, Kaidi Cao and Song HanThis design implements a one-layer binary neural network for handwritten digits recognition (0-9). Both the weights and activations are binary which is very computation-efficient. We also provided the Tensorflow code to train binary neural networks under `nn_train`. However, if you are only interested in the hardware part, you can use our pre-trained model under `nn_train/BNN.pkl`
You may start with `tutorial_digits_recognition_on_icestick.ipynb` which will guide you through the entire flow.
The architecture is output stationary. The image is resized to 16x16, and operand width in execution stage of pipeline is 16 bit. The pipeline contains five stages:

- IF: calculate IDX and CYCLE as shown in figure
- RR: read weight matrix and image block from ROM and LUTs
- EXE: using NXOR and Popcount to perform binary matrix multiplication and accumulate results
- CP: compare result to previous maximum result and save the index (prediction number) for maximum result
- FI: wait to show result until all calculation completesThere are five lights (D0, D1, D2, D3, D4) on the IceStick FPGA. The D5 LED is green which indicates the finish of calculation. Others are red and used for indicates binary representation of predited number.
### Directories and Files
`nn_train` contains tutorials of training a binary neural network for digits recognition and format of saving weight matrix and images used for FPGA.
`nn_train/BNN.pkl` contains the weight matrix and images we seleted. Only digit 4 is incorrectly recognized as 9 and other numbers can be perfectly recognized.
`test_modules` shows the simulation of our pipeline.
`tutorial_digits_recognition_on_icestick` is the tutorial to convert our code to verilog and download to icestick FPGA for experiments.
## LICENSE
The MIT License
Copyright (c) 2017 Yujun Lin, Kaidi Cao, Song Han
Contact: songhan@mit.edu, yujunlin@mit.edu