/neat

NeuroEvolution of Augmenting Topologies on Gym Environments

Primary LanguagePython

NEAT

NEAT (NeuroEvolution of Augmenting Topologies) is an algorithm which applies genetic algorithm to evolve both, the weights and topology of a neural network. This code in this repository implements NEAT for Gym Environments like the LunarLander.

Requirements

  • neat-python
  • graphviz
  • gym (including box2d environments)

Usage

You can run this repository either on colab or locally.

Colab

Run the Colab Notebook to run this repository directly

Local

Training

  • Run the train.py script with the necessary arguments as described in the help menu of the CLI by running python train.py --help.
  • To train on default settings, run python train.py
  • You can also stop the training in between and continue it using the --load_ckpt argument and passing the path of the checkpoint. For example, python train.py --load_ckpt checkpoint_G49
  • By default, the best trained genome is saved as a best.genome file.

Testing

  • Test the trained genome by executing the run.py file with the necessary arguments described in the help menu, python run.py --help.

  • On default settings, to run and watch the simulation on the trained genome (best.genome), python run.py --render.

  • To run the evaluation consequently for large episodes, python run.py --episodes 100.

  • You can accesss the trained model and results under trained_files/ including the resulting neural network and plots of fitness and speciation.

References