Class: DBMLP

Inherits:
Object
  • Object
show all
Defined in:
lib/db_mlp.rb

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DBMLP.



7
8
9
10
11
12
13
# File 'lib/db_mlp.rb', line 7

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

Instance Method Details

#feed_forward(input) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/db_mlp.rb', line 15

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



33
34
35
# File 'lib/db_mlp.rb', line 33

def inspect
  @network
end

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



29
30
31
# File 'lib/db_mlp.rb', line 29

def train(training, testing, validations, n=3000)
  train_and_cross_validate(training, validations, n)
end