Class: RANN::Connection
- Inherits:
-
Object
- Object
- RANN::Connection
- Defined in:
- lib/rann/connection.rb
Direct Known Subclasses
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(input_neuron, output_neuron, weight = nil) ⇒ Connection
constructor
A new instance of Connection.
- #locked? ⇒ Boolean
- #neurons ⇒ Object
- #process ⇒ Object
- #processable? ⇒ Boolean
- #processed? ⇒ Boolean
- #reset! ⇒ Object
Constructor Details
#initialize(input_neuron, output_neuron, weight = nil) ⇒ Connection
Returns a new instance of Connection.
16 17 18 19 20 21 22 23 24 |
# File 'lib/rann/connection.rb', line 16 def initialize input_neuron, output_neuron, weight = nil @id = SecureRandom.hex @output_neuron = output_neuron @input_neuron = input_neuron @weight = weight || initial_weight @processed = false @enabled = true @locked = false end |
Instance Method Details
#enabled? ⇒ Boolean
42 43 44 |
# File 'lib/rann/connection.rb', line 42 def enabled? enabled end |
#locked? ⇒ Boolean
50 51 52 |
# File 'lib/rann/connection.rb', line 50 def locked? @locked end |
#neurons ⇒ Object
34 35 36 |
# File 'lib/rann/connection.rb', line 34 def neurons [output_neuron, input_neuron] end |
#process ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rann/connection.rb', line 26 def process if processable? && !processed? out_value = input_neuron.value * weight output_neuron.push_value! out_value @processed = true end end |
#processable? ⇒ Boolean
38 39 40 |
# File 'lib/rann/connection.rb', line 38 def processable? input_neuron.value end |
#processed? ⇒ Boolean
46 47 48 |
# File 'lib/rann/connection.rb', line 46 def processed? processed end |
#reset! ⇒ Object
54 55 56 |
# File 'lib/rann/connection.rb', line 54 def reset! @processed = false end |