From 2fe9d32a2c3f09f1689ce4e0f6248f7a5a0a91f5 Mon Sep 17 00:00:00 2001 From: Guilherme Rossato Date: Sun, 15 Mar 2020 02:33:12 -0300 Subject: [PATCH 1/2] Added ShuffleInplace implementation to Network's Worker source To solve this [issue](https://github.com/cazala/synaptic/issues/238). The problem was that the Worker did not have the shuffleInplace function implemented. (Tested the code locally in a browser) --- src/Network.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Network.js b/src/Network.js index 5afdf14..75fc93f 100644 --- a/src/Network.js +++ b/src/Network.js @@ -516,6 +516,7 @@ export default class Network { hardcode += 'var F = new Float64Array([' + this.optimized.memory.toString() + ']);\n'; hardcode += 'var activate = ' + this.optimized.activate.toString() + ';\n'; hardcode += 'var propagate = ' + this.optimized.propagate.toString() + ';\n'; + hardcode += 'var shuffleInplace = ' + shuffleInplace.toString() + ";\n"; hardcode += 'onmessage = function(e) {\n' + 'if (e.data.action == \'startTraining\') {\n' + From c4dbe6d19eed352ca7a52d3e42caed581d7449d2 Mon Sep 17 00:00:00 2001 From: Guilherme Rossato Date: Sun, 15 Mar 2020 02:56:24 -0300 Subject: [PATCH 2/2] Fixed suhffleInplace function not reaching this scope by hardcoding it It didn't change since the project started so I guess it's safe to say it is stable. --- src/Network.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Network.js b/src/Network.js index 75fc93f..8d08bff 100644 --- a/src/Network.js +++ b/src/Network.js @@ -516,7 +516,7 @@ export default class Network { hardcode += 'var F = new Float64Array([' + this.optimized.memory.toString() + ']);\n'; hardcode += 'var activate = ' + this.optimized.activate.toString() + ';\n'; hardcode += 'var propagate = ' + this.optimized.propagate.toString() + ';\n'; - hardcode += 'var shuffleInplace = ' + shuffleInplace.toString() + ";\n"; + hardcode += 'function shuffleInplace(o) { for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x) {} return o; };\n'; hardcode += 'onmessage = function(e) {\n' + 'if (e.data.action == \'startTraining\') {\n' +