de.webdings.jannis.neuralnet

Class Neuron

Known Direct Subclasses:
BiNeuron

public abstract class Neuron
extends java.lang.Object

Neurons are the basic units that compose neural nets. The abstract class Neuron provides functionalities that all types of neurons have in common. It is an abstract class for it does not provide an implementation of an activation function or a treshhold value.

Version:
0.1 10.08.2005

Author:
Stefan Thesing
Website: http://www.webdings.de

Field Summary

protected float
a
activation a of the neuron.
protected Synapse[]
connections
connections is an array containing all outgoing synaptical connections of this neuron.
protected boolean
fired
fired returns true if the neuron has fired during the last time the net was presented with input.
protected float
net
net represents the summed up input reaching the neuron.
protected int
numberOfConnections
numberOfConnections represents the amount of outgoing connections of this neuron.
protected boolean
shouldHaveFired
shouldHaveFired can be used by learning methods.

Constructor Summary

Neuron()
Constructs a Neuron with default values:
a=0
net=0
fired=false
shouldHaveFired=false
numberOfConnections=0

Method Summary

void
addConnection(Neuron target)
connects this neuron with another one (target) by constructing a new Synapse with a randomly generated weight ranging from -0.2 and +0.2
void
addConnection(Neuron target, float weight)
connects this neuron with another one (target) by constructing a new Synapse with the specified weight.
void
addConnection(Synapse synapse)
Adds a existing Synapse to the connections of this neuron.
void
clear()
Sets all attributes (exclusive connections and numberOfConnections) back to default: a=0
net=0
fired=false
shouldHaveFired=false
void
fire()
directly causes the neuron to fire.
void
gatherActivation(float weight)
Gathers the net input.
float
getA()
String
getActivationFunction()
Synapse[]
getConnections()
float
getNet()
int
getNumberOfConnections()
boolean
getShouldHaveFired()
boolean
hasFired()
void
setConnections(Synapse connections)
void
setFired(boolean fired)
void
setShouldHaveFired(boolean shouldHaveFired)
boolean
tresholdReached()
represents the activations function of the neuron.

Field Details

a

protected float a
activation a of the neuron. Can be used in calculations for the activation funtion.


connections

protected Synapse[] connections
connections is an array containing all outgoing synaptical connections of this neuron.


fired

protected boolean fired
fired returns true if the neuron has fired during the last time the net was presented with input.


net

protected float net
net represents the summed up input reaching the neuron.


numberOfConnections

protected int numberOfConnections
numberOfConnections represents the amount of outgoing connections of this neuron. It is identical to the size of connections


shouldHaveFired

protected boolean shouldHaveFired
shouldHaveFired can be used by learning methods. Teacher) uses it, for example.

Constructor Details

Neuron

public Neuron()
Constructs a Neuron with default values:
a=0
net=0
fired=false
shouldHaveFired=false
numberOfConnections=0

Method Details

addConnection

public void addConnection(Neuron target)
connects this neuron with another one (target) by constructing a new Synapse with a randomly generated weight ranging from -0.2 and +0.2

Parameters:
target - the target neuron

See Also:
WeightRandomizer.generateRandomWeight()


addConnection

public void addConnection(Neuron target,
                          float weight)
connects this neuron with another one (target) by constructing a new Synapse with the specified weight.

Parameters:
target - the target neuron
weight - weight of the synaptical connection


addConnection

public void addConnection(Synapse synapse)
Adds a existing Synapse to the connections of this neuron.

Parameters:
synapse - the Synapse to add


clear

public void clear()
Sets all attributes (exclusive connections and numberOfConnections) back to default: a=0
net=0
fired=false
shouldHaveFired=false


fire

public void fire()
directly causes the neuron to fire.


gatherActivation

public void gatherActivation(float weight)
Gathers the net input.

Parameters:
weight -


getA

public float getA()

Returns:
Returns the a.


getActivationFunction

public String getActivationFunction()

Returns:
a String representation of the activation function implemented in tresholdReached()


getConnections

public Synapse[] getConnections()

Returns:
Returns the connections.


getNet

public float getNet()

Returns:
Returns the net.


getNumberOfConnections

public int getNumberOfConnections()

Returns:
Returns the numberOfConnections.


getShouldHaveFired

public boolean getShouldHaveFired()

Returns:
Returns the shouldHaveFired.


hasFired

public boolean hasFired()

Returns:
Returns the fired.


setConnections

public void setConnections(Synapse connections)

Parameters:
connections - The connections to set.


setFired

public void setFired(boolean fired)

Parameters:
fired - The fired to set.


setShouldHaveFired

public void setShouldHaveFired(boolean shouldHaveFired)

Parameters:
shouldHaveFired - The shouldHaveFired to set.


tresholdReached

public boolean tresholdReached()
represents the activations function of the neuron. This is an abstract method that must be replaced by any concrete subclass of Neuron.
The simplest concrete implementation of this method is a "binary treshold function" (a treshold value) found in BiNeuron.

Returns:
true if the treshold is reached.


Neuron.java - Copyright (c) 2005 by Stefan Thesing

This file is part of Jannis.

Jannis is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Jannis is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Jannis; if not, write to the
Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA



© 2005 by Stefan Thesing;
Verbatim copying and redistribution of this entire page are permitted provided this notice is preserved.