Giter Site home page Giter Site logo

xilinx_fpga_hls-mapping-neural-network-to-hardware's Introduction

示例:如何将目标检测算法YOLOv2映射到Xilinx FPGA Zedboard

由于目前处于Deadline时期,要等下个礼拜才有时间把完整的整个流程在Github上分享一下,现在只能先用中文简单描述一下整个流程:从Darknet 框架中的YOLOv2模型到最终生成bitstream的过程。
(1)需要先从Darknet官网下载darknet框架,然后将其中YOLOv2的权重提取出来。由于YOLOv2的卷积层基本都会跟着BatchNormalization,所以在提取权重的过程中,就将YOLOv2中的weight和bias分别和对应的BN乘在一起具体公式可以参考文献[1],公式如下:
y=(x-bn0)/sqrt(bn1) (1)
z=sc0y+sc1 (2)
所以,可以将(1)与(2)合并,得到:
y=A
x+B (3)
其中 A= sc0/sqpr(bn1), B=sc1-sc0*bn0/sqrt(bn1)
这部分代码放在framework目录下

参考文献:
[1] An Automatic RTL Compiler for High-Throughput FPGA Implementation of Diverse Deep Convolutional Neural Networks

xilinx_fpga_hls-mapping-neural-network-to-hardware's People

Contributors

dhm2013724 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xilinx_fpga_hls-mapping-neural-network-to-hardware's Issues

some errors happened when I used the weights.bin and bias.bin in jupter notebook

hello~
when I applied the files(weights.bin and bias.bin) to the jupyter notebook, it appeared an error:
could not broadcast input array from shape (50941792) into shape (25470896). Then I changed the shape (25470896) into shape (50941792), but it appeared another error:Failed to allocate Memory!
Can you help me?
The codes I changed are as follows:

weight_base_buffer = xlnk.cma_array(shape=(25470896,), dtype=np.uint32)

weight_base_buffer = xlnk.cma_array(shape=(50941792,), dtype=np.uint32)
print("100M",weight_base_buffer.physical_address)
WEIGHT_BASE = weight_base_buffer.physical_address

bate_base_buffer = xlnk.cma_array(shape=(5381,), dtype=np.uint32)
print("32k",bate_base_buffer.physical_address)
BETA_BASE=bate_base_buffer.physical_address

img_base_buffer = xlnk.cma_array(shape=(4194304,), dtype=np.int32)
print("16M",img_base_buffer.physical_address)
IMG_MEM = img_base_buffer.physical_address
params_wight = np.fromfile("weights.bin", dtype=np.uint32)
np.copyto(weight_base_buffer, params_wight)
print("yolov2_weight copy ok\n")

params_bais = np.fromfile("bias.bin", dtype=np.uint32)
np.copyto(bate_base_buffer, params_bais)
print("yolov2_bais copy ok\n")

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.