pengowen123 / cge

An implementation of the CGE neural network encoding, written in Rust.
Apache License 2.0
3 stars 2 forks source link

fixed a bug when computing a jump forward connection value. #2

Closed MathisWellmann closed 3 years ago

MathisWellmann commented 3 years ago

Before it would include the neuron weight and also the weight of jump forward which leads to wrong results. See the test "test_genome_is_correct" which is a genome from the phd paper on EANT and has weights other than one. In the original Test "test_network_eval" this bug was not noticed as all the weight are 1.0 meaning the neuron connection weight had no influence on the jump forward connection. I used Figure 5.3 in the paper (link in network::tests) to compute the network output manually and checked it twice for correctness. The important line from the paper is on page 101: " Finally, push the result of computation with the weight associated with forward jumper node onto the stack", which was not the case in original implementation ( as it also multiplied by regular neuron connection weight) The original test still works fine. Sorry for all the unnecessary line changes, my IDE (CLion) does this automatically.

MathisWellmann commented 3 years ago

run the test with "RUST_LOG=debug cargo test -- --nocapture test_genome_is_correct" if you would like to see the stack after each computation, that's how I spotted the bug in the first place :1234:

MathisWellmann commented 3 years ago

The newly added test was able to reproduce the bug you mentioned and it got fixed by adding a new condition. Here is the TEST_GENOME_2 on paper with the manual computations like in test "jump_recurrent_is_correct": https://www.dropbox.com/s/sxdtvfrb3h0sv1f/20200930_095539.jpg?dl=0

pengowen123 commented 3 years ago

Thanks!