diff --git a/sam-neurons-words.js b/sam-neurons-words.js index fb4737b..1cf623a 100644 --- a/sam-neurons-words.js +++ b/sam-neurons-words.js @@ -92,7 +92,6 @@ class NeuralNetwork { } // Example usage: -let nn = new NeuralNetwork(3, 4, 1); // Increased hidden nodes to 4 // Example dataset (XOR problem) let strings = ["hello", "neural", "world"] @@ -103,6 +102,9 @@ let inputs = [ [1, 0, 1], [1, 1, 1] ]; + +let nn = new NeuralNetwork(strings.length, inputs.length, 1); // Increased hidden nodes to 4 + let targets = [ [0], [1], @@ -110,6 +112,10 @@ let targets = [ [3] ]; +if (targets.length != inputs.length) { + throw new Error("You dummy, targets length should be equal to inputs length.") +} + // Training the neural network for (let i = 0; i < 50000; i++) { // Increased training iterations let index = Math.floor(Math.random() * 4);