Class: Ai::Neat::Network

Inherits:
Object
  • Object
show all
Defined in:
lib/ai/neat/network.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(models) ⇒ Network

Returns a new instance of Network.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ai/neat/network.rb', line 8

def initialize(models)
  @layers = []

  models.each do |model|
    @layers.push(Layer.new(model[:node_count], model[:node_type], model[:activationfunc]))
  end

  (0..(@layers.count - 2)).each do |i|
    @layers[i].connect(@layers[i + 1].nodes.count)
  end
end

Instance Attribute Details

#layersObject

Returns the value of attribute layers.



6
7
8
# File 'lib/ai/neat/network.rb', line 6

def layers
  @layers
end

Instance Method Details

#feed_forwardObject



20
21
22
23
24
# File 'lib/ai/neat/network.rb', line 20

def feed_forward
  (0..(@layers.count - 2)).each do |i|
    @layers[i].feed_forward(@layers[i + 1])
  end
end