XOR Example
Watch NEAT evolve a neural network that solves the classic XOR problem — a non-linearly-separable benchmark that a simple perceptron cannot solve.
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, then explore the best genome after training completes. Node colors: blue = input, red = bias, green = hidden, orange = output.