Creating the initial population
plonerma opened this issue · comments
Max Ploner commented
Hello,
I think there is an issue with how the initial population is created at the moment. In this line np.tile
should be replaced with np.repeat
.
Let's assume we have 3 input (+1 bias) nodes and 4 output nodes. Then, the algorithm will do the following steps (a little bit simplified):
ins = np.arange(4)
outs = np.arange(4) + 4
conn = np.empty((2, 16))
conn[0,:] = np.tile(ins, len(outs))
conn[1,:] = np.tile(outs,len(ins))
This will result in these connections:
array([[0., 1., 2., 3., 0., 1., 2., 3., 0., 1., 2., 3., 0., 1., 2., 3.],
[4., 5., 6., 7., 4., 5., 6., 7., 4., 5., 6., 7., 4., 5., 6., 7.]])
The first input node is connected 4 times to the first output node, but no other. Using np.tile
once and np.repeat
once leads to the desired results (each input connected to each output):
array([[0., 1., 2., 3., 0., 1., 2., 3., 0., 1., 2., 3., 0., 1., 2., 3.],
[4., 4., 4., 4., 5., 5., 5., 5., 6., 6., 6., 6., 7., 7., 7., 7.]])
adam commented
you're right, good catch! fixed.