Nano Brain for Unity v0.1
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
Neuron Class Reference

Description

A neuron is a basic Nucleus.

Inheritance diagram for Neuron:
Nucleus MemoryCell

Classes

class  Presets
 The curve presets for the activation functions. More...
 

Public Types

enum  CombinatorType { Sum , Product }
 The type of combinators. More...
 
enum  ActivationType {
  Linear , Power , Sqrt , Reciprocal ,
  Tanh , Binary , Normalized , Custom
}
 The type of.
 
enum  Type { None , Neuron , MemoryCell , Cluster }
 The types of Nucleus.
 

Public Member Functions

 Neuron (Cluster parent, string name)
 Create a new Neuron in a Cluster instance.
 
Synapse AddSynapse (Neuron sendingNucleus, float weight=1)
 Add a new synapse to this nuclues.
 
Synapse GetSynapse (Nucleus sender)
 Find a synapse.
 
void RemoveSynapse (Nucleus sendingNucleus)
 Remove a synapse from a Nucleus.
 
virtual void SetBias (Vector3 inputValue)
 Set the bias, recalculate the output and update all Nuclei receiving from this Nucleus.
 
AnimationCurve GenerateCurve ()
 Generate the curve for the current activation function.
 
void SleepCheck ()
 Check if the neuron is sleeping.
 
override Nucleus ShallowCloneTo (Cluster parent)
 Function to make a partial clone of this nucleus.
 
override void UpdateStateIsolated ()
 Update the state without updating other Nuclei.
 
float3 CombinatorSum ()
 Sum the synapse outputs together.
 
float3 CombinatorProduct ()
 Multiply the synapse outputs together.
 
Vector3 CombinatorSum ()
 Sum the synapse outputs together.
 
Vector3 CombinatorProduct ()
 Multiply the synapse outputs together.
 
virtual void AddReceiver (Nucleus receiverToAdd, float weight=1)
 Add a new receiver to this neuron.
 
virtual void RemoveReceiver (Nucleus receiverToRemove)
 Remove a receiver to this neuron.
 
virtual void ProcessStimulus (Vector3 inputValue)
 Process an external stimulus.
 

Static Public Member Functions

static void Delete (Nucleus nucleus)
 Delete the give neuron.
 

Public Attributes

Vector3 bias = Vector3.zero
 The bias.
 
CombinatorType combinator = CombinatorType.Sum
 The type of combinator used for this Neuron.
 
ActivationType _activator
 The activation function.
 
AnimationCurve curve
 The curve representing the activation function.
 
float curveMax = 1.0f
 The maximum value of the curve.
 
Action WhenFiring
 An action which is called every time the neuron is updated and is firing.
 
bool persistOutput = false
 When true, the value will not be reset after timeToSleep.
 
float lastUpdate = 0
 The time at which the last update has been done.
 
readonly float timeToSleep = 1f
 Time in seconds after the last update the neuron can go to sleep.
 
string name
 The name of the Nucleus.
 
Cluster parent
 The cluster instance in which the nucleus is located.
 

Protected Member Functions

virtual void CloneFields (Neuron clone)
 Copy relevant fields of this neuron to the given neuron.
 
float3 ActivatorLinear (float3 input)
 Linear activation function.
 
float3 ActivatorSqrt (float3 input)
 Square root activation function.
 
float3 ActivatorPower (float3 input)
 Power activation function.
 
float3 ActivatorReciprocal (float3 input)
 Reciprocal activation function.
 
float3 ActivatorTanh (float3 input)
 Tanh activation function.
 
float3 ActivatorBinary (float3 input)
 Binary activation function.
 
float3 ActivatorNormalized (float3 input)
 Normalize activation function.
 
Vector3 ActivatorLinear (Vector3 input)
 Linear activation function.
 
Vector3 ActivatorSqrt (Vector3 input)
 Square root activation function.
 
Vector3 ActivatorPower (Vector3 input)
 Power activation function.
 
Vector3 ActivatorReciprocal (Vector3 input)
 Reciprocal activation function.
 

Protected Attributes

float3 _outputValue
 The output value of the neuron.
 
Vector3 _outputValue
 The output value of the neuron.
 

Properties

List< Synapsesynapses [get]
 The synapses of the nucleus.
 
ActivationType activator [get, set]
 The activation funtion.
 
virtual float3 outputValue [get, set]
 The output value of the neuron.
 
float outputMagnitude [get]
 The magnitude of the neuron output.
 
float outputSqrMagnitude [get]
 The squared magnitude of the neuron output.
 
virtual Vector3 outputValue [get, set]
 The output value of the neuron.
 
bool isFiring [get]
 True if the neuron have a positive value with magnitude > 0.5.
 
virtual bool isSleeping [get]
 True when the neuron is not persisting and has not be updated for timeToSleep seconds.
 
Func< float3 > Combinator [get]
 The combinator which combines the values from all synapses.
 
Func< Vector3 > Combinator [get]
 The combinator which combines the values from all synapses.
 
virtual List< Nucleusreceivers [get, set]
 The nuclei which have a synapse to this neuron.
 

Member Enumeration Documentation

◆ CombinatorType

The type of combinators.

A combinator combines the weighted values of the synapses to a single value

Enumerator
Sum 

Add the weighted values together.

Product 

Multiply the weighted values.

Constructor & Destructor Documentation

◆ Neuron()

Neuron ( Cluster  parent,
string  name 
)

Create a new Neuron in a Cluster instance.

