NNRS - Rust Neural Network Library
NNRS is a Rust library for creating and working with feedforward neural networks. It provides a set of tools for building and manipulating neural networks, including creating nodes and edges, setting inputs, and firing the network to generate outputs.
Installation
To use NNRS, simply add it as a dependency to your Rust project with Cargo:
Usage
Note: This section may not be entirely up to date. For more accurate, tested information, see the (https://docs.rs/nnrs)[documentation].
Creating a Network
To create a new neural network, use the Network struct:
use ;
let mut network = default;
This creates a new neural network with a default configuration. (An empty input and output layer). You can also create an empty network
let mut network = empty;
Creating Layers
Layers are used to group nodes together. To create a layer, use the Layer struct:
network.add_layer;
network.add_layer;
network.add_layer;
Creating Nodes
Nodes are the basic building blocks of a neural network. To create a node, use the Node::create method:
let input_node_id = create?;
let hidden_node_id = create?;
let output_node_id = create?;
This creates two nodes, one in the input layer and one in the output layer. The first argument is the network. The second argument is the layer the node should be created in. The third argument is the threshold of the node. An OutputNode's
threshold is ignored.
Creating Edges
Edges represent the connections between nodes in a neural network. To create an edge, use the Edge::create method:
create?;
create?;
create?;
This creates three edges, one going from the input to the output node and a weight of 2.0, and two going from the input to the hidden node and the hidden node to the output node, with weights of 1.3 and 1.5 respectively.
Setting Inputs
To set the inputs of a neural network, use the Network::set_inputs method:
network.set_inputs?;
This sets the input of the input node to 0.8.
Firing the Network
To fire the network, use the Network::fire method:
network.fire?;
Getting Outputs
To get the outputs of a neural network, use the Network::get_outputs method:
let mut output: = Vecnew;
network.read?;
This gets the output of the output node and stores it in the output vector.
Serializing and Deserializing
To serialize a network, use the Network::serialize method:
let serialized: String = network.serialize?;
To deserialize a network, use the Network::deserialize method:
let mut network: Network = deserialized?;
To a file
To serialize a network to a file, use the Network::save method:
network.save?;
To deserialize a network from a file, use the Network::load method:
let mut network: Network = load?;
Limitations
At this moment, NNRS does not include training functionality. You can use this library to generate outputs from pre-trained networks.
Roadmap
- Basic Parts
- Generating Outputs
- Serialization
- Training (NEAT?)
License
NNRS is licensed under the AGPLv3 license. See the LICENSE file for more
information.