Back to Blog
Machine Learning November 28, 2024 9 min read

NEAT Algorithm: Evolving Neural Networks Without Backprop

How NEAT evolves both the weights and topology of neural networks — speciation, crossover, innovation numbers, and implementing it for game AI.

What Makes NEAT Special

Unlike standard NNs, NEAT starts with minimal networks and adds complexity only when needed. This prevents bloat and finds efficient solutions.

Core Concepts

Speciation

Networks are grouped into species based on structural similarity. Each species competes internally, preserving diversity.

Innovation Numbers

Every new structural mutation (new connection/node) gets a unique global innovation number. This allows meaningful crossover between different topologies.

Fitness Sharing

Fitness is divided by species size to prevent any one species from dominating.

Python Implementation (neat-python)

import neat

config = neat.Config(
    neat.DefaultGenome,
    neat.DefaultReproduction,
    neat.DefaultSpeciesSet,
    neat.DefaultStagnation,
    'config-feedforward'
)

def eval_genomes(genomes, config):
    for genome_id, genome in genomes:
        net = neat.nn.FeedForwardNetwork.create(genome, config)
        genome.fitness = run_game(net)  # your game/simulation

population = neat.Population(config)
population.run(eval_genomes, n=1000)
NEATNeuroevolutionGenetic AlgorithmGame AIEvolutionary Computing
O

Ossama Elhakki

AI Engineer & ML Systems Builder — Morocco