a hitchhiker’s guide to neuroevolution in erlang

156
Jeroen Soeters NEUROEVOLUTION A hitchhiker’s guide to neuroevolution in Erlang.

Upload: thoughtworks

Post on 11-Apr-2017

1.260 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: A hitchhiker’s guide to neuroevolution in Erlang

J e r o e n S o e t e r s

NEUROEVOLUTIONA hitchhiker’s guide to neuroevolution in

Erlang.

Page 2: A hitchhiker’s guide to neuroevolution in Erlang

MEET GARY

2

Page 3: A hitchhiker’s guide to neuroevolution in Erlang

WHAT IS MACHINE LEARNING?

• Artificial Neural Networks • Genetic Algorithms

3

Page 4: A hitchhiker’s guide to neuroevolution in Erlang

ARTIFICIAL NEURAL NETWORKS

4

Page 5: A hitchhiker’s guide to neuroevolution in Erlang

BIOLOGICAL NEURAL NETWORKS

5

Dendrites

SomaAxon

Synapse

Page 6: A hitchhiker’s guide to neuroevolution in Erlang

A MODEL FOR A NEURON

6

Y

w1

w2

wn

x1

x2

xn

Dendrites Synapses Axon

Soma

Page 7: A hitchhiker’s guide to neuroevolution in Erlang

A MODEL FOR A NEURON

6

Y

w1

w2

wn

x1

x2

xn

Input signals Weights Output signal

Neuron

Page 8: A hitchhiker’s guide to neuroevolution in Erlang

HOW DOES THE NEURON DETERMINE IT’S OUTPUT?

Y =sign ∑ xiwi - ⍬

7

n=1

n

Page 9: A hitchhiker’s guide to neuroevolution in Erlang

ACTIVATION FUNCTION

8

X

Y

Page 10: A hitchhiker’s guide to neuroevolution in Erlang

MEET FRANK

9

Page 11: A hitchhiker’s guide to neuroevolution in Erlang

PERCEPTRON LEARNING RULE

℮(p) = Yd(p) - Y(p)

wi(p + 1) = wi(p) + α • wi(p) • ℮(p) =

10

Page 12: A hitchhiker’s guide to neuroevolution in Erlang

PERCEPTRON TRAINING ALGORITHM

11

weight training

start

stopweights converged? yes

no

set weights and threshold to random values [-0.5, 0.5]

activate the perceptron

Page 13: A hitchhiker’s guide to neuroevolution in Erlang

LOGIC GATES

12

input values x1 x2 x1 AND x2 x1 OR x2 x1 XOR x2

0 0 0 0 0

0 1 0 1 1

1 0 0 1 1

1 1 1 1 0

Page 14: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

Page 15: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

Page 16: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

Page 17: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.3 -0.1

Page 18: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0 0.3

Page 19: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0 -0.1

Page 20: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0

Page 21: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

00

Page 22: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0

Page 23: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.3 -0.1

Page 24: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0 0.3

Page 25: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

1 -0.1

Page 26: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0

Page 27: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

00

Page 28: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0

Page 29: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.3 -0.1

Page 30: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

1 0.3

Page 31: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0 -0.1

Page 32: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

1

Page 33: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

10

Page 34: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

-1

Page 35: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.2 -0.1

Page 36: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

1 0.2

Page 37: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

1 -0.1

Page 38: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0

Page 39: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

01

Page 40: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

1

Page 41: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

13

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

1

0 0 0 0.3 -0.1 0 0 0.3 -0.1

0 1 0 0.3 -0.1 0 0 0.3 -0.1

1 0 0 0.3 -0.1 1 -1 0.2 -0.1

1 1 1 0.2 -0.1 0 1 0.3 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.3 0.0

Page 42: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

14

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

2

0 0 0 0.3 0.0 0 0 0.3 0.0

0 1 0 0.3 0.0 0 0 0.3 0.0

1 0 0 0.3 0.0 1 -1 0.2 0.0

1 1 1 0.2 0.0 1 0 0.2 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.3 0.0

Page 43: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

14

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

2

0 0 0 0.3 0.0 0 0 0.3 0.0

0 1 0 0.3 0.0 0 0 0.3 0.0

1 0 0 0.3 0.0 1 -1 0.2 0.0

1 1 1 0.2 0.0 1 0 0.2 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.3 0.0

Page 44: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

14

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

2

0 0 0 0.3 0.0 0 0 0.3 0.0

0 1 0 0.3 0.0 0 0 0.3 0.0

1 0 0 0.3 0.0 1 -1 0.2 0.0

1 1 1 0.2 0.0 1 0 0.2 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.2 0.0

