Bardo.AgentManager.Cortex (Bardo v0.1.0)

View Source

The Cortex is the central coordination element of a neural network agent.

Overview

The Cortex manages the synchronization and communication between all components of a neural network agent:

  • Sensors: Receive information from the environment
  • Neurons: Process information through activation functions
  • Actuators: Act on the environment based on neural outputs

It orchestrates the sense-think-act cycle by:

  1. Triggering sensors to gather input from the environment
  2. Coordinating the forward propagation of signals through the neural network
  3. Ensuring actuators receive their control signals to interact with the environment
  4. Managing the timing and synchronization of the entire process

Key Responsibilities

  • Network Coordination: Ensures all neurons, sensors, and actuators operate in coordination
  • Cycle Management: Controls the timing of sensing, processing, and acting phases
  • Message Routing: Directs signals between appropriate network components
  • State Management: Maintains the state of the neural network across operational cycles

Implementation Details

Each Cortex is implemented as an Erlang process that communicates with other processes (sensors, neurons, actuators) through message passing. This leverages the BEAM VM's concurrency model for efficient parallel processing across the neural network.

Summary

Functions

Activates a neural network with the given inputs.

Creates a neural network (cortex) from a genotype.

Initialize the cortex process.

Reactivate the Cortex after it's gone inactive.

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

Terminates the cortex.

Sync the Cortex with an actuator, providing fitness and status. Used in the cycle coordination process.

Functions

activate(nn, inputs)

@spec activate(map(), [float()]) :: [float()]

Activates a neural network with the given inputs.

This is a simplified implementation for basic examples and testing.

from_genotype(genotype)

@spec from_genotype(map()) :: map()

Creates a neural network (cortex) from a genotype.

This is a simplified implementation for basic examples and testing. It creates an in-memory neural network without spawning processes.

init(exoself_pid)

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

Initialize the cortex process.

init_phase2(pid, exoself_pid, id, s_pids, n_pids, a_pids, op_mode)

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

Initializes the cortex.

reactivate(cortex_pid, exoself_pid)

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

Reactivate the Cortex after it's gone inactive.

start(node, exoself_pid)

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

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

stop(pid, exoself_pid)

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

Terminates the cortex.

sync(cortex_pid, actuator_pid, fitness, e_flag)

@spec sync(pid(), pid(), [float()], 0 | 1 | :goal_reached) :: :ok

Sync the Cortex with an actuator, providing fitness and status. Used in the cycle coordination process.