From 7825b92ce3be95a0ce1dfea9388adbaadce83b1f Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 12 Nov 2023 15:18:29 -0600 Subject: fix bugs --- src/mind/topology.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/mind') diff --git a/src/mind/topology.js b/src/mind/topology.js index 9f2569d..946dd86 100644 --- a/src/mind/topology.js +++ b/src/mind/topology.js @@ -131,6 +131,13 @@ function get_value(n, index, input, prev, cache) { const sum = values // compute the weighted sum of the values .reduce((acc, x, i) => acc + (weight[i] * x), 0); + if (sum !== sum) { // NaN test + console.log(n); + console.log(sources); + console.log(input); + throw new Error(`failed to get output for index ${index}`); + } + // compute result const value = Math.tanh(sum); @@ -139,7 +146,7 @@ function get_value(n, index, input, prev, cache) { if (cache !== undefined) { cache[index] = value; } - + return value; } -- cgit v1.2.1