XOR Example

This example demonstrates how NEAT evolves neural networks to solve the classic XOR problem. The XOR (exclusive OR) logical operation returns true only when inputs differ, making it a fundamental benchmark for neural networks because it is not linearly separable.

What is XOR?

XOR is a logical operation that takes two binary inputs and returns a binary output. It returns 1 only when exactly one input is 1:

Input 1 Input 2 Output
0 0 0
0 1 1
1 0 1
1 1 0

XOR cannot be solved by a simple perceptron (a neural network without hidden layers), which makes it an interesting problem for demonstrating the power of NEAT's ability to evolve network topologies.

Note

XOR is included in the default configuration of NEAT-JavaScript, making it easy to experiment with this example without extensive setup.

Interactive Demo

Try the interactive demo below to see NEAT evolve a solution to the XOR problem in real-time. Click "Start Learning" to begin the evolution process, and explore the best genome after training is complete.

Training Statistics

Generation: 0

Best Fitness: 0.0

Species Count: 0

Status: Not started

Genome Visualization

Test Results

Input: [0, 0]

-
Expected: 0

Input: [0, 1]

-
Expected: 1

Input: [1, 0]

-
Expected: 1

Input: [1, 1]

-
Expected: 0