Giter VIP home page Giter VIP logo

naivebayes's Introduction

InAccel

Gaussian Naive Bayes Classifier

This is an FPGA accelerated solution of Gaussian NaiveBayes classification algorithm. It provides up to 100x speedup compared to a single threaded execution on an Intel Xeon CPU.

Specifications

Classes Features
up to 64 up to 2048

Supported Platforms and XRT

Board
Xilinx Alveo U200
Xilinx Alveo U250
AWS VU9P (F1 instances)
Alibaba VU9P (F3 instances)
Any other Xilinx platform with at least the same amount of VU9P resources
XRT
2019.1 and above

Design Files

  • The accelerator kernel files are located under the cpp/kernel_srcs directory while any accelerator binaries will be compiled under cpp one.
  • The Makefile under cpp folder will help you generate the host executable ass well as the accelerator .xclbin file.

A list of all the project files is shown below:

- data/
- cpp/
	- hosts_srcs/
		- NaiveBayes.cpp
	- kernel_srcs/
		- Classifier_0.cpp (Accelerated kernel)
		- Classifier_1.cpp (Accelerated kernel)
		- Classifier_2.cpp (Accelerated kernel)
		- Classifier_3.cpp (Accelerated kernel)
	- Makefile
	- sdaccel.ini
- java/
	- src/
		- main/java/com/inaccel/ml/NaiveBayes.java
		- test/java/NaiveBayesTest.java
- python/
	- \__init__.py
	- NaiveBayes.py
	- NaiveBayesTest.py
- hosts_srcs/
	- NaiveBayes.cpp

Compiling the kernels

This step is optional for running the demo as you can use a pre-compiled version of NaiveBayes Classifier accelerator found in our bitstream repository.

To compile the kernels you just need to execute make xbin.
A full list of all the available Makefile targets can be found using make help command.

As far as the platform (or board) is concerned, Makefile uses AWS_PLATFORM environment variable as the target platform for the kernels compilation. If you are running this on AWS make sure AWS_PLATFORM environment variable is present and points to the platform DSA files1. Otherwise you can set Makefile PLATFORM variable to point to your platform DSA files.

  1. To obtain the AWS platform DSA files make sure you have cloned aws-fpga github repository and followed the setup instructions.

Running the Demo

To run the demo you first have to download the dataset upon which we will evaluate our model. Then you are going to setup the environment for compiling the host application for the C++ case. For the Java implementation we use maven to build the project so maven needs to be installed in your system. By default the jars will be generated under $HOME/jars directory. You can change that by modifying the provided pom.xml file. For the python case you will need to have installed python version 3 as well as the python3 package installer.

  • Download Necessary Datasets:
    Create a folder called data under your home directory and download there MNIST letters dataset

     mkdir ~/data
     wget https://s3.amazonaws.com/inaccel-demo/data/nist/letters_csv_train.dat -O ~/data/letters_csv_train.dat
  • Setup Inaccel and Coral API

InAccel Coral

The host code sends requests for acceleration to Coral FPGA Resource Manager through the Coral API. To use Coral please follow the instructions below. You can find full documentation in InAccel Docs.

  1. Install InAccel CLI.
  2. Setup your Environment.
  3. Install Coral API.
  4. Install Coral API for python:
    pip3 install coral-api
  5. Install the bitstreams you are going to use with Coral.
    • To install the pre-compiled bitstream for NaiveBayes Classification found in our bitstream repository simply execute the following:
       inaccel install https://store.inaccel.com/artifactory/bitstreams/xilinx/aws-vu9p-f1/dynamic_5.0/com/inaccel/ml/NaiveBayes/1.0/4Classifier
    • To install your newly compiled bitstream do the following:
      1. Create a folder. Download into this folder the bitstream.json file from our bitstream repository, that fully describes the design of the generated bitstream (number and names of kernels, number of each kernel's arguments etc.)
        wget https://store.inaccel.com/artifactory/bitstreams/xilinx/aws-vu9p-f1/dynamic_5.0/com/inaccel/ml/NaiveBayes/1.0/4Classifier/bitstream.json
      2. Copy the generated xcblin file (after you have completed the Amazon AFI creation procedure) to the folder you created. Make sure that the name of the copied file is NaiveBayes.xclbin
      3. Install the bitstream to the Coral FPGA Manager. Give the (relative or absolute) path of the folder you created in the inaccel install command.
        inaccel install <path/to/folder_name>
  6. Execute inaccel list to make sure that the bitstream is installed successfully.
  7. Start InAccel Coral:
    inaccel start
  8. Compile the demo application:
    For the C++ CPU only version execute make while for the FPGA-accelerated one execute make host. For the Java version use maven as described above, while for python use python3 executable.
  9. Run the demo application:
    For the C++ implementation the executable takes 2 arguments as input. The number of threads to execute the classification on software and whether you want to run classification on CPU or FPGA.
    ./NaiveBayes 8 1
    For the Java implementation the command is the following. It adds all required classes to classpath and invokes java binary with NaiveBayesTest as the main class.
    classpath=''; \
    for jar in `ls ${HOME}/jars/*.jar`; do classpath+=:${jar}; done; \
    java -cp ${classpath} NaiveBayesTest
    And for the Python implementation:
    python3 NaiveBayesTest

naivebayes's People

Contributors

jstamel avatar

Stargazers

 avatar

Watchers

 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.