#neural-network #neural #network

brainy

A library for neural networks

6 releases

0.2.3 Sep 29, 2022
0.2.2 Sep 29, 2022
0.1.1 Sep 23, 2022

#478 in Machine learning

MIT license

11KB
277 lines

The library can make very basic feedforward neural networks. Learning hasn't been implemented yet. Library still needs a lot of work.

In brainy a layer struct represents a layer of the neural network (excluding the output layer) and a map to the next layer. For now the activation function is treated as a seperate map from something like matrix multiplication. That way, one can "mix and match" different maps.

A description of the underlying math and a deeper explanation of the code can be found here:

https://thefrogblog.xyz/neural-network-1/

https://thefrogblog.xyz/neural-network-2/

https://thefrogblog.xyz/neural-network-3/

Some example code:

extern crate brainy;
use brainy::matrix::Matrix;
use brainy::layer::Map;
use brainy::network::Network;

fn main()
{
let mut network = Network::new();
network.append_layer(Map::MatrixMultiply(4,3));
network.append_layer(Map::Sigmoid(3));
network.append_layer(Map::MatrixMultiply(3,2));

let input = vec![0.0, 1.0, 1.0, 0.5];
let x = Matrix { rows: input.len(),  cols: 1, elements: input };

let y = network.feedforward(x);
y.print();
}

Dependencies

~315KB