Class: Neuronet::Connection
- Inherits:
-
Object
- Object
- Neuronet::Connection
- Defined in:
- lib/neuronet.rb
Overview
A weighted connection to a neuron (or node).
Instance Attribute Summary collapse
-
#node ⇒ Object
Returns the value of attribute node.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
-
#backpropagate(error) ⇒ Object
Adjusts the connection weight according to error and backpropagates the error to the connected node.
-
#initialize(node, weight = 0.0) ⇒ Connection
constructor
A new instance of Connection.
-
#update ⇒ Object
Updates and returns the value of the connection.
-
#value ⇒ Object
The value of a connection is the weighted activation of the connected node.
Constructor Details
#initialize(node, weight = 0.0) ⇒ Connection
Returns a new instance of Connection.
53 54 55 |
# File 'lib/neuronet.rb', line 53 def initialize(node, weight=0.0) @node, @weight = node, weight end |
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
52 53 54 |
# File 'lib/neuronet.rb', line 52 def node @node end |
#weight ⇒ Object
Returns the value of attribute weight.
52 53 54 |
# File 'lib/neuronet.rb', line 52 def weight @weight end |
Instance Method Details
#backpropagate(error) ⇒ Object
Adjusts the connection weight according to error and backpropagates the error to the connected node.
70 71 72 73 |
# File 'lib/neuronet.rb', line 70 def backpropagate(error) @weight += @node.activation * error * Neuronet.noise @node.backpropagate(error) end |
#update ⇒ Object
Updates and returns the value of the connection. Updates the connected node.
64 65 66 |
# File 'lib/neuronet.rb', line 64 def update @node.update * @weight end |
#value ⇒ Object
The value of a connection is the weighted activation of the connected node.
58 59 60 |
# File 'lib/neuronet.rb', line 58 def value @node.activation * @weight end |