Class: Neuronet::Node

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

Overview

In Neuronet, there are two main types of objects: Nodes and Connections. A Node has a value which the implementation can set. A plain Node instance is used primarily as input neurons, and its value is not changed by training. It is a terminal for backpropagation of errors. Nodes are used for the input layer.

Direct Known Subclasses

Neuron

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val = 0.0) ⇒ Node

Returns a new instance of Node.



59
60
61
# File 'lib/neuronet.rb', line 59

def initialize(val=0.0)
  self.value = val
end

Instance Attribute Details

#activationObject (readonly) Also known as: update

Returns the value of attribute activation.



50
51
52
# File 'lib/neuronet.rb', line 50

def activation
  @activation
end

Instance Method Details

#backpropagate(error) ⇒ Object

Node is a terminal where backpropagation ends.



69
70
71
72
# File 'lib/neuronet.rb', line 69

def backpropagate(error)
  # to be over-ridden
  nil
end

#valueObject

The “real world” value is stored as a squashed activation.



64
65
66
# File 'lib/neuronet.rb', line 64

def value
  Neuronet.unsquash(@activation)
end

#value=(val) ⇒ Object

The “real world” value of a node is the value of it’s activation unsquashed.



55
56
57
# File 'lib/neuronet.rb', line 55

def value=(val)
  @activation = Neuronet.squash(val)
end