15 Star 33 Fork 9

Gitee 极速下载 / Tinn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/glouw/tinn
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Tinn (Tiny Neural Network) is a 200 line dependency free neural network library written in C99.

For a demo on how to learn hand written digits, get some training data:

wget http://archive.ics.uci.edu/ml/machine-learning-databases/semeion/semeion.data

make; ./test

The training data consists of hand written digits written both slowly and quickly. Each line in the data set corresponds to one handwritten digit. Each digit is 16x16 pixels in size giving 256 inputs to the neural network.

At the end of the line 10 digits signify the hand written digit:

0: 1 0 0 0 0 0 0 0 0 0
1: 0 1 0 0 0 0 0 0 0 0
2: 0 0 1 0 0 0 0 0 0 0
3: 0 0 0 1 0 0 0 0 0 0
4: 0 0 0 0 1 0 0 0 0 0
...
9: 0 0 0 0 0 0 0 0 0 1

This gives 10 outputs to the neural network. The test program will output the accuracy for each digit. Expect above 99% accuracy for the correct digit, and less that 0.1% accuracy for the other digits.

Features

  • Portable - Runs where a C99 or C++98 compiler is present.

  • Sigmoidal activation.

  • One hidden layer.

Tips

  • Tinn will never use more than the C standard library.

  • Tinn is great for embedded systems. Train a model on your powerful desktop and load it onto a microcontroller and use the analog to digital converter to predict real time events.

  • The Tinn source code will always be less than 200 lines. Functions externed in the Tinn header are protected with the xt namespace standing for externed tinn.

  • Tinn can easily be multi-threaded with a bit of ingenuity but the master branch will remain single threaded to aid development for embedded systems.

  • Tinn does not seed the random number generator. Do not forget to do so yourself.

  • Always shuffle your input data. Shuffle again after every training iteration.

  • Get greater training accuracy by annealing your learning rate. For instance, multiply your learning rate by 0.99 every training iteration. This will zero in on a good learning minima.

Disclaimer

Tinn is a practice in minimalism.

Tinn is not a fully featured neural network C library like Kann, or Genann:

https://github.com/attractivechaos/kann

https://github.com/codeplea/genann

Ports

Rust: https://github.com/dvdplm/rustinn

Other

A Tutorial using Tinn NN and CTypes

Tiny Neural Network Library in 200 Lines of Code

MIT License Copyright (c) 2018 Gustav Louw Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Tinn 是一个用 C99 编写的仅有 200 行代码微型神经网络库,无依赖,轻量级 展开 收起
C/C++ 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C/C++
1
https://gitee.com/mirrors/Tinn.git
git@gitee.com:mirrors/Tinn.git
mirrors
Tinn
Tinn
master

搜索帮助