Class: Phren::Layer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length, id) ⇒ Layer

Returns a new instance of Layer.



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

def initialize(length, id)
  @length = length
  @id = id # num of layer starting from 0. if it's negative neurons are bias
  @neurons = Array.new(@length) { |i|
    Neuron.new(@id < 0 ? 1 : 0,[@id, i])
  }
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/layer.rb', line 5

def id
  @id
end

#lengthObject (readonly)

Returns the value of attribute length.



5
6
7
# File 'lib/layer.rb', line 5

def length
  @length
end

#neuronsObject (readonly)

Returns the value of attribute neurons.



5
6
7
# File 'lib/layer.rb', line 5

def neurons
  @neurons
end