Live data from Hacker News

Deep Learning in JavaScript

github.com

31–40 of 92 posts

Re: Deep Learning in JavaScript

#31

Do you plan to implement WebGPU acceleration to make it production-ready?

I am currently studying Typescript and other JavaScript libraries to improve the library’s performance. So adding GPU support is in sight in the future.

You might already be familiar, but a GPU.js backend can provide some speedups via good old WebGL -- no need for WebGPU just yet!

[0]: https://github.com/gpujs/gpu.js/

Re: Deep Learning in JavaScript

#33
post #30

Many people seem to be unaware of tensorflow.js, an official JS implementation of TF https://github.com/tensorflow/tfjs I'd love to see PyTorch in JS, but I think unless you get it running on the GPU it won't be able to do much.

With PyTorch dominating the landscape, my guess was that tf will resurrect itself through tfjs. Seems may not.

Re: Deep Learning in JavaScript

#34

Someone needs to do a TypeScript compiler plugin to add multidimensional array slicing and operator overloading to the language, so these libraries can actually work the way PyTorch does. I know operator overloading is controversial, but the way it allows automatic differentiation to work transparently through regular arithmetic expressions is very helpful. Without it these libraries will never feel like PyTorch. Jav…

Could not agree more hahaha! I tried to work around it building methods like “torch.add(a, b)” for operator overloading and “torch.at(index)” for slicing. But it’s definitely not as seamless as these features you proposed.

Curious, why do you need to construct these as class instances, like operation = new Exp() ? Seems like a lot of extra overhead constructing those objects. Why not just have Exp contain static methods for forwards and backwards?

[edit] nevermind, I missed the cache step. Still not sure it wouldn't be more performant to centralize caches as plain objects somewhere rather than to call new() on every op...?

Re: Deep Learning in JavaScript

#35

Earlier quoted context omitted.

Could not agree more hahaha! I tried to work around it building methods like “torch.add(a, b)” for operator overloading and “torch.at(index)” for slicing. But it’s definitely not as seamless as these features you proposed.

You should do it! If you actually had a solution for operator overloading you'd really stand out from the other various JS deep learning libraries. Save me from pip and conda please :)

I can try implementing it in the future lol It would surely be a quality of life improvement. But with the current tools, I tried my best to make the syntax as similar as possible to PyTorch’s!

Re: Deep Learning in JavaScript

#36

Earlier quoted context omitted.

Could not agree more hahaha! I tried to work around it building methods like “torch.add(a, b)” for operator overloading and “torch.at(index)” for slicing. But it’s definitely not as seamless as these features you proposed.

Curious, why do you need to construct these as class instances, like operation = new Exp() ? Seems like a lot of extra overhead constructing those objects. Why not just have Exp contain static methods for forwards and backwards? [edit] nevermind, I missed the cache step. Still not sure it wouldn't be more performant to centralize caches as plain objects somewhere rather than to call new() on every op...?

I centralized the entire backpropagation around the Operation objects. They store the data about the forward prop in the cache, and serve as the connections in the graphs between tensors. Each tensor has a “parent”, “child” and “operation”. These store who generated the tensor, what tensors it generated, and how it was generated (what operation). I could store the backward function inside of each tensor instead of an Operation object, but I chose the slightly more verbose option because I think it is a little more interpretable and simpler to add new operations.

Re: Deep Learning in JavaScript

#37

BTW: you might want to add support for typed arrays. See: https://github.com/xenova/transformers.js/blob/8804c36591d11... This is really old, but added as part of the shape of the vector as well: https://github.com/nicolaspanel/numjs/blob/master/src/dtypes...

I agree. This advice should not be ignored; and if the OP is complaining about performance, the answer is lying here in plain sight.

Re: Deep Learning in JavaScript

#38

Someone needs to do a TypeScript compiler plugin to add multidimensional array slicing and operator overloading to the language, so these libraries can actually work the way PyTorch does. I know operator overloading is controversial, but the way it allows automatic differentiation to work transparently through regular arithmetic expressions is very helpful. Without it these libraries will never feel like PyTorch. Jav…

Agreed. My suggestion is for Bun to do that since they are already transforming typescript to JS. But you can do it —- there a babel plugin in the TC39 proposal: https://github.com/tc39/proposal-operator-overloading

I'm glad that proposal was withdrawn; it would've been by far, in my opinion, the worst implementation of operator overloading, in any (mainstream) language

Re: Deep Learning in JavaScript

#40
post #30

Many people seem to be unaware of tensorflow.js, an official JS implementation of TF https://github.com/tensorflow/tfjs I'd love to see PyTorch in JS, but I think unless you get it running on the GPU it won't be able to do much.

Adding GPU support soon is absolutely my goal in the future! I think a PyTorch-based JavaScript library could be useful, as PyTorch has been way more dominant than TensorFlow recently.
Post reply on HN