Class | Ai4r::NeuralNetwork::Hopfield |
In: |
lib/ai4r/neural_network/hopfield.rb
|
Parent: | Object |
A Hopfield Network is a recurrent Artificial Neural Network. Hopfield nets are able to memorize a set of patterns, and then evaluate an input, returning the most similar stored pattern (although convergence to one of the stored patterns is not guaranteed). Hopfield nets are great to deal with input noise. If a system accepts a discrete set of inputs, but inputs are subject to noise, you can use a Hopfield net to eliminate noise and identified the given input.
data_set = Ai4r::Data::DataSet.new :data_items => array_of_patterns net = Ai4r::NeuralNetworks::Hopfield.new.train data_set net.eval input => one of the stored patterns in array_of_patterns
nodes | [R] | |
weights | [R] |
Propagates the input until the network returns one of the memorized patterns, or a maximum of "eval_iterations" times.
Create a partial weigth matrix:
[ [w(1,0)], [w(2,0)], [w(2,1)], [w(3,0)], [w(3,1)], [w(3,2)], ... [w(n-1,0)], [w(n-1,1)], [w(n-1,2)], ... , [w(n-1,n-2)] ]
where n is the number of nodes.
We are saving memory here, as:
Use read_weight(i,j) to find out weight between node i and j
read_weight(i,j) reads the weigth matrix and returns weight between node i and j