• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

nnom: NNoM是一个专门为了神经网络在 MCU 上运行的框架。 NNoM 是一个定点神经网络库 ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

nnom

开源软件地址:

https://gitee.com/RT-Thread-Mirror/nnom

开源软件介绍:

Neural Network on Microcontroller (NNoM)

Build StatusLicenseDOI

NNoM is a high-level inference Neural Network library specifically for microcontrollers.

[English Manual] [中文简介]

Highlights

  • Deploy Keras model to NNoM model with one line of code.
  • Support complex structures; Inception, ResNet, DenseNet, Octave Convolution...
  • User-friendly interfaces.
  • High-performance backend selections.
  • Onboard pre-compiling - zero interpreter performance loss at runtime.
  • Onboard evaluation tools; Runtime analysis, Top-k, Confusion matrix...

The structure of NNoM is shown below:

More detail avaialble in Development Guide

Discussions welcome using issues.Pull request welcome. QQ/TIM group: 763089399.

Latest Updates - v0.4.x

Recurrent Layers (RNN) (0.4.1)

Recurrent layers (Simple RNN, GRU, LSTM) are implemented in version 0.4.1. Support statful and return_sequence options.

New Structured Interface (0.4.0)

NNoM has provided a new layer interface called Structured Interface, all marked with _s suffix. which aims to use one C-structure to provided all the configuration for a layer. Different from the Layer API which is human friendly, this structured API are more machine friendly.

Per-Channel Quantisation (0.4.0)

The new structred API supports per-channel quantisation (per-axis) and dilations for Convolutional layers.

New Scripts (0.4.0)

From 0.4.0, NNoM will switch to structured interface as default to generate the model header weights.h. The scripts corresponding to structured interfaces are nnom.py while the Layer Interface corresponding to nnom_utils.py.

Licenses

NNoM is released under Apache License 2.0 since nnom-V0.2.0.License and copyright information can be found within the code.

Why NNoM?

The aims of NNoM is to provide a light-weight, user-friendly and flexible interface for fast deploying on MCU.

Nowadays, neural networks are wider, deeper, and denser.

[1] Szegedy, C., Liu, W., Jia, Y., Sermanet, P., Reed, S., Anguelov, D., ... & Rabinovich, A. (2015). Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 1-9).

[2] He, K., Zhang, X., Ren, S., & Sun, J. (2016). Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 770-778).

[3] Huang, G., Liu, Z., Van Der Maaten, L., & Weinberger, K. Q. (2017). Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 4700-4708).

After 2014, the development of Neural Networks are more focus on structure optimising to improve efficiency and performance, which is more important to the small footprint platforms such as MCUs.However, the available NN libs for MCU are too low-level which make it sooooo difficult to use with these complex strucures.

Therefore, we build NNoM to help embedded developers for faster and simpler deploying NN model directly to MCU.

NNoM will manage the strucutre, memory and everything else for the developer. All you need to do is feeding your new measurements and getting the results.

Documentations

Guides

5 min to NNoM Guide

The temporary guide

Porting and optimising Guide

RT-Thread Guide(Chinese)

RT-Thread-MNIST example (Chinese)

Performance

There are many articles compared NNoM with other famous MCU AI tools, such as TensorFlow LiteSTM32Cube.AI .etc.

Raphael Zingg etc from Zurich University of Applied Sciences compare nnom with tflite, cube, and e-Ai in their paper "Artificial Intelligence on Microcontrollers" blog https://blog.zhaw.ch/high-performance/2020/05/14/artificial-intelligence-on-microcontrollers/

performance-comparison-tflite-cubeai-eai

Butt Usman Ali from POLITECNICO DI TORINO, did below comparison in the thesis: On the deployment of Artificial Neural Networks (ANN) in lowcost embedded systems

performance-comparison-tflite-cubeai

Both articles shows that NNoM is not only comparable with other popular NN framework but with faster inference time and sometime less memory footprint.

Note: These graphs and tables are credited to their authors. Please refer the their original papers for details and copyright.

Examples

Documented examples

Please check examples and choose one to start with.

Available Operations

[API Manual]

*Notes: NNoM now supports both HWC and CHW formats. Some operation might not support both format currently. Please check the tables for the current status. *

Core Layers

