Class: DBMLP

Inherits:
Object
  • Object
show all
Includes:
CreateTestResults, DB, TestResultsParser, Training
Defined in:
lib/db_mlp.rb

Instance Method Summary collapse

Methods included from TestResultsParser

included

Constructor Details

#initialize(db_path, options = {}) ⇒ DBMLP

Returns a new instance of DBMLP.



15
16
17
18
19
20
21
22
# File 'lib/db_mlp.rb', line 15

def initialize(db_path, options={})
  @input_size = options[:inputs]
  @hidden_layers = options[:hidden_layers]
  @number_of_output_nodes = options[:output_nodes]
  @verbose = options[:verbose] || false
  connect_to_db(db_path)
  setup_network
end

Instance Method Details

#feed_forward(input) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/db_mlp.rb', line 24

def feed_forward(input)
  @network.each_with_index do |layer, layer_index|
    layer.each do |neuron|
      if layer_index == 0
        neuron.fire(input)
      else
        input = @network[layer_index-1].map {|x| x.last_output}
        neuron.fire(input)
      end
    end
  end
  @network.last.map {|x| x.last_output}
end

#inspectObject



43
44
45
# File 'lib/db_mlp.rb', line 43

def inspect
  @network
end

#train(training, testing, validations, n = 3000, report_path = nil) ⇒ Object



38
39
40
41
# File 'lib/db_mlp.rb', line 38

def train(training, testing, validations, n=3000, report_path=nil)
  train_and_cross_validate(training, validations, n)
  create_test_report(testing, report_path) unless report_path.nil?
end