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

Description

A MemoryCell stored its value for one update.

When the input for a Memory Cell changes, it will output the previous value

Inheritance diagram for MemoryCell:
Neuron Nucleus

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

 MemoryCell (Cluster parent, string name)
 Create a new memory cell.
 
override Nucleus ShallowCloneTo (Cluster parent)
 Function to make a partial clone of this nucleus.
 
override void UpdateStateIsolated ()
 Update the state without updating other Nuclei.
 
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.
 
void SleepCheck ()
 Check if the neuron is sleeping.
 
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.
 
static float3 CombinatorSum (float3 bias, List< Synapse > synapses)
 Sum the bias and synpase outputs together.
 
static Vector3 CombinatorSum (Vector3 bias, List< Synapse > synapses)
 Sum the bias and synpase outputs together.
 
static float3 CombinatorProduct (float3 bias, List< Synapse > synapses)
 Multiply the synapse outputs together.
 
static Vector3 CombinatorProduct (Vector3 bias, List< Synapse > synapses)
 Multiply the synapse outputs together.
 

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.
 
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.
 
bool breakOnUpdate = false
 When true, Unity will pause exection when this neuron is updated.
 
string name
 The name of the Nucleus.
 
Cluster parent
 The cluster instance in which the nucleus is located.
 

Static Public Attributes

static readonly float timeToSleep = 0.5f
 Time in seconds after the last update the neuron can go to sleep.
 

Protected Member Functions

virtual void CloneFields (Neuron clone)
 Copy relevant fields of this neuron to the given neuron.
 
float3 Combinator (float3 bias, List< Synapse > synapses)
 The combinator which combines the bias with the values from all synapses.
 
Vector3 Combinator (Vector3 bias, List< Synapse > synapses)
 The combinator which combines the bias with the values from all synapses.
 
float3 Activator (float3 inputValue)
 Apply the activation function to the input.
 
Vector3 Activator (Vector3 inputValue)
 Apply the activation function to the input.
 
float3 ActivatorLinear (float3 input)
 Linear activation function.
 
Vector3 ActivatorLinear (Vector3 input)
 Linear activation function.
 
float3 ActivatorSqrt (float3 input)
 Square root activation function.
 
Vector3 ActivatorSqrt (Vector3 input)
 Square root activation function.
 
float3 ActivatorPower (float3 input)
 Power activation function.
 
Vector3 ActivatorPower (Vector3 input)
 Power activation function.
 
float3 ActivatorReciprocal (float3 input)
 Reciprocal activation function.
 
Vector3 ActivatorReciprocal (Vector3 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.
 

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.
 
virtual Vector3 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.
 
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.
 
virtual List< Nucleusreceivers [get, set]
 The nuclei which have a synapse to this neuron.
 

Member Enumeration Documentation

◆ CombinatorType

enum CombinatorType
inherited

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

◆ MemoryCell()

MemoryCell ( Cluster  parent,
string  name 
)

Create a new memory cell.

Parameters
parentThe cluster in which the memorycell shoud be created
nameThe name of the memory cell

Member Function Documentation

◆ 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

◆ UpdateStateIsolated()

override void UpdateStateIsolated ( )

Update the state without updating other Nuclei.

◆ AddSynapse()

Synapse AddSynapse ( Neuron  sendingNucleus,
float  weight = 1 
)
inherited

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)
inherited

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)
inherited

Remove a synapse from a Nucleus.

Parameters
sendingNucleusRemote the synapse connecting to this Nucleus

◆ SetBias()

virtual void SetBias ( Vector3  inputValue)
virtualinherited

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

Parameters
inputValue

◆ SleepCheck()

void SleepCheck ( )
inherited

Check if the neuron is sleeping.

This will reset the output value if it is sleeping

◆ CloneFields()

virtual void CloneFields ( Neuron  clone)
protectedvirtualinherited

Copy relevant fields of this neuron to the given neuron.

Parameters
clone

◆ Delete()

static void Delete ( Nucleus  nucleus)
staticinherited

Delete the give neuron.

Parameters
nucleusThe neuron to delete

◆ Combinator() [1/2]

float3 Combinator ( float3  bias,
List< Synapse synapses 
)
protectedinherited

The combinator which combines the bias with the values from all synapses.

Parameters
biasThe bias of the neuron
synapsesThe synapses of the neuron
Returns

◆ Combinator() [2/2]

