liquidcarrot / carrot

🥕 Evolutionary Neural Networks in JavaScript
https://liquidcarrot.io/carrot/
MIT License
293 stars 34 forks source link

A way to pause/resume network.evolve() #194

Open tracycollins opened 4 years ago

tracycollins commented 4 years ago

When evolving a network on a machine, and using close to 100% of cpu capacity, it would be nice to have a way to pause and later resume the evolve() function. Otherwise, a machine can become unresponsive for other tasks.

Not sure how best to do this, or even if this functionality should/could exist in carrot. Is there a way to do this cleanly via node? pm2?

christianechevarria commented 4 years ago

I think this is a very interesting idea that makes sense, off the top of my head I'd imagine that supporting a CLI listening for a keyboard interrupt or something could work but I'd have to look into how to go about it. @GavinRay97 would you have any ideas about how something like this could work?

GavinRay97 commented 4 years ago

You could wrap the evolve() loop in an if(shouldContinue) or while(shouldContinue), and then set up a toggle on shouldContinue that can be triggered in the browser by invoking it through the console or programmatically (whether that be UI or otherwise), and in the CLI by intercepting keypress on some key to trigger it

GavinRay97 commented 4 years ago

Actually, paused is probably a more idiomatic name, and you can throw it on the global namespace under carrot.paused.

if (!carrot.paused) {}
christianechevarria commented 4 years ago

image