jeffheaton / encog-java-core

http://www.heatonresearch.com/encog
Other
742 stars 268 forks source link

Weight calculation for HyperNEAT is flawed? #236

Closed willhs closed 7 years ago

willhs commented 7 years ago

Hi.

In HyperNEATCODEC.java weights for all connections in a substrate are computed using an individual's CPPN. Weight is calculated as follows:

  1. First a scaling value c is computed at this line
  2. Later, weight is scaled here using c.

I believe this scaling is supposed to be from the range [minWeight, maxWeight] to [0, maxWeight], but this code will cause a different result: for example if minWeight = 0.2, maxWeight = 5, and weight = 2, then c will be 6.25 and the updated weight will be 11.25 which is above the maxWeight and so shouldn't be allowed.

I tried to find a quote from a HyperNEAT paper about this scaling but only found this rather unspecific quote from the paper entitled "Autonomous Evolution of Topographic Regularities in Artificial Neural Networks" (by Stanley et al. 2008):

create the connection with a weight scaled proportionally to the output value

A way to scale this correctly might be use the scaling function found in this stackoverflow answer. If I have made any mistakes or wrong assumptions, let me know.

jeffheaton commented 7 years ago

Thank you for the information. I will try to look into this soon for Encog 3.4.

jeffheaton commented 7 years ago

I've actually seen it done this way in a number of the NEAT implementations. I can't find the original C++ implementation that I based my code on, but will check further.

You can see a similar implementation to mine here:

https://github.com/colgreen/sharpneat/blob/master/src/SharpNeatLib/Decoders/HyperNeat/Substrate.cs

Is the current implementation causing an issue for your program?