Live data from Hacker News

Tensorflow.js – A Practical Guide

blog.yellowant.com

1–10 of 37 posts

Re: Tensorflow.js – A Practical Guide

#5

Noob question: Can anybody tell in a few sentences of plain english what is tensorflow, how it works and why seems to be so relevant?

It's a high-performance-computing framework that allows you to specify matrix and vector math expressions in terms of a graph structure. In exchange, you get automatic derivative calculation, and a somewhat easier ability to distribute complicated calculations across processors.

HN people are mainly interested in it because it's one of the major frameworks for creating neural networks. Also because Google.

The framework is written in C++ but has decent bindings to Python, and is popular in both languages. Aside from wanting to use Javascript, there are no good technical reasons to do any of this stuff in Javascript.

Re: Tensorflow.js – A Practical Guide

#6
post #5

Noob question: Can anybody tell in a few sentences of plain english what is tensorflow, how it works and why seems to be so relevant?

It's a high-performance-computing framework that allows you to specify matrix and vector math expressions in terms of a graph structure. In exchange, you get automatic derivative calculation, and a somewhat easier ability to distribute complicated calculations across processors. HN people are mainly interested in it because it's one of the major frameworks for creating neural networks. Also because Google. The framew…

[deleted]

Re: Tensorflow.js – A Practical Guide

#7
post #5

Noob question: Can anybody tell in a few sentences of plain english what is tensorflow, how it works and why seems to be so relevant?

It's a high-performance-computing framework that allows you to specify matrix and vector math expressions in terms of a graph structure. In exchange, you get automatic derivative calculation, and a somewhat easier ability to distribute complicated calculations across processors. HN people are mainly interested in it because it's one of the major frameworks for creating neural networks. Also because Google. The framew…

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 predictions locally, or send embeddings back to a server without the raw data ever leaving a client.

- Flexibility of JavaScript / TypeScript. Dynamic languages are great for scientific computing, TypeScript allows you to define your own level of type safety, from raw JS on one end, to strict typing support on the other end.

- Interactivity / education tooling. See tensorflow playground for an excellent example.

- No servers for applications. Making predictions in TensorFlow on a server can be expensive in the long run. Hosting static weights on a server is much much cheaper.

JavaScript and Python ecosystems for machine learning are not mutually exclusive -- they both have their strengths and weaknesses.

Re: Tensorflow.js – A Practical Guide

#8

Noob question: Can anybody tell in a few sentences of plain english what is tensorflow, how it works and why seems to be so relevant?

Tensorflow tries to fit the free parameters (usually millions of parameters) of a function y=f(x). The fitting algorithm gets usually thousands or millions of examples of how the output y for a given input x has to look like.

For example, x can be tens of thousands of images of cats and dogs, and y can be 1 for a dog and 0 for a cat. The goal for the fitting algorithm is to find parameters that describe the concept of a cat and a dog so that it can can generalize and categorize general images of cats and dogs. A bad fit would be if the network just memorized the example images.

Re: Tensorflow.js – A Practical Guide

#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 (unless maybe you want to hijack people's browsers to help with training or something).

Re: Tensorflow.js – A Practical Guide

#10
post #7
post #5

Earlier quoted context omitted.

It's a high-performance-computing framework that allows you to specify matrix and vector math expressions in terms of a graph structure. In exchange, you get automatic derivative calculation, and a somewhat easier ability to distribute complicated calculations across processors. HN people are mainly interested in it because it's one of the major frameworks for creating neural networks. Also because Google. The framew…

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 support. Go with JS, and you're getting none of that.

"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."

Right. So this is "we don't want to use another language". Acknowledged.

"Privacy. You can make predictions locally, or send embeddings back to a server without the raw data ever leaving a client."

If calling out to a binary is a security problem for you, you have bigger problems than choice of language. Also, of course, you don't need tensorflow to convert your top-secret data into an input vector that you can send somewhere (seriously: it does not help with this problem).

Your third and fourth points -- flexibility and interactivity -- are indeed why people use Python vs C++ (even though it's more difficult and painful to get decent performance out of TF with that approach). So again, this boils down to "I don't want to use Python and I'd prefer to use JS instead."

"No servers for applications. Making predictions in TensorFlow on a server can be expensive in the long run. Hosting static weights on a server is much much cheaper."

You're contradicting yourself with this point. Servers are expensive so hosting static weights on a server is cheaper? I have no idea what this means.

Post reply on HN