Parameters
parentThe parent cluster in which the new Neuron should be created
nameThe name of the new Neuron

Member Function Documentation

◆ AddSynapse()

Synapse AddSynapse ( Neuron  sendingNucleus,
float  weight = 1 
)

Add a new synapse to this nuclues.

Parameters
sendingNucleusThe nucleus from which the signals may originate
weightThe weight applied to the input. Default value = 1
Returns
The created Synapse

This will add a new input to this nucleus with the given weight.

◆ GetSynapse()

Synapse GetSynapse ( Nucleus  sender)

Find a synapse.

Parameters
senderThe sender of the input to the Synapse
Returns
The found Synapse or null when the sender has no synapse to this nucleus.

◆ RemoveSynapse()

void RemoveSynapse ( Nucleus  sendingNucleus)

Remove a synapse from a Nucleus.

Parameters
sendingNucleusRemote the synapse connecting to this Nucleus

◆ SetBias()

virtual void SetBias ( Vector3  inputValue)
virtual

Set the bias, recalculate the output and update all Nuclei receiving from this Nucleus.

Parameters
inputValue

◆ GenerateCurve()

AnimationCurve GenerateCurve ( )

Generate the curve for the current activation function.

Returns
The curve

◆ SleepCheck()

void SleepCheck ( )

Check if the neuron is sleeping.

This will reset the output value if it is sleeping

◆ ShallowCloneTo()

override Nucleus ShallowCloneTo ( Cluster  parent)

Function to make a partial clone of this nucleus.

Parameters
parentThe cluster in which the cloned nucleus should be placed
Returns

◆ CloneFields()

virtual void CloneFields ( Neuron  clone)
protectedvirtual

Copy relevant fields of this neuron to the given neuron.

Parameters
clone

◆ Delete()

static void Delete ( Nucleus  nucleus)
static

Delete the give neuron.

Parameters
nucleusThe neuron to delete

◆ UpdateStateIsolated()

override void UpdateStateIsolated ( )

Update the state without updating other Nuclei.

◆ CombinatorSum() [1/2]

float3 CombinatorSum ( )

Sum the synapse outputs together.

Returns
The sum of the synapse outputs

◆ CombinatorProduct() [1/2]

float3 CombinatorProduct ( )

Multiply the synapse outputs together.

Returns
The mutliplcation of the synapse outputs

◆ CombinatorSum() [2/2]

Vector3 CombinatorSum ( )

Sum the synapse outputs together.

Returns
The sum of the synapse outputs

◆ CombinatorProduct() [2/2]

Vector3 CombinatorProduct ( )

Multiply the synapse outputs together.

Returns
The mutliplcation of the synapse outputs

◆ ActivatorLinear() [1/2]

float3 ActivatorLinear ( float3  input)
protected

Linear activation function.

Parameters
inputInput value
Returns
The unchanged value

◆ ActivatorSqrt() [1/2]

float3 ActivatorSqrt ( float3  input)
protected

Square root activation function.

Parameters
inputInput value
Returns
The square root of the input

◆ ActivatorPower() [1/2]

float3 ActivatorPower ( float3  input)
protected

Power activation function.

Parameters
inputInput value
Returns
The input to the power of 2

◆ ActivatorReciprocal() [1/2]

float3 ActivatorReciprocal ( float3  input)
protected

Reciprocal activation function.

Parameters
inputInput value
Returns
1/input value

◆ ActivatorTanh()

float3 ActivatorTanh ( float3  input)
protected

Tanh activation function.

Parameters
inputInput value
Returns
Tanh(input value)

◆ ActivatorBinary()

float3 ActivatorBinary ( float3  input)
protected

Binary activation function.

Parameters
inputInput value
Returns
An uniform vector with magnitude between 0 and 1

◆ ActivatorNormalized()

float3 ActivatorNormalized ( float3  input)
protected

Normalize activation function.

Parameters
inputInput value
Returns
The normalized vector

◆ ActivatorLinear() [2/2]

Vector3 ActivatorLinear ( Vector3  input)
protected

Linear activation function.

Parameters
inputInput value
Returns
The unchanged value

◆ ActivatorSqrt() [2/2]

Vector3 ActivatorSqrt ( Vector3  input)
protected

Square root activation function.

Parameters
inputInput value
Returns
The square root of the input

◆ ActivatorPower() [2/2]

Vector3 ActivatorPower ( Vector3  input)
protected

Power activation function.

Parameters
inputInput value
Returns
The input to the power of 2

◆ ActivatorReciprocal() [2/2]

Vector3 ActivatorReciprocal ( Vector3  input)
protected

Reciprocal activation function.

Parameters
inputInput value
Returns
1/input value

◆ AddReceiver()

virtual void AddReceiver ( Nucleus  receiverToAdd,
float  weight = 1 
)
virtual

Add a new receiver to this neuron.

Parameters
receiverToAddThe receiver to add
weightThe weight to use for the synapse to his neuron

◆ RemoveReceiver()

virtual void RemoveReceiver ( Nucleus  receiverToRemove)
virtual

Remove a receiver to this neuron.

Parameters
receiverToRemoveThe receiver to remove

◆ ProcessStimulus()

virtual void ProcessStimulus ( Vector3  inputValue)
virtual

Process an external stimulus.

Parameters
inputValueThe value of the stimulus

Member Data Documentation

◆ bias

Vector3 bias = Vector3.zero

The bias.

The bias which a value which is always added to the combined value of the neuron It does not have a synapse and therefore no weight of source nucleus