Rust DNN
Create Modular Lightweight Deep Neural Networks in Rust easy
Installation
After running
cargo add Rust_Simple_DNN
Then you must put these in your rust code
use *;
use *;
Current Implemented Layers
Think of layers as building blocks for a neural network. Different Layers process data in different ways. Layers can be trained.
layers:
- Fully connected Dense Layers
FCnew
These are best when doing just straight raw brain processing. Using these combined with activations, it is technically possible to make a mathematical ai for anything. These layers have exponintial more computation when scaled up though.
- Activations
new; //hyperbolic tangent
new; //if activation > 0
new; //Relu with leak
new; //sigmoid
- Convolutions
new;
starting tutorial
This is how you make a neural network that looks like this
Use this code to make it:
//Model/network/AI Definition
let mut net = new;
net.forward_data; //returns the output vector from the Model
After propagating data through, you can then backpropagate your target:
// This parameter is the models target, (aka what you want the ai to output)
net.backward_data; //trains the ai to output 0
The network will store and apply the gradients, so to train the network, all you need to do is repeatedly forward and back-propagate your data in order
//TRAINING LOOP
let mut iteration = 0; //just a counter
while iteration < 5000
//at this point its well trained
Saving and Loading
An example for saving in loading is in examples/saveLoadModel. You have to be using the serde feature on this crate
[]
= { .. features= ["serde"]}
#use this feature to save and load to files
In code, the functions for saving and loading are:
//Some example model you want to save..
let mut net = new;
net.save_weights; //Stores the parameters
let mut loaded_net = new;
loaded_net.load_weights; //loaded net will now produce the same output as net