Created
March 23, 2023 22:24
-
-
Save esshka/e4b96ffbf748ae0aeff1b21bd1d099b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calculateFitness(network, data) { | |
let fitness = 0; | |
for (const { input, output } of data) { | |
const prediction = network.propagate(input); | |
const error = output[0] - prediction[0]; | |
fitness += 1 - Math.abs(error * error); | |
} | |
// Normalize the fitness value by dividing it by the number of data points | |
return fitness / data.length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment