Class: Neuronet::MiddleNeuron
- Inherits:
-
Object
- Object
- Neuronet::MiddleNeuron
- Includes:
- Backpropagate, NeuronStats, Squash
- Defined in:
- lib/neuronet/middle_neuron.rb
Overview
Middle Neuron
Direct Known Subclasses
Instance Attribute Summary collapse
-
#activation ⇒ Object
readonly
Returns the value of attribute activation.
-
#bias ⇒ Object
Returns the value of attribute bias.
-
#connections ⇒ Object
readonly
Returns the value of attribute connections.
Instance Method Summary collapse
- #connect(neuron, weight = 0.0) ⇒ Object
-
#initialize ⇒ MiddleNeuron
constructor
A new instance of MiddleNeuron.
- #update ⇒ Object
- #value ⇒ Object
Methods included from Squash
Methods included from Backpropagate
Methods included from NeuronStats
#downstream_params_tally, #mju, #nju
Constructor Details
#initialize ⇒ MiddleNeuron
Returns a new instance of MiddleNeuron.
10 11 12 13 14 |
# File 'lib/neuronet/middle_neuron.rb', line 10 def initialize @activation = 0.5 @bias = 0.0 @connections = [] end |
Instance Attribute Details
#activation ⇒ Object (readonly)
Returns the value of attribute activation.
17 18 19 |
# File 'lib/neuronet/middle_neuron.rb', line 17 def activation @activation end |
#bias ⇒ Object
Returns the value of attribute bias.
16 17 18 |
# File 'lib/neuronet/middle_neuron.rb', line 16 def bias @bias end |
#connections ⇒ Object (readonly)
Returns the value of attribute connections.
17 18 19 |
# File 'lib/neuronet/middle_neuron.rb', line 17 def connections @connections end |
Instance Method Details
#connect(neuron, weight = 0.0) ⇒ Object
19 20 21 |
# File 'lib/neuronet/middle_neuron.rb', line 19 def connect(neuron, weight = 0.0) @connections << Connection.new(neuron, weight) end |
#update ⇒ Object
27 28 29 |
# File 'lib/neuronet/middle_neuron.rb', line 27 def update @activation = squash(value) end |
#value ⇒ Object
23 24 25 |
# File 'lib/neuronet/middle_neuron.rb', line 23 def value @bias + @connections.sum(&:value) end |