From a6b03ad344da1c2c471c5e102dc5763f544b162b Mon Sep 17 00:00:00 2001 From: papalotis <36131443+papalotis@users.noreply.github.com> Date: Sun, 11 Feb 2018 10:48:41 +0100 Subject: [PATCH] User Input needs to be normalized During training the input is in [0,...,1] but when creating the user input array the data was copied directly from the graphics element and not normalized --- examples/mnist/sketch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mnist/sketch.js b/examples/mnist/sketch.js index d718936..796ae28 100644 --- a/examples/mnist/sketch.js +++ b/examples/mnist/sketch.js @@ -119,7 +119,7 @@ function guessUserDigit() { img.resize(28, 28); img.loadPixels(); for (let i = 0; i < 784; i++) { - inputs[i] = img.pixels[i * 4]; + inputs[i] = img.pixels[i * 4] / 255; } let prediction = nn.predict(inputs); let guess = findMax(prediction);