BrainJS / brain.js

🤖 GPU accelerated Neural networks in JavaScript for Browsers and Node.js
https://brain.js.org
MIT License
14.4k stars 1.07k forks source link

Visualizing Neural Networks | Any Updates on GPU LSTM? | Adding onto a network #399

Closed CamK06 closed 5 years ago

CamK06 commented 5 years ago

A GIF or MEME to give some spice of the internet

Comments

I'm not really having an issue with brain.js but I was just curious if there was a way to visualize a neural network like the image below.

Image of Neural Network

I was also wondering if there's any news on training LSTMs with a GPU, if I recall I was told it was coming soon back in March and so far I've heard nothing, it has become a big issue as my datasets get larger and larger.

And finally, a while back I noticed an issue someone posted (#377) which I was also having and he wasn't able to get help so I am just going to add it onto this issue; When I train a network and save it to a JSON file I would like to be able to do network.fromJSON(); to load it then using that network, add more training on top of its existing training data since retraining everything with the old data takes forever without GPU acceleration (I'm sure it would still be an issue WITH GPU acceleration). Is this in any way possible, and if not, could it be added?

robertleeplummerjr commented 5 years ago

I'm not really having an issue with brain.js but I was just curious if there was a way to visualize a neural network like the image below.

RNN's get pretty big pretty quick. Sometime back, when I was debugging the implementation, I wrote https://github.com/BrainJS/rnn-viewer, which is not anything like your image, but a way to visualize them. Likely the code is a bit out of date, as it was a tool to fix what was not working yet. Of which those issues were closed sometime back.

I was also wondering if there's any news on training LSTMs with a GPU, if I recall I was told it was coming soon back in March and so far I've heard nothing, it has become a big issue as my datasets get larger and larger.

It has been a bit longer than anticipated, and I ty for the prod, but it is under very active development. I think the problem is the scope of v2 has grown over time. I did go through all the issues in GPU.js, where the GPU implementation is being done, and have finally set a limit as to what is going into v2. It stopped at bitwise operators, of all things. As it was requested several times prior to the initial node proof of concept.

A couple of really big concepts finally made their way into GPU.js v2. For example, I wanted to pull out a lot of the code that does type checking, so it could be done once, outside the kernel, rather than N lookups inside the kernel. This lead to kernels being able to raise an event that asks for a kernel to recompile, and then cache that beside the existing kernel.

Then there was the big issue of float for loop handling not working in node on some GPU's, which lead to either upgrading Google Angle to the latest, or writing a complete type inference system, of the two, the latter was chosen.

Then there was returning array values from kernels, and as well multiple render targets, which is an absolute must for brain.js to have performant backpropagation. This lead to having to learn and debug c++ and headlessgl, to add those parts, unit test them thoroughly, join their development team, and get it released.

Then there was breaking up the argument and constant handlers, so they reused the same code, and did the type checking to raise said events about kernels in the previous paragraph.

We have also added TONS more unit tests. I believe we are nearing 20k assertions, testing the kernels from different angles, and ensuring all tests pass that are supported in Node, Chrome, Firefox, and Safari.

I think I could go on and on. And I apologize for it taking so long. The most important thing, is, I believe we are down to the wire, and the implementation will not be rushed, it will be right.

Once I cannot find anymore bugs in GPU.js, v2 will land, and I will take a proper look at all open issues for brain. If I do find anymore bugs in GPU.js, I will add those unit tests, fix them, and continue iterating. If anyone would like to join in the fun, they are invited to jump in.

CamK06 commented 5 years ago

Thanks for the response, I also forgot to mention I cannot get NeuralNetGPU to work on any of my PCs after I install gpu.js and have working code, it just says Warning: gpu not supported, falling back to cpu support not sure if this is a normal thing because of no proper GPU support but just thought I would ask anyways

robertleeplummerjr commented 5 years ago

it just says Warning: gpu not supported, falling back to cpu support not sure if this is a normal thing

It is for the time being, I'll get that code up to date soon however.

samfultonjr commented 5 years ago

@robertleeplummerjr Any ETA of when NeuralNetworkGPU will be back up again? I am working on an easy to use genetic algorithm in brain.js to get some reinforcement learning tasks going. I have already made the algorithm in tensorflow.js and I am very excited to get it working in brain, but hesitant for the time being without GPU support. Thanks for your hard work and making this amazing lib!

robertleeplummerjr commented 5 years ago

I have NeuralNetworkGPU running now in the develop branch upgraded to GPU.js v2 rc17, and that is committed. I'm waiting on a few things there (some very exciting), including:

and so I've finally reached a point I can continue work on brain.js!

You'll be seeing some activity in https://github.com/BrainJS/brain.js-cnn-integrity, which independently (and hackishly) tests brain.js against ConvNet.js, to ensure it's algorithms match up 100%. After that is finished, then we finalize a few outstanding API designs, add tons of unit tests, and release.

robertleeplummerjr commented 5 years ago

I'll take a few minutes and look at the GPU and CPU versions of network.fromJSON(), I forgot to answer that sometime back.

CamK06 commented 5 years ago

That's all good to hear! Are GPU LSTMs being worked on or will they be done at a later time after all of this?

robertleeplummerjr commented 5 years ago

They are being worked on in tandem.

robertleeplummerjr commented 5 years ago

How does this look for a simple SVG visualization? This is the default toSVG utility function with recurrent visualization shimmed (hacked) in.

Screen Shot 2019-08-20 at 7 40 01 AM

(With neural nets, it gets noisy fast!)

robertleeplummerjr commented 5 years ago

lol, I just realized I have the wrong layers connected with recurrence. Hey it is early! When this makes it into the package, it'll be right guys.

robertleeplummerjr commented 5 years ago

Much cleaner! Feedback welcomed.

Screen Shot 2019-08-20 at 8 16 49 AM
CamK06 commented 5 years ago

Yeah, that looks really good

samfultonjr commented 5 years ago

Looks damn sexy

mubaidr commented 5 years ago

Closing as it seems it will be available in next version.