Page 45: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

14

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

2

0 0 0 0.3 0.0 0 0 0.3 0.0

0 1 0 0.3 0.0 0 0 0.3 0.0

1 0 0 0.3 0.0 1 -1 0.2 0.0

1 1 1 0.2 0.0 1 0 0.2 0.0

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.2 0.0

Page 46: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

15

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

3

0 0 0 0.2 0.0 0 0 0.2 0.0

0 1 0 0.2 0.0 0 0 0.2 0.0

1 0 0 0.2 0.0 1 -1 0.1 0.0

1 1 1 0.1 0.0 0 1 0.2 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.2 0.0

Page 47: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

15

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

3

0 0 0 0.2 0.0 0 0 0.2 0.0

0 1 0 0.2 0.0 0 0 0.2 0.0

1 0 0 0.2 0.0 1 -1 0.1 0.0

1 1 1 0.1 0.0 0 1 0.2 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.2 0.0

Page 48: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

15

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

3

0 0 0 0.2 0.0 0 0 0.2 0.0

0 1 0 0.2 0.0 0 0 0.2 0.0

1 0 0 0.2 0.0 1 -1 0.1 0.0

1 1 1 0.1 0.0 0 1 0.2 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.1 0.0

Page 49: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

15

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

3

0 0 0 0.2 0.0 0 0 0.2 0.0

0 1 0 0.2 0.0 0 0 0.2 0.0

1 0 0 0.2 0.0 1 -1 0.1 0.0

1 1 1 0.1 0.0 0 1 0.2 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.2 0.1

Page 50: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

16

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

4

0 0 0 0.2 0.1 0 0 0.2 0.1

0 1 0 0.2 0.1 0 0 0.2 0.1

1 0 0 0.2 0.1 1 -1 0.1 0.1

1 1 1 0.1 0.1 1 0 0.1 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.2 0.1

Page 51: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

16

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

4

0 0 0 0.2 0.1 0 0 0.2 0.1

0 1 0 0.2 0.1 0 0 0.2 0.1

1 0 0 0.2 0.1 1 -1 0.1 0.1

1 1 1 0.1 0.1 1 0 0.1 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.2 0.1

Page 52: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

16

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

4

0 0 0 0.2 0.1 0 0 0.2 0.1

0 1 0 0.2 0.1 0 0 0.2 0.1

1 0 0 0.2 0.1 1 -1 0.1 0.1

1 1 1 0.1 0.1 1 0 0.1 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.1 0.1

Page 53: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

16

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

4

0 0 0 0.2 0.1 0 0 0.2 0.1

0 1 0 0.2 0.1 0 0 0.2 0.1

1 0 0 0.2 0.1 1 -1 0.1 0.1

1 1 1 0.1 0.1 1 0 0.1 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.1 0.1

Page 54: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

17

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

5

0 0 0 0.1 0.1 0 0 0.1 0.1

0 1 0 0.1 0.1 0 0 0.1 0.1

1 0 0 0.1 0.1 0 0 0.1 0.1

1 1 1 0.1 0.1 1 0 0.1 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.1 0.1

Page 55: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

17

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

5

0 0 0 0.1 0.1 0 0 0.1 0.1

0 1 0 0.1 0.1 0 0 0.1 0.1

1 0 0 0.1 0.1 0 0 0.1 0.1

1 1 1 0.1 0.1 1 0 0.1 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.1 0.1

Page 56: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

17

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

5

0 0 0 0.1 0.1 0 0 0.1 0.1

0 1 0 0.1 0.1 0 0 0.1 0.1

1 0 0 0.1 0.1 0 0 0.1 0.1

1 1 1 0.1 0.1 1 0 0.1 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.1 0.1

Page 57: A hitchhiker’s guide to neuroevolution in Erlang

TRAINING A PERCEPTRON TO PERFORM THE AND OPERATION

17

epochinputs

x1 x2

desired output

Yd

initial weights

w1 w2

actual output

Yerror ℮

final weights

w1 w2

5

0 0 0 0.1 0.1 0 0 0.1 0.1

0 1 0 0.1 0.1 0 0 0.1 0.1

1 0 0 0.1 0.1 0 0 0.1 0.1

1 1 1 0.1 0.1 1 0 0.1 0.1

Threshold: ⍬ = 0.2 ; learning rate: α = 0.1 =

0.1 0.1

Page 58: A hitchhiker’s guide to neuroevolution in Erlang

A LITTLE GEOMETRY…

18

0 1

1

x2

x1 0 1

1

x2

x10 1

1

x2

x1

x1 AND x2 x1 OR x2 x1 XOR x2

