0.0
No commit activity in last 3 years
No release in over 3 years
Multi-Layer Perceptron Neural Network 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

Multi-Layer Perceptron Neural Network¶ ↑

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.

Install¶ ↑

gem sources -a http://gems.github.com
sudo gem install reddavis-mlp

How To Use¶ ↑

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}"

Benchmarks¶ ↑

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)

Thanks¶ ↑

Copyright © 2009 Red Davis. See LICENSE for details.