easynn
This crate aims to provide neuro network developing and training utilities in rust, where a variety of models and layers are supported.
Note: this crate is currently in beta, any interface is subject to change.
Xor Example
Here we examine an example of building up a 3-layer MLP, learning the xor function of 64 bit integer.
use *;
use Rng;
// the target xor function
let target_func = ;
// create the network and add 4 layers
let mut nn = new;
// add the input (2 integers) and a hidden layer
nn.add;
// add another hidden layer
nn.add;
// add another hidden layer
nn.add;
// add the output layer
nn.add;
// create the training set
let mut rng = thread_rng;
let tot_samples: usize = 1000;
let mut inputs = vec!;
let mut outputs = vec!;
for in inputs.iter_mut.zip
// train the model
for _i in 0..10
// evaluate the model
let test_in1: u32 = 19260817;
let test_in2: u32 = 1145141919;
let test_out: u32 = target_func;
let test_res = nn.predict.unwrap.get;
println!;
Supported models
-
Sequential: similar to The Sequential model of Keras
Supported layer types
- Primitive types:
-
Dense: fully connected layers
-
- CNN types:
-
Conv: the convolution layer -
Pooling: the pooling layer
-
License: MIT