Class: NEAT::BasicNeuronTypes::GaussianNeuron

Inherits:
Neuron
  • Object
show all
Defined in:
lib/rubyneat/neuron.rb

Overview

Gaussian function (CPPN) – SD 1 of inputs

Instance Attribute Summary

Attributes inherited from Neuron

#genotype, #heirarchy_number, #output, #trait

Attributes inherited from NeatOb

#controller, #name

Instance Method Summary collapse

Methods inherited from Neuron

#bias?, bias?, inherited, input?, #input?, neuron_types, #output?, type_name

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 Method Details

#express(instance) ⇒ Object

create a function on the instance with our name that sums all inputs and produce a gaussian of standard deviation of 1.



172
173
174
175
176
177
178
179
180
181
# File 'lib/rubyneat/neuron.rb', line 172

def express(instance)
  instance.define_singleton_method(@name) { |*inputs|
    a = 1.0 #height
    b = 0.0 #center
    c = 1.0 #SD
    d = 0.0 #lowest y point
    x = inputs.reduce {|p, q| p + q}
    a * exp(-(x - b)**2.0 / 2*c**2.0) + d
  }
end