neuralegion / crystal-fann Goto Github PK
View Code? Open in Web Editor NEWFANN (Fast Artifical Neural Network) binding in Crystal
License: MIT License
FANN (Fast Artifical Neural Network) binding in Crystal
License: MIT License
Right now the namespace is quite long, we want to keep the repo and shard name crystal-fann , but we can make it more programmers friendly
# Now
Crystal::Fann::Network::Standard
# After
Fann::Network::Standard
Is possible add a function to generate C program without dependencies?
For example I put data, learn in Crystal, but at end I get one simple finction in C
#define WEIGHTS ....
int result(data *input.....)
{
}
ideal for embeded, no dependencies, no load any file. Only put input and get output
make cr
crystal run ./fa2.cr
F-ann5858T-rainD-ata.o: In function `set_train_struct':
/home/xor256/t1a-fann/lib/crystal-fann/src/crystal-fann/train_data.cr:21: undefined reference to `fann_create_train_pointer_array'
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/libdoublefann.so: undefined reference to `sqrtf'
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/libdoublefann.so: undefined reference to `log'
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/libdoublefann.so: undefined reference to `exp'
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/libdoublefann.so: undefined reference to `sin'
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/libdoublefann.so: undefined reference to `pow'
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/libdoublefann.so: undefined reference to `cos'
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/xor256/.cache/crystal/crystal-run-fa2.tmp' -rdynamic -ldoublefann -lpcre /usr/bin/../lib/crystal/lib/libgc.a -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib`
make: *** [Makefile:5: cr] Błąd 1
fedora 30
trouble with simplest in static mode --release --static
/```
usr/bin/ld: cannot find -ldoublefann (this usually means you need to install the development package for libdoublefann)
/usr/bin/ld: cannot find -lpcre (this usually means you need to install the development package for libpcre)
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: cc "${@}" -o '/home/xor/fa1' -rdynamic -static -ldoublefann -lpcre -lm /usr/bin/../lib/crystal/lib/libgc.a -lpthread /usr/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib
@hugoabonizio Wana try and tackle this ?
To allow long runs and reuse of the trained network later, we need to add .save
and .load
options, basically it just uses
fun save = fann_save(ann : Fann*, configuration_file : LibC::Char*) : LibC::Int
fun create_from_file = fann_create_from_file(configuration_file : LibC::Char*) : Fann*
so something along the lines of
def save(path : String) : Int32
LibFANN.save(@ann, path)
end
and something similar for load, crate_from_file
Following a suggestion from #4 and using the crystal naming guidelines
Acronyms
In class names, acronyms are all uppercase. For example, HTTP, and LibXML
We should rename the module name to uppercase , so FANN
After moving to use doublefann
so that input parameters can be Float64
we got some bug with the MSE values, running specs shows
........Max epochs 8000. Desired error: -0.0000000000.
Epochs 1. Current error: 0.2504344881. Bit fail 4.
Epochs 1000. Current error: 0.0000258677. Bit fail 0.
Epochs 2000. Current error: 0.0000260366. Bit fail 0.
Epochs 3000. Current error: 0.0000253705. Bit fail 0.
Epochs 4000. Current error: 0.0000244194. Bit fail 0.
Epochs 5000. Current error: 0.0000170922. Bit fail 0.
Epochs 6000. Current error: 0.0000164790. Bit fail 0.
Epochs 7000. Current error: 0.0000157123. Bit fail 0.
Epochs 8000. Current error: 0.0000215559. Bit fail 0.
.Max neurons 500. Desired error: -0.000000
Where relevant parts are:
Desired error: -0.0000000000
Desired error: -0.000000
Those should have used the configured amount of:
0.001
and
0.1
The Crystal community has somewhat decided to use crystal
as the language's topic.
To avoid fragmentation in the community, please change the crystal-language
topic, that only has ~30 repositories at the moment, to crystal
.
Any contributor can change it from the repo's homepage.
See crystal-lang/crystal#4241 for more context.
Thank you very much :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.