DeepHyperNEAT
DeepHyperNEAT copied to clipboard
A public python implementation of the DeepHyperNEAT system for evolving neural networks. Developed by Felix Sosa and Kenneth Stanley. See paper here: https://eplex.cs.ucf.edu/papers/sosa_ugrad_report1...
Deep HyperNEAT: Extending HyperNEAT to Evolve the Architecture and Depth of Deep Networks
NOTE: This implementation is under development. Updates will be pushed over time, bringing in new functionality, tests, and various other elements. The purpose of this repo is to allow others to have a codebase to understand, use, or improve upon DeepHyperNEAT.
Using DeepHyperNEAT
To run DHN in its current form, you need to create a task file. For reference, see xor_study.py.
This task file must contain:
- Necessary imports:
rom genome import Genome # Genome class rom population import Population # Population class rom phenomes import FeedForwardCPPN # CPPN class rom decode import decode # Decoder for CPPN -> Substrate rom visualize import draw_net # optional, for visualizing networks - Substrate parameters
- Input dimensions
- Output dimensions
- Sheet dimensions (optional)
ub_in_dims = [1,2] # Is of type list ub_sh_dims = [1,3] # Is of type list ub_o_dims = 1 # Is of type integer - Evolutionary parameters
- Population size
- Population elitism
- Max number of generations
op_key = 0 # Key for population op_size = 150 op_elitism = 2 # Number of members of pop to keep each generation - The task (defined as a function in python)
- Task parameters:
- Task inputs
- Expected outputs (optional)
ef task(genomes): task_inputs = [1,2,3] expected_outputs = [2,4,6] for key, genome in genomes: cppn = CPPN.create(genome) # Create cppn from genome substrate = decode(cppn,sub_in_dims,sub_o_dims,sub_sh_dims) # Decode cppn into substrate error = 0.0 # Initialize error for current genome for inputs, expected in zip(xor_inputs, expected_outputs): inputs = inputs + (1.0,) # Append inputs with bias value actual_output = substrate.activate(inputs)[0] # Query substrate error += error_func(actual_output,expected) # Evaluate error genome.fitness = 1.0 - error # Assign fitness - Task parameters:
- A call to DHN to attempt to solve the task
op = Population(pop_key, pop_size, pop_elitism) olution = pop.run(task,num_generations) # Returns the solution to the task
Primary Modules
These modules are associated with the primary function of the DeepHyperNEAT (DHN) algorihtm.
genome.py
Contains all functionality of the genome, a Compositional Pattern Producing Network (CPPN) and its mutation operators.
phenomes.py
Contains multiple representations for feed-forward and recurrent neural networks for the CPPN and the Substrate.
population.py
Contains all functionality and information of the populations used in DHN.
activations.py
A library of activation functions that can be used for the CPPN and Substrate.
reproduction.py
Contains all functionality needed for the reproductive behavior in DHN.
species.py
Contains all functionality needed for speciation in DHN.
stagnation.py
Contains all functionality needed for stagnation schemes used in speciation.
decode.py
Contains all functionality needed to decode a given CPPN into a Substrate.
Secondary Modules
These modules are intended for secondary functionality such as reporting evolutionary statistics, visualizing the CPPN and Substrate, and various utility functions used throughout the primary modules.
reporters.py
Contains various functions for reporting evolutionary statistics during and after an evolutionary run.
visualize.py
Contains functions for visualizing a CPPN or Substrate.
util.py
Contains common functions and iterators used throughout DHN.