Class: SimpleNeuralNetwork::Neuron
- Inherits:
-
Object
- Object
- SimpleNeuralNetwork::Neuron
- Defined in:
- lib/neuron.rb
Instance Attribute Summary collapse
-
#bias ⇒ Object
Returns the value of attribute bias.
-
#edges ⇒ Object
A neuron’s edges connect it to the #layerlayer.next_layerlayer.next_layer.size neurons of the next layer.
Instance Method Summary collapse
-
#initialize(layer:) ⇒ Neuron
constructor
A new instance of Neuron.
-
#initialize_edges(next_layer_size) ⇒ Object
A neuron should have one edge per neuron in the next layer.
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
#bias ⇒ Object
Returns the value of attribute bias.
3 4 5 |
# File 'lib/neuron.rb', line 3 def bias @bias end |
#edges ⇒ Object
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 |