NeuroEvolution of Augmenting Topologies (NEAT) evolves neural networks as populations rather than training one fixed design with backpropagation. A candidate genome can change weights, add or remove connections, and change the number of nodes, so the network architecture itself develops over generations. This makes NEAT a configuration-driven approach to searching hyperparameters, parameters, topology, and even node behavior such as activation or aggregation. section 1.5.5 section 10.0 section 10.6
Compare a conventional layered network with an evolved graph whose connections and node positions have changed. section 10.0
Instead of assuming hidden nodes belong to clean layers, NEAT treats a network as an evolving graph with input, output, and middle nodes. A genome is instantiated as a network, activated on task inputs, and assigned fitness from its outputs. Evolution then favors fitter genomes. For XOR, fitness starts at 4.0 and subtracts squared error for each expected output; for classification, fitness can use balanced accuracy; for an environment agent, it can accumulate rewards across simulation runs. section 10.1 section 10.4 section 11.3
A practical NEAT-Python workflow is:
- Install and import NEAT-Python, then prepare inputs and expected outputs or an environment interface. section 10.1
- Write an evaluation function that creates a feed-forward network from each genome, activates it, and records fitness. section 10.1
- Configure population size, fitness threshold, inputs and outputs, initial connections, mutation probabilities, and activation options. section 10.1 section 10.3
- Create a population, optionally attach reporters, run evolution, then instantiate and inspect the winning genome. section 10.1 section 10.3
From XOR to image classification
A small XOR run establishes the loop: evolve a population, convert the winner to a feed-forward network, and compare its outputs with all four truth-table cases. The same pattern scales to moons and circles datasets by changing the fitness target and configuration. An MNIST exercise raises inputs to 784, uses 10 outputs, begins with full direct connections, evaluates random image batches, and scores predictions with balanced accuracy. These examples also expose a limitation: NEAT can perform image classification, but results are limited. section 10.1 section 10.3 section 10.4 section 10.6
Speciation keeps similar genomes in groups while preserving population diversity. Diversity matters because a population can become overly specialized around local minima or maxima. Compatibility distance controls separation between species, while maximum stagnation controls how long a species can fail to improve before extinction. Culling stagnant species frees space for new groups within a fixed population, but the many interacting configuration options can make difficult problems harder to evolve. section 10.5 section 10.5.1 section 10.5.2
Evolving a Gym agent
For an OpenAI Gym task, configure NEAT inputs from the observation-space size and outputs from the action-space size. Activate the genome network on each state, select the action index from its output, step the environment, and sum rewards as fitness. This uses an RL environment, but selection is driven by evolutionary evaluation rather than an agent learning directly from rewards. Parallel evaluation can score genomes across CPU cores. section 11.3 section 11.3
