I built this to not only learn about the MLP but to also make a very simple, well laid out MLP so other can easily see what’s happening.
I also suggest checking out bit.ly/XEWOc for a great tutorial.
gem sources -a http://gems.github.com sudo gem install reddavis-mlp
require 'rubygems' require 'mlp' a = MLP.new(:hidden_layers => [2], :output_nodes => 1, :inputs => 2) 3001.times do |i| a.train([0,0], [0]) a.train([0,1], [1]) a.train([1,0], [1]) error = a.train([1,1], [0]) puts "Error after iteration #{i}:\t#{error}" if i%200 == 0 end puts "Test data" puts "[0,0] = > #{a.feed_forward([0,0]).inspect}" puts "[0,1] = > #{a.feed_forward([0,1]).inspect}" puts "[1,0] = > #{a.feed_forward([1,0]).inspect}" puts "[1,1] = > #{a.feed_forward([1,1]).inspect}"
The above example produces these times user system total real MLP 0.820000 0.000000 0.820000 ( 0.837693) Ai4R 1.180000 0.010000 1.190000 ( 1.232388)
-
David Richards - For his code reviews and all round helpfulness. - github.com/davidrichards
Copyright © 2009 Red Davis. See LICENSE for details.