Live data from Hacker News

Tensorflow.js – A Practical Guide

blog.yellowant.com

31–37 of 37 posts

Re: Tensorflow.js – A Practical Guide

#31
post #25
post #14

Earlier quoted context omitted.

"You miss the point. The security problem is sending the raw data from the client to the server." So don't do that. If you can run tensorflow on your device, you can call out to a local process. If you want to use JS to do everything, fine. But that's not a good reason. It's just a reason.

> So don't do that. If you can run tensorflow on your device, you can call out to a local process. Not from a webapp (without jumping through a dozen other hoops.) With tensorflow.js, you can do (for example) pose estimation, or face detection, or audio recognition, right in the browser without sending data to a remote server. > But that's not a good reason. It's just a reason. Yes, of course it's a reason. The point…

So now we're down to "I want to run a neural network exclusively in the browser" as the primary reason you'd want to use this.

OK, fine. That's a niche use-case for a domain where scale and performance matter so much that we're building specialized hardware to support it. For 99.99% of developers, they would be better advised to find another way to solve their problem using more conventional tools.

There was a guy who built a life-sized house out of Lego once. It was a cool trick, but the difference between him and "modern Javascript" developers is that he didn't try to make anyone live in the house.

Re: Tensorflow.js – A Practical Guide

#33
post #9

The most practical use not mentioned here is probably to import existing trained models/weights. I can see it being useful for anything that you want to run in real-time (e.g., webcams apps like https://github.com/ModelDepot/tfjs-yolo-tiny ) and can't pay a round-trip cost to server. https://js.tensorflow.org/tutorials/import-keras.html Training a model in the browser is the least practical use for tensorflow.js IMO…

And if you want to just load generic pre-trained classifiers for a variety of tasks, ml5js (which uses TensorFlow.js under the hood) seems promising!

https://ml5js.org/docs/quick-start

Re: Tensorflow.js – A Practical Guide

#35
post #10
post #7

Earlier quoted context omitted.

There are many reasons to do it in JavaScript: - Many companies and projects have their entire server-side stack in JavaScript and Node.js, and often they want to simply make a prediction through a model. It's quite a lot to ask them to pull in a python runtime just to make a prediction. TensorFlow.js with node bindings to TensorFlow C enables this type of inference with minimal overhead. - Privacy. You can make pred…

There's literally only one reason to do it in Javascript: you want to use Javascript. There are dozens of reasons why it's a terrible idea: unfortunate memory consumption, abysmal performance, poor abstractions, bad library support, and so on. Tensorflow in Python isn't exactly a stellar choice for performance, but at least you gain flexibility and nice abstractions and good high-performance math/stats library suppor…

[deleted]

Re: Tensorflow.js – A Practical Guide

#37
post #28

Earlier quoted context omitted.

You can probably export your Keras model, load it in tensorflow.js, and train it. Makes more sense than transpiling. Guide here: https://js.tensorflow.org/tutorials/import-keras.html

Thanks! Do you by chance know if it is practical to convert huge .h5 Keras models to TF.js layers model? (~1GB). I have some state-of-art computer vision models and it would be great if they could be used in a browser with a WebCam, if they can fit into memory and be performant for inferencing.

Mobile has similar constraints as web (but to a lesser extent) so you will find more resources there.

Look into quantizing the weights (e.g., reduce from 32bit per parameter to 8 bits) to reduce model size: https://www.tensorflow.org/mobile/optimizing#model_size

Post reply on HN