Vector3 Combinator ( Vector3  bias,
List< Synapse synapses 
)
protectedinherited

The combinator which combines the bias with the values from all synapses.

Parameters
biasThe bias of the neuron
synapsesThe synapses of the neuron
Returns

◆ CombinatorSum() [1/2]

static float3 CombinatorSum ( float3  bias,
List< Synapse synapses 
)
staticinherited

Sum the bias and synpase outputs together.

Parameters
biasThe bias of the neuron
synapsesThe synapses of the neuron
Returns

◆ CombinatorSum() [2/2]

static Vector3 CombinatorSum ( Vector3  bias,
List< Synapse synapses 
)
staticinherited

Sum the bias and synpase outputs together.

Parameters
biasThe bias of the neuron
synapsesThe synapses of the neuron
Returns

◆ CombinatorProduct() [1/2]

static float3 CombinatorProduct ( float3  bias,
List< Synapse synapses 
)
staticinherited

Multiply the synapse outputs together.

Parameters
biasThe bias of the neuron
synapsesThe synapses of the neuron
Returns
The result of the multiplication

◆ CombinatorProduct() [2/2]

static Vector3 CombinatorProduct ( Vector3  bias,
List< Synapse synapses 
)
staticinherited

Multiply the synapse outputs together.

Parameters
biasThe bias of the neuron
synapsesThe synapses of the neuron
Returns
The result of the multiplication

◆ Activator() [1/2]

float3 Activator ( float3  inputValue)
protectedinherited

Apply the activation function to the input.

Parameters
inputValue
Returns
The result of applying the activation function

◆ Activator() [2/2]

Vector3 Activator ( Vector3  inputValue)
protectedinherited

Apply the activation function to the input.

Parameters
inputValue
Returns
The result of applying the activation function

◆ ActivatorLinear() [1/2]

float3 ActivatorLinear ( float3  input)
protectedinherited

Linear activation function.

Parameters
inputInput value
Returns
The unchanged value

◆ ActivatorLinear() [2/2]

Vector3 ActivatorLinear ( Vector3  input)
protectedinherited

Linear activation function.

Parameters
inputInput value
Returns
The unchanged value

◆ ActivatorSqrt() [1/2]

float3 ActivatorSqrt ( float3  input)
protectedinherited

Square root activation function.

Parameters
inputInput value
Returns
The square root of the input

◆ ActivatorSqrt() [2/2]

Vector3 ActivatorSqrt ( Vector3  input)
protectedinherited

Square root activation function.

Parameters
inputInput value
Returns
The square root of the input

◆ ActivatorPower() [1/2]

float3 ActivatorPower ( float3  input)
protectedinherited

Power activation function.

Parameters
inputInput value
Returns
The input to the power of 2

◆ ActivatorPower() [2/2]

Vector3 ActivatorPower ( Vector3  input)
protectedinherited

Power activation function.

Parameters
inputInput value
Returns
The input to the power of 2

◆ ActivatorReciprocal() [1/2]

float3 ActivatorReciprocal ( float3  input)
protectedinherited

Reciprocal activation function.

Parameters
inputInput value
Returns
1/input value

◆ ActivatorReciprocal() [2/2]

Vector3 ActivatorReciprocal ( Vector3  input)
protectedinherited

Reciprocal activation function.

Parameters
inputInput value
Returns
1/input value

◆ ActivatorTanh()

float3 ActivatorTanh ( float3  input)
protectedinherited

Tanh activation function.

Parameters
inputInput value
Returns
Tanh(input value)

◆ ActivatorBinary()

float3 ActivatorBinary ( float3  input)
protectedinherited

Binary activation function.

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

◆ ActivatorNormalized()

float3 ActivatorNormalized ( float3  input)
protectedinherited

Normalize activation function.

Parameters
inputInput value
Returns
The normalized vector

◆ AddReceiver()

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

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)
virtualinherited

Remove a receiver to this neuron.

Parameters
receiverToRemoveThe receiver to remove

◆ ProcessStimulus()

virtual void ProcessStimulus ( Vector3  inputValue)
virtualinherited

Process an external stimulus.

Parameters
inputValueThe value of the stimulus

Member Data Documentation

◆ bias

Vector3 bias = Vector3.zero
inherited

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

◆ breakOnUpdate

bool breakOnUpdate = false
inherited

When true, Unity will pause exection when this neuron is updated.

Pausing is implemented using Debug.Break()