CodeReclaimers / neat-python

Python implementation of the NEAT neuroevolution algorithm
BSD 3-Clause "New" or "Revised" License
1.4k stars 488 forks source link

Creates populations bigger or smaller than set in config #258

Open havietisov opened 1 year ago

havietisov commented 1 year ago

when initial_connection value in the config set to fs_neat_hidden, partial_direct, full_direct, and and num_hidden is other than zero, creates population of size, different from what is set in config, on windows version specifically

To Reproduce Steps to reproduce the behavior:

  1. Set population count to, lets say, 200
  2. set num_hidden to 2
  3. run for a while
  4. you will eventually witness populations getting bigger or smaller than 200

Expected behavior Population to be exactly of a size set in config

Screenshots I hope log would be enough


Population's average fitness: -169.37399 stdev: 104.98072
Best fitness: 7.59671 - size: (3, 3) - species 1 - id 306
Average adjusted fitness: 0.580
Mean genetic distance 2.391, standard deviation 0.551
Population of 200 members in 3 species:
   ID   age  size  fitness  adj fit  stag
  ====  ===  ====  =======  =======  ====
     1    1    73   -156.5    0.527     0
     2    1   117    -73.0    0.767     0
     3    1    10   -183.9    0.447     0
Total extinctions: 0
Generation time: 4.611 sec (6.612 average)

 ****** Running generation 2 ******

Population's average fitness: -81.61679 stdev: 77.83935
Best fitness: 7.45752 - size: (3, 3) - species 1 - id 503
Average adjusted fitness: 0.647
Mean genetic distance 2.223, standard deviation 0.770
Population of 200 members in 3 species:
   ID   age  size  fitness  adj fit  stag
  ====  ===  ====  =======  =======  ====
     1    2    72    -96.3    0.687     0
     2    2    98    -65.1    0.781     0
     3    2    30   -167.3    0.473     0
Total extinctions: 0
Generation time: 4.662 sec (5.962 average)

 ****** Running generation 3 ******

Population's average fitness: -67.03078 stdev: 67.50329
Best fitness: 7.65170 - size: (4, 4) - species 2 - id 786
Average adjusted fitness: 0.764
Mean genetic distance 2.069, standard deviation 0.884
Population of 199 members in 3 species:
   ID   age  size  fitness  adj fit  stag
  ====  ===  ====  =======  =======  ====
     1    3    71    -50.1    0.819     0
     2    3    81    -76.9    0.735     1
     3    3    47    -75.4    0.740     0
Total extinctions: 0
Generation time: 4.590 sec (5.619 average)

Desktop:

KristianTve commented 1 year ago

I have been having the exact same issue. It happens usually at generation two for me if i start out with two hidden nodes. If i start out with one hidden nodes, the population size diverges from the configured number after 10-100 generations.

I also have had this happen when loading a checkpoint, NEAT overwriting it initially, stopping training and then re-load from that overwritten checkpoint.

bable631 commented 1 year ago

I have hidden nodes set to 20, and it is immediately the wrong size (I want 250 per generation and got 546 in the first generation)

This software is completely unusable for me if this bug is not fixed.