Class: Newral::Networks::Layer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier: nil) ⇒ Layer

Returns a new instance of Layer.



6
7
8
9
# File 'lib/newral/networks/layer.rb', line 6

def initialize( identifier: nil )
    @identifier = identifier
    @neurons = []
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



4
5
6
# File 'lib/newral/networks/layer.rb', line 4

def identifier
  @identifier
end

#neuronsObject (readonly)

Returns the value of attribute neurons.



4
5
6
# File 'lib/newral/networks/layer.rb', line 4

def neurons
  @neurons
end

Instance Method Details

#add_neuron(neuron) ⇒ Object



11
12
13
# File 'lib/newral/networks/layer.rb', line 11

def add_neuron( neuron )
  @neurons << neuron 
end

#biasesObject



19
20
21
# File 'lib/newral/networks/layer.rb', line 19

def biases 
  neurons.collect(&:bias)
end

#outputsObject



23
24
25
# File 'lib/newral/networks/layer.rb', line 23

def outputs
  neurons.collect(&:output)
end

#weightsObject



15
16
17
# File 'lib/newral/networks/layer.rb', line 15

def weights 
  @neurons.collect(&:weights).flatten
end