Skip to content
NEAT-JavaScript
NEAT-JavaScript
On this page

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 1Input 2Output
000
011
101
110

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.

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.

Generation
0
Best fitness
0.00
Species
0
Status
Loading…
[0, 0]
-
Expected: 0
[0, 1]
-
Expected: 1
[1, 0]
-
Expected: 1
[1, 1]
-
Expected: 0