4 releases
new 0.2.1 | Jan 10, 2025 |
---|---|
0.2.0 | Jan 3, 2025 |
0.1.1 | Dec 30, 2024 |
0.1.0 | Dec 29, 2024 |
#320 in Machine learning
485 downloads per month
79KB
2.5K
SLoC
gann
Generic ANN - simple back-propagation generic based dense ANN
Usage
The library provides macro ann!
for simplify ann creation:
let ann = ann!(10, SigmoidLayer, 2, SigmoidLayer, 1, CrossEntropyLoss);
Where first argument must be a number of scalars in input vector. After you can set type of next layer and number of neurons in it if layer has them (SoftMaxLayer for example has no neurons). Repeat as many times as many layers you want to have. At the end you must have a "fake" layer that is responsible for calculating first gradient from ANN output and desired scores for back-propagation.
After that ANN can be train with train
method that requires
3 arguments: input data sample, desired output and learning rate.
NOTE: for processing a dataset just use the method in a loop.
After training you can convert the ANN to string. Also you
can restore ANN from such string. However for that you need
to define ANN type first. For that the library provides another
macro: ann_type!
:
let ann: ann_type!(10, SigmoidLayer, 1, CrossEntropyLoss) = ann_str.parse().unwrap();
For get predictions from the ANN you can use infer
method that
requires input vector and provide output scores.
Dependencies
~365–500KB