db_mlp 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/db_mlp.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{db_mlp}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["reddavis"]
data/examples/data.rdb CHANGED
Binary file
data/examples/xor.rb CHANGED
@@ -1,8 +1,11 @@
1
- require File.dirname(__FILE__) + '/../lib/db_mlp'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/db_mlp')
2
2
  require 'benchmark'
3
3
 
4
4
  db = "sqlite3://#{File.dirname(File.expand_path(__FILE__))}/data.rdb"
5
- a = DBMLP.new(db, :hidden_layers => [2, 2], :output_nodes => 1, :inputs => 2)
5
+ a = DBMLP.new(db, :hidden_layers => [2],
6
+ :output_nodes => 1,
7
+ :inputs => 2,
8
+ :verbose => true)
6
9
 
7
10
  times = Benchmark.measure do
8
11
 
@@ -12,7 +15,7 @@ times = Benchmark.measure do
12
15
  testing = [[[0,0], [0]], [[0,1], [1]], [[1,0], [1]], [[1,1], [0]]]
13
16
  validation = [[[0,0], [0]], [[0,1], [1]], [[1,0], [1]], [[1,1], [0]]]
14
17
 
15
- a.train(training, testing, validation, 3001)
18
+ a.train(training, testing, validation, 3000)
16
19
 
17
20
  puts "Test data"
18
21
  puts "[0,0] = > #{a.feed_forward([0,0]).inspect}"
data/lib/db_mlp.rb CHANGED
@@ -1,4 +1,4 @@
1
- #require 'rubygems'
1
+ require 'rubygems'
2
2
  require 'datamapper'
3
3
  require File.expand_path(File.dirname(__FILE__) + '/models/neuron')
4
4
  require File.expand_path(File.dirname(__FILE__) + '/modules/create_test_results')
@@ -82,7 +82,7 @@ module Training
82
82
  if layer_index == 0
83
83
  compute_output_deltas(layer, targets)
84
84
  else
85
- compute_hidden_deltas(layer, targets)
85
+ compute_hidden_deltas(layer, targets, reversed_network[layer_index-1])
86
86
  end
87
87
  end
88
88
  end
@@ -94,10 +94,10 @@ module Training
94
94
  end
95
95
  end
96
96
 
97
- def compute_hidden_deltas(layer, targets)
97
+ def compute_hidden_deltas(layer, targets, previous_layer)
98
98
  layer.each_with_index do |neuron, neuron_index|
99
99
  error = 0
100
- @network.last.each do |output_neuron|
100
+ previous_layer.each do |output_neuron|
101
101
  error += output_neuron.delta * output_neuron.weights[neuron_index]
102
102
  end
103
103
  output = neuron.last_output
data/test/test_db_mlp.rb CHANGED
@@ -26,7 +26,7 @@ class TestDBMLP < Test::Unit::TestCase
26
26
  set_data_variables
27
27
  @db_path = "sqlite3://#{File.dirname(File.expand_path(__FILE__))}/db/data.rdb"
28
28
  end
29
-
29
+
30
30
  should "contain 4 layers" do
31
31
  a = DBMLP.new(@db_path, :hidden_layers => [2, 2, 2], :output_nodes => 2, :inputs => 2)
32
32
  assert_equal 4, a.inspect.size
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_mlp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - reddavis