Page 59: A hitchhiker’s guide to neuroevolution in Erlang

WE NEED MORE LAYERS

19

3

4

5

1

2

Input layer Hidden layer Output layer

x1

x2

Y

Page 60: A hitchhiker’s guide to neuroevolution in Erlang

PROBLEMS WITH BACK PROPAGATION

•a training set of sufficient size is required •topology of the network needs to be known in advance •no recurrent connections are allowed •activation function must be differentiable

Does not emulate the biological world

20

Page 61: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY COMPUTATION

21

Page 62: A hitchhiker’s guide to neuroevolution in Erlang

MEET JOHN

22

Page 63: A hitchhiker’s guide to neuroevolution in Erlang

THE CHROMOSOME

23

10 11 101 0

Page 64: A hitchhiker’s guide to neuroevolution in Erlang

1 1000 11 0

CROSSOVER

24

0 111 0 11 0 1 100 1 10 0

parents

Page 65: A hitchhiker’s guide to neuroevolution in Erlang

1 1000 11 0

CROSSOVER

24

0 111 0 11 0 1 100 1 10 0✂

parents

Page 66: A hitchhiker’s guide to neuroevolution in Erlang

1 1000 11 0

1 10 00 111

offspring

CROSSOVER

24

0 111 1 10 0✂

parents

Page 67: A hitchhiker’s guide to neuroevolution in Erlang

MUTATION

25

A D10 11 101 0

Page 68: A hitchhiker’s guide to neuroevolution in Erlang

MUTATION

25

A DA D10 11 101 01 0

Page 69: A hitchhiker’s guide to neuroevolution in Erlang

MUTATION

25

A DA D10 11 101 01 00 1

Page 70: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome •chose the initial population size N, crossover probability (Pc) and mutation probability (Pm)

•define a fitness function to measure the performance of the chromosome •define the genetic operators for the chromosome

26

Page 71: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

27

start

stop

generate a population

calculate fitness

termination criteria satisfied?

yes

no

new population size = N?

crossover and mutation

select pair for mating add to new population

replace population

no

yes

Page 72: A hitchhiker’s guide to neuroevolution in Erlang

TRAVELING SALESMAN

28

A

B

D

F

G

C

E

H

Page 73: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome •define a fitness function to measure the performance of the chromosome •define the genetic operators for the chromosome •chose the initial population size N, crossover probability Pc and mutation probability Pm

29

Page 74: A hitchhiker’s guide to neuroevolution in Erlang

THE CHROMOSOME

30

HG FE ABC D

Page 75: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome

•define a fitness function to measure the performance of the chromosome

•define the genetic operators for the chromosome •chose the initial population size N, crossover probability Pc and mutation probability Pm

31

Page 76: A hitchhiker’s guide to neuroevolution in Erlang

FITNESS FUNCTION

Fitness = 1 / total distance

32

Page 77: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome

•define a fitness function to measure the performance of the chromosome •define the genetic operators for the chromosome •chose the initial population size N, crossover probability Pc and mutation probability Pm

33

Page 78: A hitchhiker’s guide to neuroevolution in Erlang

CROSSOVER

34

G EBC H FA D A FEB H DC G

parents

Page 79: A hitchhiker’s guide to neuroevolution in Erlang

CROSSOVER

34

G EBC H FA D A FEB H DC G✂ ✂

parents

Page 80: A hitchhiker’s guide to neuroevolution in Erlang

H A D

offspring

CROSSOVER

34

G EBC H FA D A FEB H DC G✂ ✂

parents

Page 81: A hitchhiker’s guide to neuroevolution in Erlang

H A D

offspring

CROSSOVER

34

G EBC H FA D A FEB H DC G✂ ✂

parents

B

Page 82: A hitchhiker’s guide to neuroevolution in Erlang

H A D

offspring

CROSSOVER

34

G EBC H FA D A FEB H DC G✂ ✂

parents

B E

Page 83: A hitchhiker’s guide to neuroevolution in Erlang

H A D

offspring

CROSSOVER

34

G EBC H FA D A FEB H DC G✂ ✂

parents

B E F

Page 84: A hitchhiker’s guide to neuroevolution in Erlang

H A D

offspring

CROSSOVER

34

G EBC H FA D A FEB H DC G✂ ✂

parents

B E F C

Page 85: A hitchhiker’s guide to neuroevolution in Erlang

H A D

offspring

CROSSOVER

34

G EBC H FA D A FEB H DC G✂ ✂

parents

B E F C G

Page 86: A hitchhiker’s guide to neuroevolution in Erlang

MUTATION

35

HG FE ABC D

Page 87: A hitchhiker’s guide to neuroevolution in Erlang

