com.anji.nn
Class Neuron

java.lang.Object
  extended bycom.anji.nn.Neuron
All Implemented Interfaces:
XmlPersistable

public class Neuron
extends java.lang.Object
implements XmlPersistable

Neuron component of an artificial neural network. Performs an activation function on a sum of inputs.

Author:
Philip Tucker

Field Summary
protected  double value
          protected for TestNeuron only
static java.lang.String XML_TAG
          base XML tag
 
Constructor Summary
Neuron(ActivationFunction aFunc)
          Create neuron with aFunc activation function.
 
Method Summary
 void addIncomingConnection(Connection c)
          Add incoming connection c.
static void appendToXml(java.util.Collection allNeurons, java.util.List outputNeurons, java.lang.StringBuffer result)
          XML representation is consistent with NEVT .
 long cost()
           
 ActivationFunction getFunc()
           
 long getId()
          for logging, tracking, debugging; this ID usually will be the innovation ID of the corresponding gene
protected  java.util.Collection getIncomingConns()
          used by NeuronConnection.appendToXml() only
 double getValue()
          only calculate value if dirty == false; otherwise, returned cached value
 java.lang.String getXmld()
           
 java.lang.String getXmlRootTag()
           
 boolean isDirty()
           
 boolean isRecurrent()
           
 void reset()
          clear current value
 void setId(long l)
           
 void step()
          indicates a time step has passed
 java.lang.String toString()
           
 java.lang.String toXml()
          XML representation is consistent with NEVT .
static java.lang.String toXml(com.anji.nn.Neuron.NeuronMetaData layout)
          XML representation is consistent with NEVT .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_TAG

public static final java.lang.String XML_TAG
base XML tag

See Also:
Constant Field Values

value

protected double value
protected for TestNeuron only

Constructor Detail

Neuron

public Neuron(ActivationFunction aFunc)
       throws java.lang.IllegalArgumentException
Create neuron with aFunc activation function.

Parameters:
aFunc -
Throws:
java.lang.IllegalArgumentException
Method Detail

addIncomingConnection

public void addIncomingConnection(Connection c)
Add incoming connection c.

Parameters:
c -

step

public void step()
indicates a time step has passed


getValue

public double getValue()
only calculate value if dirty == false; otherwise, returned cached value

Returns:
double activation value for current time step

reset

public void reset()
clear current value


toString

public java.lang.String toString()
Returns:
String representation of object

toXml

public java.lang.String toXml()
XML representation is consistent with NEVT .

Specified by:
toXml in interface XmlPersistable
Returns:
String XML representation of object

toXml

public static java.lang.String toXml(com.anji.nn.Neuron.NeuronMetaData layout)
XML representation is consistent with NEVT .

Parameters:
layout -
Returns:
String XML representation of layout

appendToXml

public static void appendToXml(java.util.Collection allNeurons,
                               java.util.List outputNeurons,
                               java.lang.StringBuffer result)
XML representation is consistent with NEVT . Utility method to convert collection of neurons, presumably an entire ANN, to XML.

Parameters:
allNeurons -
outputNeurons -
result - destination to which XML is appended

getIncomingConns

protected java.util.Collection getIncomingConns()
used by NeuronConnection.appendToXml() only

Returns:
Collection contains Connection objects

isRecurrent

public boolean isRecurrent()
Returns:
boolean true if at least one incoming connection is recurrent

setId

public void setId(long l)
Parameters:
l - new ID

getId

public long getId()
for logging, tracking, debugging; this ID usually will be the innovation ID of the corresponding gene

Returns:
long id

isDirty

public boolean isDirty()
Returns:
true if this neuron's value has not been updated for the current time step

getFunc

public ActivationFunction getFunc()
Returns:
ActivationFunction

cost

public long cost()
Returns:
number corresponding to cost of activation in resources

getXmlRootTag

public java.lang.String getXmlRootTag()
Specified by:
getXmlRootTag in interface XmlPersistable
Returns:
root tag
See Also:
XmlPersistable.getXmlRootTag()

getXmld

public java.lang.String getXmld()
Specified by:
getXmld in interface XmlPersistable
Returns:
id
See Also:
XmlPersistable.getXmld()