Live data from Hacker News

Deep Learning in JavaScript

github.com

41–50 of 92 posts

Re: Deep Learning in JavaScript

#41

Earlier quoted context omitted.

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/

Thanks for the tip! I’ll definitely take a look. Adding GPU support is my next step!

Re: Deep Learning in JavaScript

#42

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 had read about this as a possibility, but will definitely look more into it now, thank you for the tip!

Re: Deep Learning in JavaScript

#43

This is great. Code seems to have good comments / jsdoc from the bit studied, tests and all. Will take a closer look in the morning but congratulations on the release.

Thank you for the feedback! If you have any questions or suggestions looking it over tomorrow, I’d love to hear them!

Re: Deep Learning in JavaScript

#44
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.

tfjs is dead, looking at the commit history. The standard now is to convert PyTorch to onnx, then use onnxruntime (https://github.com/microsoft/onnxruntime/tree/main/js/web) to run the model on the browser using webassembly/webGL (and nodejs if you wanted to, but why?).

Re: Deep Learning in JavaScript

#45
post #44
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.

tfjs is dead, looking at the commit history. The standard now is to convert PyTorch to onnx, then use onnxruntime ( https://github.com/microsoft/onnxruntime/tree/main/js/web ) to run the model on the browser using webassembly/webGL (and nodejs if you wanted to, but why?).

> nodejs if you wanted to, but why?

Node.js is better backend than something like Flask.

Re: Deep Learning in JavaScript

#46
Cool project! I worked on something similar a while ago to learn about automatic differentiation: https://github.com/hexhowells/onegrad.js

Needs more layers to be really useful though.

I always thought examples using browser extensions would be neat since their built in JS and you only need to download the model once.

Re: Deep Learning in JavaScript

#47
post #44

Earlier quoted context omitted.

tfjs is dead, looking at the commit history. The standard now is to convert PyTorch to onnx, then use onnxruntime ( https://github.com/microsoft/onnxruntime/tree/main/js/web ) to run the model on the browser using webassembly/webGL (and nodejs if you wanted to, but why?).

> nodejs if you wanted to, but why? Node.js is better backend than something like Flask.

Performance is a lot worse on NodeJS with a WebAssembly/WebGL backend versus Flask with a PyTorch/CUDA backend.

Re: Deep Learning in JavaScript

#48

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…

What's wrong with creating a function that does those things? It would be less surprising to people new to the library, would be self-documenting by having a name and an easily inspected declaration with named arguments, and it would be idiomatic JS. You could also have variants that are purely functional and return a new value or ones that mutate in place that you could use depending on your needs.

Re: Deep Learning in JavaScript

#49

Earlier quoted context omitted.

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/

FWIW also taichi is quite popular in python and seems has some javascript related implementation (I haven't used it though), taichi.js [0]

[0] https://github.com/AmesingFlank/taichi.js

Re: Deep Learning in JavaScript

#50
Wow! Thank you for doing this. It looks like a great starting point for anyone approaching deep learning from the JS ecosystem. It is very plainly written and looks like it will be a joy to learn from. Thank you for adding JSDoc comments with type hints!

Are you open to pull requests? If I have the time I'd love to contribute. I'm sure others would as well.

You should write up a short article on this, even something really simple like one of the examples in the README but with some commentary and examples of output and then post it to a few places like https://dev.to/ or maybe https://hashnode.com/ or even Medium (even though I'm not a big fan). There aren't many newer implementations of PyTorch in JS and I've been looking for one to learn from for some time so I'm sure there are a lot of other JS/TS developers out there that would be interested. Getting to the front page of HN certainly helps but having an article somewhere will help everyone after this week find it through a Google search.

Again, thanks so much for doing this work! It's really helpful to have everything spelled out in JS for those of us who haven't used Python much (I'm sure Python devs can relate when they think about JS projects).

Post reply on HN