MUTATION

35

HG FE ABC DA D

Page 88: A hitchhiker’s guide to neuroevolution in Erlang

MUTATION

35

HG FE ABC DA DAD

Page 89: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome

•define a fitness function to measure the performance of the chromosome •define the genetic operators for the chromosome •chose the initial population size N, crossover probability Pc and mutation probability Pm

36

Page 90: A hitchhiker’s guide to neuroevolution in Erlang

DEMO

37

Page 91: A hitchhiker’s guide to neuroevolution in Erlang

DEMO

37

Page 92: A hitchhiker’s guide to neuroevolution in Erlang

NEUROEVOLUTION

38

Page 93: A hitchhiker’s guide to neuroevolution in Erlang

MEET GENE

39

Page 94: A hitchhiker’s guide to neuroevolution in Erlang

SIMULATION

•inputs (sensors) •outputs (actuators) •fitness function

40

Page 95: A hitchhiker’s guide to neuroevolution in Erlang

CLEANING ROBOT

41

Page 96: A hitchhiker’s guide to neuroevolution in Erlang

FOREX TRADING

42

Page 97: A hitchhiker’s guide to neuroevolution in Erlang

AND LOTS MORE…

•data compression •training NPCs in a video game •cyber warfare

43

Page 98: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome •define a fitness function to measure the performance of the chromosome •define the genetic operators for the chromosome •chose the initial population size N, crossover probability Pc and mutation probability Pm

44

Page 99: A hitchhiker’s guide to neuroevolution in Erlang

THE CHROMOSOME

45

Page 100: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome

•define a fitness function to measure the performance of the chromosome

•define the genetic operators for the chromosome •chose the initial population size N, crossover probability Pc and mutation probability Pm

46

Page 101: A hitchhiker’s guide to neuroevolution in Erlang

FITNESS FUNCTION

Fitness = performance of network on an actual problem

47

Page 102: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome

•define a fitness function to measure the performance of the chromosome •define the genetic operators for the chromosome •chose the initial population size N, crossover probability Pc and mutation probability Pm

48

Page 103: A hitchhiker’s guide to neuroevolution in Erlang

CROSSOVER

Crossover doesn’t work for large neural nets!

49

Page 104: A hitchhiker’s guide to neuroevolution in Erlang

MUTATE ACTIVATION FUNCTION

50

Page 105: A hitchhiker’s guide to neuroevolution in Erlang

MUTATE ACTIVATION FUNCTION

50

Page 106: A hitchhiker’s guide to neuroevolution in Erlang

ADD CONNECTION

51

Page 107: A hitchhiker’s guide to neuroevolution in Erlang

ADD CONNECTION

51

Page 108: A hitchhiker’s guide to neuroevolution in Erlang

ADD NEURON

52

Page 109: A hitchhiker’s guide to neuroevolution in Erlang

ADD NEURON

52

Page 110: A hitchhiker’s guide to neuroevolution in Erlang

OUTSPLICE

53

Page 111: A hitchhiker’s guide to neuroevolution in Erlang

OUTSPLICE

53

Page 112: A hitchhiker’s guide to neuroevolution in Erlang

MUTATION OPERATORS

and lots more…

54

Page 113: A hitchhiker’s guide to neuroevolution in Erlang

EVOLUTIONARY ALGORITHM

•represent the candidate solution as a chromosome

•define a fitness function to measure the performance of the chromosome •define the genetic operators for the chromosome •chose the initial population size N, crossover probability Pc and mutation probability Pm

55

Page 114: A hitchhiker’s guide to neuroevolution in Erlang

RANDOM IMPACT MUTATION

Number of mutations = random(1, network size)

56

Page 115: A hitchhiker’s guide to neuroevolution in Erlang

MEMETIC ALGORITHM

57

apply to a problem

start

generate a population

local search: Hill Climber calculate effective fitness

select fit organisms

create offspring

Page 116: A hitchhiker’s guide to neuroevolution in Erlang

STOCHASTIC HILL CLIMBER (LOCAL SEARCH)

58

start

new fitness > old fitness?

yes

no

stopping condition reached?

stop

apply NN to a problem

backup and perturb weights restore backed-up weights

Page 117: A hitchhiker’s guide to neuroevolution in Erlang

A LANGUAGE FOR NEUROEVOLUTION

•The system must be able to handle very large numbers of concurrent activities

•Actions must be performed at a certain point in time or within a certain time

•Systems may be distributed over several computers

•The system is used to control hardware

•The software systems are very large

59

Page 118: A hitchhiker’s guide to neuroevolution in Erlang

