Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/elftausend/forward

A feed-forward-only neural network library, planned for embedded devices
https://github.com/elftausend/forward

compile-time const embedded embedded-devices fixed-size-array forward-propagation neural-network no-std rust

Last synced: about 1 month ago
JSON representation

A feed-forward-only neural network library, planned for embedded devices

Awesome Lists containing this project

README

        

# forward

A feed-forward-only neural network library written in Rust, which uses fixed-size arrays.

## Example array-operations

```rust
use forward::{Forward, Sum, Transpose};

fn main() {
//1x3 Matrix
let x = [2, 1, 3];
//3x2 Matrix
let y = [3, 1,
3, 6,
5, 3];

//vector(or 1 by x-matrix)-matrix multiply
//..Forward::..
let output = Forward::::forward(&x, &y);
assert_eq!(output, [24, 17]);

//sum all elements
let sum = Sum::compute(&output);
assert_eq!(sum, 41);

//swap rows and cols
let transposed = Transpose::<_, 3, 2, 6>::compute(&y);
assert_eq!(transposed, [3, 3, 5,
1, 6, 3]);

}
```

## Example neural network

This is a neural network, which was trained to fit a sine wave.

```rust

use forward::{Linear, activation::{None, ReLU}, sine_net::{BIAS1, BIAS2, BIAS3, LAYER1, LAYER2, LAYER3}};

fn main() {
let linear1 = Linear::::new(LAYER1, BIAS1);
let linear2 = Linear::::new(LAYER2, BIAS2);
let linear3 = Linear::::new(LAYER3, BIAS3);

let input = [0.555];

let x = linear1.forward(&input);
let x = linear2.forward(&x);
let x = linear3.forward(&x);

println!("predicted: {:?}", x);
}

```