Training the network by evolution 0.25 −0.99 0.96 0.94 0.23 0.44 x₁ x₂ h₁, b₁ = 0.05 h₂, b₂ = −0.44 ŷ, c = −0.15 ŷ = 0.54, 0.55, 0.56, 0.57; target 0, 1, 1, 0
The small network from unit 5: two inputs, two hidden neurons, one output. It has 9 numbers: 6 weights on the edges and 3 biases on the nodes. Backpropagation set these numbers with gradients. This time there is no gradient: an individual is the list of these 9 numbers, so its chromosome is made of numbers instead of bits. The network on the scene is the first random individual, with fitness 0.748.
A random population 0.90 −0.74 −0.67 −0.22 −0.20 −0.35 x₁ x₂ h₁, b₁ = 0.96 h₂, b₂ = −0.76 ŷ, c = 0.32 ŷ = 0.52, 0.53, 0.52, 0.53; target 0, 1, 1, 0
The population has 20 individuals, every number random between −1 and 1. Fitness is 1 minus the mean squared error on the four XOR inputs, at most 1. The scene shows the best of the population: fitness 0.750, and 2 of the four inputs are classified correctly.
Crossover and mutation 0.09 −0.43 0.24 0.32 0.98 0.46 x₁ x₂ h₁, b₁ = 1.26 h₂, b₂ = −0.52 ŷ, c = 0.01 ŷ = 0.72, 0.71, 0.73, 0.72; target 0, 1, 1, 0
Two parents were chosen by tournament, with fitness 0.749 and 0.745. The child took the first 3 numbers from the first parent and the rest from the second. Mutation does not flip bits; it adds a small number from a normal distribution to the chosen gene. Genes changed in this child: 4; its fitness is 0.701.
Generation 1 −0.93 0.57 −0.51 −0.70 0.03 −0.35 x₁ x₂ h₁, b₁ = −0.23 h₂, b₂ = −0.76 ŷ, c = 0.02 ŷ = 0.48, 0.49, 0.49, 0.50; target 0, 1, 1, 0
The best individual of generation 1 is on the scene: fitness 0.751, and 2 of the four inputs are correct. The best individual is kept as it is every generation, so the best fitness never drops.
Generation 10 −2.32 0.65 −0.51 0.71 0.93 0.74 x₁ x₂ h₁, b₁ = −0.71 h₂, b₂ = −1.28 ŷ, c = −0.28 ŷ = 0.55, 0.61, 0.47, 0.50; target 0, 1, 1, 0
The best individual of generation 10 is on the scene: fitness 0.754, and 2 of the four inputs are correct. The best individual is kept as it is every generation, so the best fitness never drops.
Generation 25 −2.55 1.50 −1.00 1.50 1.67 −0.88 x₁ x₂ h₁, b₁ = −1.12 h₂, b₂ = 0.94 ŷ, c = 0.27 ŷ = 0.51, 0.61, 0.47, 0.43; target 0, 1, 1, 0
The best individual of generation 25 is on the scene: fitness 0.780, and 2 of the four inputs are correct. The best individual is kept as it is every generation, so the best fitness never drops.
Generation 50 −3.48 2.90 −1.65 2.57 3.58 −1.98 x₁ x₂ h₁, b₁ = −2.05 h₂, b₂ = 0.60 ŷ, c = 0.41 ŷ = 0.39, 0.73, 0.48, 0.27; target 0, 1, 1, 0
The best individual of generation 50 is on the scene: fitness 0.858, and 3 of the four inputs are correct. The best individual is kept as it is every generation, so the best fitness never drops.
Generation 100 −6.66 4.32 −5.23 5.38 8.34 −6.06 x₁ x₂ h₁, b₁ = −2.76 h₂, b₂ = 2.18 ŷ, c = 2.62 ŷ = 0.09, 0.97, 0.91, 0.05; target 0, 1, 1, 0
The best individual of generation 100 is on the scene: fitness 0.995, and 4 of the four inputs are correct. The best individual is kept as it is every generation, so the best fitness never drops.
The network learned XOR −6.66 4.32 −5.23 5.38 8.34 −6.06 x₁ x₂ h₁, b₁ = −2.76 h₂, b₂ = 2.18 ŷ, c = 2.62 ŷ = 0.09, 0.97, 0.91, 0.05; target 0, 1, 1, 0
The network first classified all four inputs correctly in generation 34. After 100 generations the fitness is 0.995. No derivative was taken; only selection, crossover and mutation were used.
Gradient or evolution −6.66 4.32 −5.23 5.38 8.34 −6.06 x₁ x₂ h₁, b₁ = −2.76 h₂, b₂ = 2.18 ŷ, c = 2.62 ŷ = 0.09, 0.97, 0.91, 0.05; target 0, 1, 1, 0
Backpropagation computes at every step in which direction each weight should change; evolution does not know this and moves by trial and error. That is why backpropagation is much faster for networks with millions of weights. The strength of evolution is that it needs no derivative: it is used for models that cannot be differentiated and in reinforcement learning, where the reward only comes at the end of a game.