A LANGUAGE FOR NEUROEVOLUTION

59

•The system exhibits complex functionality such as, feature interaction.

•The systems should be in continuous operation for many years.

•Software maintenance (reconfiguration, etc) should be performed without stopping the system.

•There are stringent quality, and reliability requirements.

•Fault tolerance

Page 119: A hitchhiker’s guide to neuroevolution in Erlang

A LANGUAGE FOR NEUROEVOLUTION

59

•The system exhibits complex functionality such as, feature interaction.

•The systems should be in continuous operation for many years.

•Software maintenance (reconfiguration, etc) should be performed without stopping the system.

•There are stringent quality, and reliability requirements.

•Fault tolerance

Bjarne Dacker. Erlang - A New Programming Language. Ericsson Review, no 2, 1993.

Page 120: A hitchhiker’s guide to neuroevolution in Erlang

MEET JOE

60

Page 121: A hitchhiker’s guide to neuroevolution in Erlang

1:1 MAPPING

61

neuron

neuronneuron

neuron

process process

process process

processprocess

genotype

erlang

Page 122: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

Page 123: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

sync

Page 124: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scapesense

Page 125: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

percept

Page 126: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

forward

forward

Page 127: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

forward

forward

Page 128: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

forward

forward

Page 129: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scapeaction

Page 130: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

{fitness, halt_flag}

Page 131: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

sync

Page 132: A hitchhiker’s guide to neuroevolution in Erlang

THE NEURAL NETWORK

62

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

Page 133: A hitchhiker’s guide to neuroevolution in Erlang

THE EXOSELF

63

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

exoself

cortex

Page 134: A hitchhiker’s guide to neuroevolution in Erlang

THE EXOSELF

63

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

exoself

{evaluation_completed, fitness}

cortex

Page 135: A hitchhiker’s guide to neuroevolution in Erlang

THE EXOSELF

63

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

exoself

cortex

fitness > best fitness

Page 136: A hitchhiker’s guide to neuroevolution in Erlang

THE EXOSELF

63

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

exoself

backup_weights

backup_weights

backup_weights

backup_weights

neuron neuron

neuronneuron

Page 137: A hitchhiker’s guide to neuroevolution in Erlang

THE EXOSELF

63

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

exoself

neuron

neuron

perturb_weights

perturb_weights

Page 138: A hitchhiker’s guide to neuroevolution in Erlang

THE EXOSELF

63

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

exoself

cortex

Page 139: A hitchhiker’s guide to neuroevolution in Erlang

THE EXOSELF

63

neuron

neuronneuron

actuatorsensor

neuron

cortex

scape

exoself

cortex

reactivate

Page 140: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

Page 141: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

private private privateprivate private

Page 142: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

private private privateprivate private

start

start start start

start

Page 143: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

private private privateprivate private

Page 144: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

private private privateprivate private

terminated

terminated terminated

terminated

terminated

Page 145: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

private private privateprivate private

Page 146: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

private privateprivate

Page 147: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

private privateprivate private private

Page 148: A hitchhiker’s guide to neuroevolution in Erlang

THE POPULATION MONITOR

64

population monitordatabase

private privateprivate private private

start

start start start

start

Page 149: A hitchhiker’s guide to neuroevolution in Erlang

THE DEVIL IS IN THE DETAILS

•recurrent connections •newer generations get a higher chance for mutation •neural plasticity •public scapes and steady state evolution

65

Page 150: A hitchhiker’s guide to neuroevolution in Erlang

POLE BALANCING

66

agent

cartactions

percepts

Page 151: A hitchhiker’s guide to neuroevolution in Erlang

DEMO

67

Page 152: A hitchhiker’s guide to neuroevolution in Erlang

DEMO

67

Page 153: A hitchhiker’s guide to neuroevolution in Erlang

BENCHMARK RESULTS

68

Method Single-Pole/Incomplete state information

Double-Pole/Partial Information W/O Damping

Double-Pole W/Damping

RWG 8557 415209 1232296

SANE 1212 262700 451612

CNE* 724 76906* 87623*

ESP 589 7374 26342

NEAT - - 6929

CMA-ES* - 3521* 6061*

CoSyNE* 127* 1249* 3416*

DXNN not performed 2359 2313

Our System 647 5184 4792

Page 154: A hitchhiker’s guide to neuroevolution in Erlang

THE HANDBOOK

69

Page 155: A hitchhiker’s guide to neuroevolution in Erlang

Feel free to reach out at:

e. [email protected] t. @JeroenSoeters

THANK YOU

Page 156: A hitchhiker’s guide to neuroevolution in Erlang

DATA SCIENCE AND ENGINEERING

71