macula-tweann

Topology and Weight Evolving Artificial Neural Networks for Erlang

Hex.pmDocumentationLicenseBuy Me A Coffee

Evolutionary neural networks that evolve both topology and weights, now with Liquid Time-Constant (LTC) neurons for adaptive temporal processing. Based on DXNN2 by Gene Sher.

Highlights

Quick Start

%% Add to rebar.config
{deps, [{macula_tweann, "~> 0.17.0"}]}.

%% Create and evolve a standard network
genotype:init_db(),
Constraint = #constraint{morphology = xor_mimic},
{ok, AgentId} = genotype:construct_agent(Constraint),
genome_mutator:mutate(AgentId).

%% Use LTC dynamics directly
{NewState, Output} = ltc_dynamics:evaluate_cfc(Input, State, Tau, Bound).

LTC Neurons

Liquid Time-Constant neurons enable adaptive temporal processing with input-dependent time constants:

LTC Architecture

%% CfC evaluation (fast, closed-form)
{State1, _} = ltc_dynamics:evaluate_cfc(1.0, 0.0, 1.0, 1.0),
{State2, _} = ltc_dynamics:evaluate_cfc(1.0, State1, 1.0, 1.0).
%% State persists between evaluations - temporal memory!

Key equations:

See the LTC Neurons Guide for details.

Documentation

Features

Neural Network Evolution

LTC/CfC Neurons

Production Quality

Community vs Enterprise Edition

This library is available in two editions:

Feature Community (hex.pm) Enterprise
TWEANN topology evolution Yes Yes
LTC/CfC neurons Yes Yes
Weight evolution Yes Yes
Speciation Yes Yes
Rust NIF acceleration No (pure Erlang) Yes (30-200x faster)
Source code Hex package only Full repository

Community Edition

The hex.pm package uses pure Erlang implementations for all algorithms. This is fully functional and suitable for:

%% Check if NIFs are available
tweann_nif:is_loaded().  %% Returns false on Community Edition

Enterprise Edition

Enterprise users with full source access can enable Rust NIF acceleration by:

  1. Installing Rust toolchain (rustup.rs)
  2. Uncommenting NIF hooks in rebar.config
  3. Building from source

NIF-accelerated functions include:

Contact Macula.io for enterprise licensing.

Architecture

Module Dependencies

Process-based neural networks with evolutionary operators. See Architecture Guide for details.

Testing

rebar3 eunit          # Unit tests (858 tests)
rebar3 dialyzer       # Static analysis
rebar3 ex_doc         # Generate documentation

Academic References

TWEANN/NEAT

LTC/CfC Neurons

Weight Initialization

Evolutionary Algorithms

ONNX Export

Related Projects

Macula Ecosystem

Inspiration & Related Work

License

Apache License 2.0 - See LICENSE

Credits

Based on DXNN2 by Gene Sher. Adapted with LTC extensions by Macula.io.