No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A very simple neural network implementation in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

SimpleNeuralNetwork

This is a simple neural network implementation in Ruby.

This gem does not include any learning implementations (back-prop, etc).

Installation

gem install simple_neural_network

Sample usage:

Sample Neural Network

The following code implements the above neural network.

require 'simple_neural_network'

network = SimpleNeuralNetwork::Network.new

network.create_layer(neurons: 5)
network.create_layer(neurons: 7)
network.create_layer(neurons: 7)
network.create_layer(neurons: 4)

Neural networks are initialized with random edge weights and zero-valued neuron biases. Edge/bias initialization is configurable by setting the initialization lambdas.

The following code runs an input set against the network.

 network.run([0.5, 0.4, 0.8, 0, 0.9])
 => [0.2257, 0.7488, 0.1016, 0.9935]

Manipulating the network

Setting a neuron bias

network.layers[layer_index].neurons[neuron_index].bias = new_neuron_bias

Setting an edge weight

In SimpleNeuralNetwork, edges point forward and edge weights stored as an array of integers on a Neuron object. To access the edge pointing from a neuron to the n'th neuron in the next layer:

network.layers[layer_index].neurons[neuron_index].edges[n] = new_edge_weight

Improvements / Bugs

Improvements and bugs are listed as issues in the gem repository.