CodeReclaimers / neat-python

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

Add `abs` to decrement of fitness in eval_genomes #260

Closed brentspine closed 1 year ago

brentspine commented 1 year ago

Let's say we test xor_inputs[1] in the current iteration. The expected output would be xor_outputs[1], meaning 1. output = net.activate(xi) will now let the model predict an output. In our example, the model predicts 0. Based on that the following line should remove fitness for the wrong guess. Though through the fact, xo[0] would be 1 and output would be 0, the line genome.fitness -= (output[0] - xo[0]) ** 2 would not decrease the genome.fitness variable but rather increase it.

brentspine commented 1 year ago

Bump

CodeReclaimers commented 1 year ago

As long as output[0] and xo[0] are floats, (output[0] - xo[0]) ** 2 should always be positive, so there's no need for the abs. Does this seem right or am I missing something?

brentspine commented 1 year ago

Oh yes then it's my misunderstanding