Artificial Neural Network

Todo

Missing reference to plotly (hacked something in but fails with 404)

Todo

Implement read-/write-through I/O Buffers

class abrain.ANN2D

2D Artificial Neural Network produced through Evolvable Substrate Hyper-NEAT

CPPN

alias of CPPN2D

DIMENSIONS = 2
Point

alias of Point2D

__call__(self: abrain.ANN2D, inputs: abrain.ANN2D.IBuffer, outputs: abrain.ANN2D.OBuffer, substeps: int = 1) None

Execute a computational step

Assigns provided input values to corresponding input neurons in the same order as when created (see build). Returns output values as computed. If not otherwise specified, a single computational substep is executed. If need be (e.g. large network, fast response required) you can requested for multiple sequential execution in one call

Parameters:
  • inputs – provided analog values for the input neurons

  • outputs – computed analog values for the output neurons

  • substeps – number of sequential executions

See also

Basic usage

buffers(self: abrain.ANN2D) tuple[abrain.ANN2D.IBuffer, abrain.ANN2D.OBuffer]

Return the ann’s I/O buffers as a tuple

static build(inputs: list[abrain.Point2D], outputs: list[abrain.Point2D], genome: abrain._cpp.genotype.CPPNData) abrain.ANN2D

Create an ANN via ES-HyperNEAT

The ANN has inputs/outputs at specified coordinates. A CPPN is instantiated from the provided genome and used to query connections weight, existence and to discover hidden neurons locations

Parameters:
  • inputs – coordinates of the input neurons on the substrate

  • outputs – coordinates of the output neurons on the substrate

  • genome – genome describing a cppn (see abrain.Genome, CPPN)

See also

Basic usage

empty(self: abrain.ANN2D, strict: bool = False) bool

Whether the ANN contains neurons/connections

Parameters:

strict – whether perceptrons count as empty (true) or not (false)

See also

Config::allowPerceptrons

ibuffer(self: abrain.ANN2D) abrain.ANN2D.IBuffer

Return a reference to the neural inputs buffer

max_edges(self: abrain.ANN2D) int

How many connections this ANN could have based on the number of inputs/outputs and hidden nodes (if any)

max_hidden_neurons() int

How many hidden neurons an ANN could have based on the value of maxDepth

neuronAt(self: abrain.ANN2D, pos: abrain.Point2D) abrain.ANN2D.Neuron

Query an individual neuron

neurons(self: abrain.ANN2D) abrain.ANN2D.Neurons

Provide read-only access to the underlying neurons

obuffer(self: abrain.ANN2D) abrain.ANN2D.OBuffer

Return a reference to the neural outputs buffer

perceptron(self: abrain.ANN2D) bool

Whether this ANN is a perceptron

reset(self: abrain.ANN2D) None

Resets internal state to null (0)

stats(self: abrain.ANN2D) abrain.ANN2D.Stats

Return associated stats (connections, depth…)

Supporting types:

class abrain.Point2D

2D coordinate using fixed point notation with 3 decimals

DIMENSIONS = 2
__init__(self: abrain.Point2D, x: float, y: float)

Create a point with the specified coordinates

Parameters:
  • x (float) – x, y coordinate

  • y (float) – x, y coordinate

null() abrain.Point2D

Return the null vector

tuple(self: abrain.Point2D) tuple[float, float]

Return a tuple for easy unpacking in python

class abrain.ANN2D.IBuffer

Input data buffer for an ANN

class abrain.ANN2D.OBuffer

Output data buffer for an ANN

Underlying types:

class abrain.ANN2D.Neuron

Atomic computational unit of an ANN

class Type

Members:

I : Input (receiving data)

H : Hidden (processing data)

O : Output (producing data)

An incoming neural connection

src(self: abrain.ANN2D.Neuron.Link) abrain.ANN2D.Neuron

Return a reference to the source neuron

weight

Connection weight (see abrain.Config.annWeightsRange)

bias

Neural bias

depth

Depth in the neural network

flags

Stimuli-dependent flags (for modularization)

is_hidden(self: abrain.ANN2D.Neuron) bool

Whether this neuron is used for internal computations

is_input(self: abrain.ANN2D.Neuron) bool

Whether this neuron is used a an input

is_output(self: abrain.ANN2D.Neuron) bool

Whether this neuron is used a an output

Return the list of inputs connections

pos

Position in the 2D substrate

type

Neuron role (see Type)

value

Current activation value

class abrain.ANN2D.Neurons

Wrapper for the C++ neurons container

class abrain.ANN2D.Stats

Contains various statistics about an ANN

axons

Total length of the connections

density

Ratio of expressed connections

depth

Maximal depth of the neural network

dict(self: abrain.ANN2D.Stats) dict

Return the stats as Python dictionary

edges

Number of connections

hidden

Number of hidden neurons

iterations

H -> H iterations before convergence

utility

Ratio of used input/output neurons