Class: SimpleNeuralNetwork::Neuron

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(layer:) ⇒ Neuron

Returns a new instance of Neuron.



8
9
10
11
12
# File 'lib/neuron.rb', line 8

def initialize(layer:)
  @layer = layer
  @bias = layer.network.neuron_bias_initialization_function.call
  @edges = []
end

Instance Attribute Details

#biasObject

Returns the value of attribute bias.



3
4
5
# File 'lib/neuron.rb', line 3

def bias
  @bias
end

#edgesObject

A neuron’s edges connect it to the #SimpleNeuralNetwork::Neuron.layerlayer.next_layerlayer.next_layer.size neurons of the next layer



6
7
8
# File 'lib/neuron.rb', line 6

def edges
  @edges
end

Instance Method Details

#initialize_edges(next_layer_size) ⇒ Object

A neuron should have one edge per neuron in the next layer



15
16
17
18
19
20
21
# File 'lib/neuron.rb', line 15

def initialize_edges(next_layer_size)
  init_function = @layer.network.edge_initialization_function

  next_layer_size.times do
    @edges << init_function.call
  end
end