Giter VIP home page Giter VIP logo

bnn_icestick's Introduction

Binary Neural Network on IceStick FPGA

Introduction

This project is from Magma Hackathon by Yujun Lin, Kaidi Cao and Song Han

This 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:

binary matrix vector multiplication

  • 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 completes

There 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: [email protected], [email protected]

bnn_icestick's People

Contributors

adamdai avatar stanford-cva-lab avatar

Watchers

 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.