This repository contains an implementation of the NEAT algorithm (NeuroEvolution of Augmenting Topologies) from scratch. NEAT is a genetic algorithm for the generation of evolving artificial neural networks. The implementation is modular and flexible, allowing you to easily pass a custom fitness function to evolve neural networks tailored to your specific problem.
- Modular Design: Easily integrate your own fitness function to customize the evolutionary process.
- NeuroEvolution: Evolve neural networks using genetic algorithms.
- Topological Innovation: Supports dynamic growth and complexity of neural networks through mutation operations that add nodes and connections.
- NumPy Powered: Efficient numerical computations using the NumPy library.
- Python 3.x
- NumPy
- TensorFlow
- TQDM
- Matplotlib
- Gymnasium
- NetworkX
-
Clone the repository:
git clone https://github.com/larrie1/neat.git cd neat -
Install the required dependencies:
pip install numpy tensorflow tqdm matplotlib gymnasium networkx
-
Define your fitness function:
def fitness_function(genome): # Your custom fitness logic here return fitness_score
-
Initialize the NEAT algorithm:
neat = NEAT(fitness_function=fitness_function, population_size=100, input_size=5, output_size=2)
-
Run the evolutionary process:
best = neat.fit(generations=10, selection_size=20)
-
Plot the results of the best network:
plot_genom(best, fitness)