Class: NEAT::Neuron
- Includes:
- Math, Graph
- Defined in:
- lib/rubyneat/neuron.rb
Overview
Neuron – Basis of all Neat Neuron types.
Normally contains primatives which aids in its own expression, but the details of this remains to be worked out.
Direct Known Subclasses
BasicNeuronTypes::CosineNeuron, BasicNeuronTypes::GaussianNeuron, BasicNeuronTypes::InputNeuron, BasicNeuronTypes::LinearNeuron, BasicNeuronTypes::SigmoidNeuron, BasicNeuronTypes::SineNeuron, BasicNeuronTypes::TanhNeuron
Constant Summary collapse
- @@neuron_types =
List of neuron types defined.
[]
Instance Attribute Summary collapse
-
#genotype ⇒ Object
readonly
Genotype to which we belong.
-
#heirarchy_number ⇒ Object
(assigned by wire!) Heirarchy number in the Genome / Critter We need this to assure we add genes in the proper order.
-
#output ⇒ Object
This is true if this is an output neuron.
-
#trait ⇒ Object
Returns the value of attribute trait.
Attributes inherited from NeatOb
Class Method Summary collapse
- .bias? ⇒ Boolean
- .inherited(clazz) ⇒ Object
-
.input? ⇒ Boolean
Class is is of Input type?.
-
.neuron_types ⇒ Object
List of distinct neuron types (classes).
-
.type_name ⇒ Object
Type names must always be unique for Neurons.
Instance Method Summary collapse
- #bias? ⇒ Boolean
-
#express(instance) ⇒ Object
Function must be implemented by subclasses for phenotype generation.
- #input? ⇒ Boolean
-
#output? ⇒ Boolean
Instantiation is of outout type?.
Methods included from Graph
#<<, #add, #clear_graph, #inputs
Methods inherited from NeatOb
attr_neat, #initialize, log, #log, #to_s
Constructor Details
This class inherits a constructor from NEAT::NeatOb
Instance Attribute Details
#genotype ⇒ Object (readonly)
Genotype to which we belong
19 20 21 |
# File 'lib/rubyneat/neuron.rb', line 19 def genotype @genotype end |
#heirarchy_number ⇒ Object
(assigned by wire!) Heirarchy number in the Genome / Critter We need this to assure we add genes in the proper order. This will be recalculated every time a new neuron is added.
25 26 27 |
# File 'lib/rubyneat/neuron.rb', line 25 def heirarchy_number @heirarchy_number end |
#output ⇒ Object
This is true if this is an output neuron.
28 29 30 |
# File 'lib/rubyneat/neuron.rb', line 28 def output @output end |
#trait ⇒ Object
Returns the value of attribute trait.
20 21 22 |
# File 'lib/rubyneat/neuron.rb', line 20 def trait @trait end |
Class Method Details
.bias? ⇒ Boolean
43 |
# File 'lib/rubyneat/neuron.rb', line 43 def self.bias? ; false ; end |
.inherited(clazz) ⇒ Object
49 50 51 |
# File 'lib/rubyneat/neuron.rb', line 49 def self.inherited(clazz) @@neuron_types << clazz end |
.input? ⇒ Boolean
Class is is of Input type?
40 |
# File 'lib/rubyneat/neuron.rb', line 40 def self.input? ; false ; end |
.neuron_types ⇒ Object
List of distinct neuron types (classes)
54 |
# File 'lib/rubyneat/neuron.rb', line 54 def self.neuron_types; @@neuron_types ; end |
.type_name ⇒ Object
Type names must always be unique for Neurons. TODO: Enforce uniqueness in neural type names
35 36 37 |
# File 'lib/rubyneat/neuron.rb', line 35 def self.type_name @type_name ||= self.to_s.split('::').last.split('Neuron').first.downcase end |
Instance Method Details
#bias? ⇒ Boolean
44 |
# File 'lib/rubyneat/neuron.rb', line 44 def bias? ; self.class.bias? ; end |
#express(instance) ⇒ Object
Function must be implemented by subclasses for phenotype generation. Basically, an instance is passed to this function and it will add a function to sum all inputs and a apply an operator to the sum.
60 61 62 |
# File 'lib/rubyneat/neuron.rb', line 60 def express(instance) raise NeatException.new "express() must be implemented by subclass." end |
#input? ⇒ Boolean
41 |
# File 'lib/rubyneat/neuron.rb', line 41 def input? ; self.class.input? ; end |
#output? ⇒ Boolean
Instantiation is of outout type?
47 |
# File 'lib/rubyneat/neuron.rb', line 47 def output? ; !!@output ; end |