cazala / synaptic

architecture-free neural network library for node.js and the browser
http://caza.la/synaptic
Other
6.92k stars 666 forks source link

Website hangs in Chrome on Core i5 consuming 100% CPU #247

Open irnc opened 7 years ago

irnc commented 7 years ago

https://synaptic.juancazala.com/ hangs right away leaving it unusable, because links couldn't be clicked.

System is Ubuntu 16.04 with Chrome 59.

wagenaartje commented 7 years ago

Was mentioned here too - https://github.com/cazala/synaptic/issues/26.

AlexisTM commented 7 years ago

Might be because of the 100 fps?

What about using the window.requestAnimationFrame function instead of the setTimeout?

https://github.com/cazala/synaptic/blob/gh-pages/scripts/homepage/world.js#L83

wagenaartje commented 7 years ago

@AlexisTM I wrote a JSFiddle of the demo that uses requestAnimationFrame instead of setTimeout, problem still occured. https://jsfiddle.net/wagenaartje/fuh36aex/1/.

I also set the setTimeout delay to 1000 and it worked fine for like 5 iterations and then just completely slowed down, but did not freeze.

AlexisTM commented 7 years ago

If you leave the page during some time, it actually works after a long freeze.

AlexisTM commented 7 years ago

It took 134200 seconds for the first execution of the activate function, which optimize.

https://github.com/cazala/synaptic/blob/gh-pages/scripts/homepage/world.js#L71

var output = creature.network.activate(input);

The optimization creates an optimized version of the network by concatenating the calls.

https://github.com/cazala/synaptic/blob/master/src/network.js#L114-L191

wagenaartje commented 7 years ago

Nice catch! I used setOptimize(false) and it worked again.

https://jsfiddle.net/wagenaartje/4516xtze/7/

I also noticed that the perceptron has way too many neurons in its hidden layer. Could easily be reduced. Just 1 is enough for clustering, 2 is more smooth.

AlexisTM commented 7 years ago

Therefore, the optimization is hanging on Chrome. :(