Class: DBMLP
- Inherits:
-
Object
- Object
- DBMLP
- Includes:
- CreateTestResults, DB, TestResultsParser, Training
- Defined in:
- lib/db_mlp.rb
Instance Method Summary collapse
- #feed_forward(input) ⇒ Object
-
#initialize(db_path, options = {}) ⇒ DBMLP
constructor
A new instance of DBMLP.
- #inspect ⇒ Object
- #train(training, testing, validations, n = 3000, report_path = nil) ⇒ Object
Methods included from TestResultsParser
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, ={}) @input_size = [:inputs] @hidden_layers = [:hidden_layers] @number_of_output_nodes = [:output_nodes] @verbose = [: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 |
#inspect ⇒ Object
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 |