Skip to main content

neat (wip)

Explorations into NEAT and some of its derivative research

install

In project root, run

$ sh install.sh

usage

Distill / behavior-clone an evolved champion NEAT network into any barebones PyTorch MLP:

import torch
import torch.nn as nn
import gymnasium as gym

from neat import NEAT, behavior_clone

# 1. train NEAT on an environment

env = gym.make('CartPole-v1')
pop = NEAT(4, 16, 2, pop_size = 64)

# ... evolve population ...

# 2. extract champion network

champion = pop.champion

# 3. define any barebones PyTorch MLP

mlp = nn.Sequential(
    nn.Linear(4, 32),
    nn.Tanh(),
    nn.Linear(32, 2)
)

# 4. behavior clone and save .pt to project root

behavior_clone(
    env,
    champion,
    mlp,
    save_path = 'mlp-cartpole.pt'  # saved directly to project root
)

quick test

$ uv run train_lunar.py

To run the end-to-end CartPole evolution, behavior cloning, and validation:

$ uv run train_bc_cartpole.py

citations

@article{Stanley2011CompetitiveCT,
    title   = {Competitive Coevolution through Evolutionary Complexification},
    author  = {Kenneth O. Stanley and Risto Miikkulainen},
    journal = {ArXiv},
    year    = {2011},
    volume  = {abs/1107.0037},
    url     = {https://api.semanticscholar.org/CorpusID:11881625}
}
@inproceedings{4665912,
    author  = {Miguel, Cesar Gomes and Silva, Carolina Feher da and Netto, Marcio Lobo},
    booktitle = {2008 10th Brazilian Symposium on Neural Networks},
    title   = {Structural and Parametric Evolution of Continuous-Time Recurrent Neural Networks},
    year    = {2008},
    doi     = {10.1109/SBRN.2008.12}
}
@article{Khamesian2021HybridSN,
    title   = {Hybrid self-attention NEAT: a novel evolutionary self-attention approach to improve the NEAT algorithm in high dimensional inputs},
    author  = {Saman Khamesian and Hamed Malek},
    journal = {Evolving Systems},
    year    = {2021},
    pages   = {1-15},
    url     = {https://api.semanticscholar.org/CorpusID:244920723}
}
@article{Hornby2006AutomatedAD,
    title   = {Automated Antenna Design with Evolutionary Algorithms},
    author  = {Gregory Hornby and Al Globus and Derek S. Linden and Jason D. Lohn},
    journal = {Space},
    year    = {2006},
    url     = {https://api.semanticscholar.org/CorpusID:8290212}
}
@inproceedings{schrum:gecco14,
    title   = {Evolving Multimodal Behavior With Modular Neural Networks in Ms. Pac-Man},
    author  = {Jacob Schrum and Risto Miikkulainen},
    booktitle = {Proceedings of the Genetic and Evolutionary Computation Conference (GECCO 2014)},
    month   = {July},
    address = {Vancouver, BC, Canada},
    pages   = {325--332},
    note    = {Best Paper: Digital Entertainment and Arts},
    url     = {http://www.cs.utexas.edu/users/ai-lab?schrum:gecco2014},
    year    = {2014}
@article{stanley:ec02,
    title   = {Evolving Neural Networks Through Augmenting Topologies},
    author  = {Kenneth O. Stanley and Risto Miikkulainen},
    volume  = {10},
    journal = {Evolutionary Computation},
    number  = {2},
    pages   = {99-127},
    url     = "http://nn.cs.utexas.edu/?stanley:ec02",
    year    = {2002}
}
@misc{doerr2017fastgeneticalgorithms,
    title   = {Fast Genetic Algorithms},
    author  = {Benjamin Doerr and Huu Phuoc Le and Régis Makhmara and Ta Duy Nguyen},
    year    = {2017},
    eprint  = {1703.03334},
    archivePrefix = {arXiv},
    primaryClass = {cs.NE},
    url     = {https://arxiv.org/abs/1703.03334},
}
@misc{legg2004tournamentversusfitnessuniform,
    title   = {Tournament versus Fitness Uniform Selection},
    author  = {Shane Legg and Marcus Hutter and Akshat Kumar},
    year    = {2004},
    eprint  = {cs/0403038},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/cs/0403038},
}
@article{hiraga2024improving,
    title   = {Improving the performance of mutation-based evolving artificial neural networks with self-adaptive mutations},
    author  = {Hiraga, Motoaki and Komura, Masahiro and Miyamoto, Akiharu and Morimoto, Daichi and Ohkura, Kazuhiro},
    journal = {PLOS ONE},
    volume  = {19},
    number  = {7},
    pages   = {e0307084},
    year    = {2024},
    publisher = {Public Library of Science},
    doi     = {10.1371/journal.pone.0307084},
    url     = {https://doi.org/10.1371/journal.pone.0307084}
}
@inproceedings{tackett1994unique,
    title     = {The unique implications of brood selection for genetic programming},
    author    = {Tackett, Walter Alden and Carmi, Aviram},
    booktitle = {Proceedings of the First IEEE Conference on Evolutionary Computation. IEEE World Congress on Computational Intelligence},
    pages     = {160--165},
    year      = {1994},
    organization = {IEEE},
    doi       = {10.1109/ICEC.1994.350030}
}

Metadata

Release files for x-neat 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for x-neat 0.0.7
File Size Uploaded
x_neat-0.0.7.tar.gz 27.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for x-neat 0.0.7
File Interpreter ABI Platform
x_neat-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 50.5 kB

Release files / x_neat-0.0.7.tar.gz

Download URL x_neat-0.0.7.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
da647dab81a82958bed8c0f683433faa4e5ac105976b0d3741530aa63f08a089
BLAKE2b-256 checksum
How to use checksums
fe545a898f9d28f42e58aded73174b6fe32a1073e34b9eeadadb1f21d2ad2837
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / x_neat-0.0.7-py3-none-any.whl

Download URL x_neat-0.0.7-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83fa696dca54bbb022175916971d18a11a74d545e938dc6fcaa22d98de62ecc9
BLAKE2b-256 checksum
How to use checksums
27e03164646c5bb8c4cc25fea1d3ed30c7defde2625f9d667904a797294f2ad1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release history Release notifications | RSS feed

0.0.9

2 release files

0.0.8

2 release files

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page