Live data from Hacker News

Deep Learning in JavaScript

github.com

81–90 of 92 posts

Re: Deep Learning in JavaScript

#81
This is great!

I was looking for something like this.

Now I just need a guide that tackles the principles of this, but from a typescript/javascript perspective.

PS: TyTorch (from Typescript) sounds nice!

Re: Deep Learning in JavaScript

#82
post #47

Earlier quoted context omitted.

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

If you're using Node you can write whatever you want in C++ and then add a binding to call it from within your Node app. Don't need WebGL.

But you're having to write whatever in C++ versus just using Flask/Pytorch.

Re: Deep Learning in JavaScript

#83
post #81

This is great! I was looking for something like this. Now I just need a guide that tackles the principles of this, but from a typescript/javascript perspective. PS: TyTorch (from Typescript) sounds nice!

I plan on adding Typescript support soon! Thanks for the feedback

Re: Deep Learning in JavaScript

#84

Earlier quoted context omitted.

If you're using Node you can write whatever you want in C++ and then add a binding to call it from within your Node app. Don't need WebGL.

But you're having to write whatever in C++ versus just using Flask/Pytorch.

A lot of what you need is already written, you just need to find the right libraries and write the bindings. From my encounters with Python ML it seems like "just use Pytorch" is a bit like "simply walk into Mordor".

Re: Deep Learning in JavaScript

#85

Earlier quoted context omitted.

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.

What's wrong is it obscures simple math expressions behind tons of dots and parentheses. The thing is that the core of deep learning algorithms is usually very simple math. It's useful to be able to translate that math directly from research papers into straightforward expressions that mirror the structure in the paper like a = b / c + d * e rather than something less similar like a = b.divide(c).add(d.multiply(e)).

Depending on what you learned first, dots and parentheses are a lot simpler to understand than math expressions.

Re: Deep Learning in JavaScript

#87
post #86

One of the learning tool is notebook. I even has a lisp backend to enabled it to be used. It will be nice if there is a notebook version and easy to run on web (like colab).

I’m planning on creating a small article explaining the syntax and the functionalities of the Deep Learning library. I think that could be a useful learning tool, do you think it would help?

Re: Deep Learning in JavaScript

#88

Earlier quoted context omitted.

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.

What's wrong is it obscures simple math expressions behind tons of dots and parentheses. The thing is that the core of deep learning algorithms is usually very simple math. It's useful to be able to translate that math directly from research papers into straightforward expressions that mirror the structure in the paper like a = b / c + d * e rather than something less similar like a = b.divide(c).add(d.multiply(e)).

You could probably build tagged template literal like:

a = e`${b} / ${c}`

Not ideal, but much better and without magic pre processors

Re: Deep Learning in JavaScript

#89

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…

You could use eval to expand whatever syntax you like into function calls. It could be done once at the start of the program and act like a js preprocessor.

I know eval is not kosher but this problem is also not real, so why not.

Re: Deep Learning in JavaScript

#90

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…

You could use eval to expand whatever syntax you like into function calls. It could be done once at the start of the program and act like a js preprocessor. I know eval is not kosher but this problem is also not real, so why not.

That's an interesting idea as well, could definitely see that working in some use cases.
Post reply on HN