Class: NeuralNetwork::Connection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, target) ⇒ Connection

Returns a new instance of Connection.



5
6
7
8
9
# File 'lib/neural_network/connection.rb', line 5

def initialize(source, target)
  @source = source # neuron
  @target = target # neuron
  @weight = 0.4 # rand
end

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#targetObject

Returns the value of attribute target.



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

def target
  @target
end

#weightObject

Returns the value of attribute weight.



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

def weight
  @weight
end

Instance Method Details

#to_sObject



11
12
13
# File 'lib/neural_network/connection.rb', line 11

def to_s
  "Connection: #{@source} #{@target} #{@weight}"
end