LayersStruct APILayer APIComments
Convolutionconv2d_s()Conv2D()Support 1/2D, support dilations (New!)
ConvTransposed (New!)conv2d_trans_s()Conv2DTrans()Under Dev.
Depthwise Convdwconv2d_s()DW_Conv2D()Support 1/2D
Fully-connecteddense_s()Dense()
Lambdalambda_s()Lambda()single input / single output anonymous operation
Batch NormalizationN/AN/AThis layer is merged to the last Conv by the script
Flattenflatten_s()Flatten()
Reshape (New!)reshape_s()N/A
SoftMaxsoftmax_s()SoftMax()Softmax only has layer API
ActivationN/AActivation()A layer instance for activation
Input/Outputinput_s()/output_s()Input()/Output()
Up Samplingupsample_s()UpSample()
Zero Paddingzeropadding_s()ZeroPadding()
Croppingcropping_s()Cropping()

RNN Layers

LayersStatusStruct APIComments
Recurrent NN Layer(New!)Alpharnn_s()Layer wrapper of RNN
Simple Cell (New!)Alphasimple_cell_s()
GRU Cell (New!)Alphagru_cell_s()Gated Recurrent Network
LSTM Cell (New!)Alphalstm_s()Long Short-Term Memory

Activations

Activation can be used by itself as layer, or can be attached to the previous layer as "actail" to reduce memory cost.

There is no structred API for activation currently, since activation are not usually used as a layer.

ActrivationStruct APILayer APIActivation APIComments
ReLUN/AReLU()act_relu()
Leaky ReLU (New!)N/ALeakyReLU()act_leaky_relu()
Adv ReLU(New!)N/AN/Aact_adv_relu()advance ReLU, Slope, max, threshold
TanHN/ATanH()act_tanh()
Hard TanH (New!)N/ATanH()backend only
SigmoidN/ASigmoid()act_sigmoid()
Hard Sigmoid (New!)N/AN/AN/Abackend only

Pooling Layers

PoolingStruct APILayer APIComments
Max Poolingmaxpool_s()MaxPool()
Average Poolingavgpool_s()AvgPool()
Sum Poolingsumpool_s()SumPool()
Global Max Poolingglobal_maxpool_s()GlobalMaxPool()
Global Average Poolingglobal_avgpool_s()GlobalAvgPool()
Global Sum Poolingglobal_sumpool_s()GlobalSumPool()dynamic output shift

Matrix Operations Layers

MatrixStruct APILayer APIComments
Concatenateconcat_s()Concat()Concatenate through any axis
Multiplemult_s()Mult()
Additionadd_s()Add()
Substractionsub_s()Sub()

Dependencies

NNoM now use the local pure C backend implementation by default. Thus, there is no special dependency needed.

However, You will need to enable libc for dynamic memory allocation malloc(), free(), and memset(). Or you can port to the equivalent memory method in your system.

Optimization

CMSIS-NN/DSP is an optimized backend for ARM-Cortex-M4/7/33/35P. You can select it for up to 5x performance compared to the default C backend. NNoM will use the equivalent method in CMSIS-NN if the condition met.

Please check Porting and optimising Guide for detail.

Known Issues

The Converter do not support implicitly defined activations

The script currently does not support implicit act:

x = Dense(32, activation="relu")(x)

Use the explicit activation instead.

x = Dense(32)(x)x = Relu()(x)

Tips - improving accuracy

  • Attaching an BatchNormalization after each convolutional layer limit the activation range thus help quantisation. BN add no extra computation in NNoM.
  • Dont train too much epoch. Large epoch number increases extreme number in activation -> lower the quantisation resolution.
  • Leave enough data for bottleneck - do not compress data at before the output of a model, infomation will be lost when it is quantised.

Contacts

Jianjia Ma[email protected]

Also find me for field supports.

Citation are required in publication

Please contact me using above details if you have any problem.

Example:

@software{jianjia_ma_2020_4158710,  author       = {Jianjia Ma},  title        = {{A higher-level Neural Network library on Microcontrollers (NNoM)}},  month        = oct,  year         = 2020,  publisher    = {Zenodo},  version      = {v0.4.2},  doi          = {10.5281/zenodo.4158710},  url          = {https://doi.org/10.5281/zenodo.4158710}}

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
CoolNLTK: Automatic Text Categorization by deep learning发布时间:2022-03-24
下一篇:
eat_tensorflow2_in_30_days: Tensorflow2发布时间:2022-03-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap