Package: prettyNEAT
prettyNEATNeuroevolution of Augmenting Topologies (NEAT) algorithm in numpy, built for multicore use and OpenAI's gym interface.Original paper by Ken Stanley and Risto Miikkulainen:Evolving Neural Networks Through Augmenting TopologiesImplementation created byAdam
Gaierand
originally released as part of theGoogle Brain Tokyo
Workshop.InstallationprettyNEAT can be downloaded from pypi:pip install prettyNEATOr installed locallygitclonehttps://github.com/d9w/prettyNEATcdprettyNEAT
pythonsetup.pyinstallOther dependenciesThe provided example scripts which evolve individuals forgymenvironments
have further dependencies, includingmpi4pyfor distributed evaluation. To
install these additional dependencies, do:pip install -r requirements.txtRunning NEATThe 'cartpole_swingup' task doesn't have any dependencies and is set as the default task, try it with the default parameters:Training command:python evolution.pyTo view the performance of a trained controller (defaultlog/test_best.outloaded):python evaluation.pyTo load and test a specific network:python neat_test.py -i demo/swingup.outData Gathering and VisualizationData about each run is stored by default in thelogfolder with thetestprefix, though a new prefix can be specified:python evolution.py -o myExperiment_Output files will still be placed in the 'log' folder but prepended with the 'myExperiment_' prefixIn addition to the best performing individual, prettyNEAT regularly updates a_stats.outfile with run statistics. These statistics are stored as comma seperated values, and some helper functions are shown to display these statistics as well as the topology of the evolved networks.seeprettyNeat_demo.ipynbnotebook for example usage.Distributed evaluationprettyNeat uses an ask/tell pattern to handle parallelization:neat = Neat(hyp)  # Initialize Neat with hyperparameters
  for gen in range(hyp['maxGen']):        
    pop = neat.ask()            # Get newly evolved individuals from NEAT  
    reward = batchMpiEval(pop)  # Send population to workers to evaluate
    neat.tell(reward)           # Send fitness values back to NEATThe number of workers can be specified when called from the command line:python evo_distributed.py -n 8Algorithm hyperparameters are stored in a .json file. Default parameters specified with-d, modification with a-p:python evo_distributed.py -d config/neat_default.jsonor to use default except for certain changespython evo_distributed.py -p config/swingup.json       # Swing up with standard parameters
python evo_distributed.py -p config/swing_allAct.json  # Swing up but allow hidden nodes to have several activationsThe full list of hyperparameters is explained inhypkey.txtExtensions and Differences from Canonical NEATA few key differences and common extensions from the original NEAT paper have been included:Compatibility threshold updateThe compatibility threshold is regularly updated to keep the number of species near a desired number. Though use of this update is widespread and mentioned on theNEAT User's Page, to my knowledge it has never been explicitly mentioned in a publication.Activation functionsUnless a specific activation function to be used by all hidden nodes is specified in the hyperparameters, when a new node is created it can chosen from a list of activation functions defined by the task. A probability of mutating the activation function is also defined. This allows the code to easily handle extensions for HyperNEAT and CPPN experiments.Rank-based FitnessThe canonical NEAT uses raw fitness values to determine the relative fitness of individuals and species. This can cause scaling problems, and can't handle negative fitness values. PrettyNEAT instead ranks the population and assigns each individual a real-valued fitness based on this ranking.Multi-objectiveMany extensions of NEAT involve optimizing for additional objectives (age, number of connections, novelty, etc) and we include non-dominated sorting of the population by multiple objectives. The probability that these alternate objectives are applied can also be tuned (e.g. normal optimization, but 20% chance of ranking based on fitnessandnumber of connections). This can be used with or without speciation.Weight Tuning with CMA-ESNetworks produced by PrettyNEAT are exported in the form of weight matrices and a vector of activation functions. We provide an interface to further tune the weights of these networks with CMA-ES:python cmaes.py -i log/test_best.outOther NEAT resourcesWeight Agnostic Neural Networks (WANN)NEAT SoftwareNEAT gymNEAT pythonPyTorch NEAT