Bardo.AgentManager.Neuron (Bardo v0.1.0)

View Source

The neuron is a signal processing element.

It accepts signals, accumulates them into an ordered vector, then processes this input vector to produce an output, and finally passes the output to other elements it is connected to. The neuron never interacts with the environment directly, and even when it does receive signals and produces output signals, it does not know whether these input signals are coming from sensors or neurons, or whether it is sending its output signals to other neurons or actuators.

All the neuron does is have a list of input PIDs from which it expects to receive signals, a list of output PIDs to which the neuron sends its output, a weight list correlated with the input PIDs, and an activation function it applies to the dot product of the input vector and its weight vector. The neuron waits until it receives all the input signals, and then passes the output onwards.

NOTE: The neuron is the basic processing element, the basic processing node in the neural network system. The neurons in this system are more general than those used by others. They can easily use various activation functions, and accept and output vectors. Because we can use anything for the activation function, including logical operators, the neurons are really just processing nodes. In some sense, this system is not a Topology and Weight Evolving Artificial Neural Network, but a Topology and Parameter Evolving Universal Learning Network (TPEULN). Nevertheless, we will continue referring to these processing elements as neurons.

Summary

Functions

Returns a specification to start this module under a supervisor.

The Neuron process waits for vector signals from all the processes that it's connected from, taking the dot product of the input and weight vectors, and then adding it to the accumulator. Once all the signals from InputPids are received, the accumulator contains the dot product to which the neuron then adds the bias and executes the activation function. After fanning out the output signal, the neuron again returns to waiting for incoming signals.

Get backup: neuron sends back to the exoself its last best synaptic weight combination, stored as the MInputPids list.

Initialize the neuron process.

Main process loop during initialization.

Main process loop after initialization.

Perturb plasticity function: perturbs the plasticity function.

The perturb_weights_p function is the function that actually goes through each weight block, and perturbs each weight with a probability of MP. If the weight is chosen to be perturbed, the perturbation intensity is chosen uniformly between -Spread and Spread.

Reset prep: This message is sent after a single evaluation is completed, and the exoself wishes to reset all the neurons to their original states, with empty inboxes. Once a neuron receives this message, it goes into a reset_prep state, flushes its buffer/inbox, and then awaits for the {ExoselfPid, reset} signal. When the neuron receives the {ExoselfPid, reset} message, it again sends out the default output message to all its recurrent connections (Ids stored in the ro_ids list), and then finally drops back into its main receive loop.

Spawns a Neuron process belonging to the Exoself process that spawned it and calls init to initialize.

Terminates neuron.

Terminate the neuron process.

Weight backup: The signal from the exoself, which tells the neuron that the NN system performs best when this particular neuron is using its current synaptic weight combination, and thus it should save this synaptic weight list as MInputPidPs, and that it is the best weight combination achieved thus far. The message is sent if after the weight perturbation, the NN's evaluation achieves a higher fitness than when the neurons of this NN used their previous synaptic weights.

Weight perturb: Uses the Spread value for the purpose of generating synaptic weight perturbations.

Weight restore: This message is sent from the exoself, and it tells the neuron that it should restore its synaptic weight list to the one previously used, saved as MInputPidPs. This message is usually sent if after the weight perturbation, the NN based agent's evaluation performs worse than it did with its previous synaptic weight combinations.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

forward(pid, i_pid, input)

@spec forward(pid(), pid(), [float()]) :: :ok

The Neuron process waits for vector signals from all the processes that it's connected from, taking the dot product of the input and weight vectors, and then adding it to the accumulator. Once all the signals from InputPids are received, the accumulator contains the dot product to which the neuron then adds the bias and executes the activation function. After fanning out the output signal, the neuron again returns to waiting for incoming signals.

get_backup(pid, exoself_pid)

@spec get_backup(pid(), pid()) :: :ok

Get backup: neuron sends back to the exoself its last best synaptic weight combination, stored as the MInputPids list.

init(exoself_pid)

@spec init(pid()) :: no_return()

Initialize the neuron process.

init_phase2(pid, exoself_pid, id, cx_pid, af, pf, aggr_f, heredity_type, si_pidps, mi_pidps, output_pids, ro_pids)

@spec init_phase2(
  pid(),
  pid(),
  tuple(),
  pid(),
  atom(),
  {atom(), [float()]},
  atom(),
  atom(),
  [tuple()],
  [tuple()],
  [pid()],
  [pid()]
) :: :ok

Initializes the neuron setting it to its initial state.

loop(exoself_pid)

@spec loop(pid()) :: no_return()

Main process loop during initialization.

loop(state, exoself_pid, list1, list2, si_acc, mi_acc)

@spec loop(
  Bardo.AgentManager.Neuron.State.t(),
  pid(),
  [:ok] | [pid()],
  [:ok] | [pid()],
  [{pid(), [float()]}] | [],
  [{pid(), [float()]}] | []
) :: no_return()

Main process loop after initialization.

perturb_pf(spread, arg)

@spec perturb_pf(
  float(),
  {atom(), [float()]}
) :: {atom(), [float()]}

Perturb plasticity function: perturbs the plasticity function.

perturb_weights_p(spread, mp, list, acc)

@spec perturb_weights_p(float(), float(), [{float(), [float()]}], [float()]) :: [
  float()
]

The perturb_weights_p function is the function that actually goes through each weight block, and perturbs each weight with a probability of MP. If the weight is chosen to be perturbed, the perturbation intensity is chosen uniformly between -Spread and Spread.

reset_prep(pid, exoself_pid)

@spec reset_prep(pid(), pid()) :: :ok

Reset prep: This message is sent after a single evaluation is completed, and the exoself wishes to reset all the neurons to their original states, with empty inboxes. Once a neuron receives this message, it goes into a reset_prep state, flushes its buffer/inbox, and then awaits for the {ExoselfPid, reset} signal. When the neuron receives the {ExoselfPid, reset} message, it again sends out the default output message to all its recurrent connections (Ids stored in the ro_ids list), and then finally drops back into its main receive loop.

sat(val, min, max)

start(node, exoself_pid)

@spec start(node(), pid()) :: pid()

Spawns a Neuron process belonging to the Exoself process that spawned it and calls init to initialize.

stop(pid, exoself_pid)

@spec stop(pid(), pid()) :: :ok

Terminates neuron.

terminate(reason)

@spec terminate(atom()) :: :ok

Terminate the neuron process.

weight_backup(pid, exoself_pid)

@spec weight_backup(pid(), pid()) :: :ok

Weight backup: The signal from the exoself, which tells the neuron that the NN system performs best when this particular neuron is using its current synaptic weight combination, and thus it should save this synaptic weight list as MInputPidPs, and that it is the best weight combination achieved thus far. The message is sent if after the weight perturbation, the NN's evaluation achieves a higher fitness than when the neurons of this NN used their previous synaptic weights.

weight_perturb(pid, exoself_pid, spread)

@spec weight_perturb(pid(), pid(), integer()) :: :ok

Weight perturb: Uses the Spread value for the purpose of generating synaptic weight perturbations.

weight_restore(pid, exoself_pid)

@spec weight_restore(pid(), pid()) :: :ok

Weight restore: This message is sent from the exoself, and it tells the neuron that it should restore its synaptic weight list to the one previously used, saved as MInputPidPs. This message is usually sent if after the weight perturbation, the NN based agent's evaluation performs worse than it did with its previous synaptic weight combinations.