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
- DIMENSIONS = 2¶
- __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
- 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
- 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)
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…)
- class abrain.ANN3D¶
3D Artificial Neural Network produced through Evolvable Substrate Hyper-NEAT
- DIMENSIONS = 3¶
- __call__(self: abrain.ANN3D, inputs: abrain.ANN3D.IBuffer, outputs: abrain.ANN3D.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
- buffers(self: abrain.ANN3D) tuple[abrain.ANN3D.IBuffer, abrain.ANN3D.OBuffer]¶
Return the ann’s I/O buffers as a tuple
- static build(inputs: list[abrain.Point3D], outputs: list[abrain.Point3D], genome: abrain._cpp.genotype.CPPNData) abrain.ANN3D¶
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
- empty(self: abrain.ANN3D, 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.ANN3D) abrain.ANN3D.IBuffer¶
Return a reference to the neural inputs buffer
- max_edges(self: abrain.ANN3D) int¶
How many connections this ANN could have based on the number of inputs/outputs and hidden nodes (if any)
How many hidden neurons an ANN could have based on the value of
maxDepth
- neuronAt(self: abrain.ANN3D, pos: abrain.Point3D) abrain.ANN3D.Neuron¶
Query an individual neuron
- neurons(self: abrain.ANN3D) abrain.ANN3D.Neurons¶
Provide read-only access to the underlying neurons
- obuffer(self: abrain.ANN3D) abrain.ANN3D.OBuffer¶
Return a reference to the neural outputs buffer
- perceptron(self: abrain.ANN3D) bool¶
Whether this ANN is a perceptron
- render3D(labels: Dict[Point3D, str] | None = None, edges_alpha=1.0) Figure¶
Produce a 3D figure from an artificial neural network
The returned figure can be used to save an interactive html session or a (probably poorly) rendering to e.g. a png file
- Parameters:
ann – The neural network to render
labels – The names to use for the neurons
edges_alpha – The alpha value to use for the edges
- reset(self: abrain.ANN3D) None¶
Resets internal state to null (0)
- stats(self: abrain.ANN3D) abrain.ANN3D.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
- 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
- class abrain.Point3D¶
3D coordinate using fixed point notation with 3 decimals
- DIMENSIONS = 3¶
- __init__(self: abrain.Point3D, x: float, y: float, z: float)¶
Create a point with the specified coordinates
- null() abrain.Point3D¶
Return the null vector
- class abrain.ANN3D.IBuffer¶
Input data buffer for an ANN
- class abrain.ANN3D.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)
- class Link¶
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)
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
- links(self: abrain.ANN2D.Neuron) list[abrain.ANN2D.Neuron.Link]¶
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
Number of hidden neurons
- iterations¶
H -> H iterations before convergence
- utility¶
Ratio of used input/output neurons
- class abrain.ANN3D.Neuron¶
Atomic computational unit of an ANN
- class Type¶
Members:
I : Input (receiving data)
H : Hidden (processing data)
O : Output (producing data)
- class Link¶
An incoming neural connection
- src(self: abrain.ANN3D.Neuron.Link) abrain.ANN3D.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)
Whether this neuron is used for internal computations
- is_input(self: abrain.ANN3D.Neuron) bool¶
Whether this neuron is used a an input
- is_output(self: abrain.ANN3D.Neuron) bool¶
Whether this neuron is used a an output
- links(self: abrain.ANN3D.Neuron) list[abrain.ANN3D.Neuron.Link]¶
Return the list of inputs connections
- pos¶
Position in the 3D substrate
- type¶
Neuron role (see
Type)
- value¶
Current activation value
- class abrain.ANN3D.Neurons¶
Wrapper for the C++ neurons container
- class abrain.ANN3D.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.ANN3D.Stats) dict¶
Return the stats as Python dictionary
- edges¶
Number of connections
Number of hidden neurons
- iterations¶
H -> H iterations before convergence
- utility¶
Ratio of used input/output neurons