55 comments

[ 3.1 ms ] story [ 119 ms ] thread
I didn't think the web could get any more terrible than it is today, but if everyone starts adding ML to all the tracking/targeting/adware systems then that seems to be a new deeper level of hell.
starts?

It's a classic example of how machine learning is used.

Analysis done in browser using the clients resources ? Would love to see an example.
Not in the browser, but that is what all those analytics like the ones from Google and Adobe already offer since the last decade.
(comment deleted)
> the web could get any more terrible than it is today

Please cry a river how bad it is. As someone actively developing since about 2006 I think it's never been in a better shape.

totally agree. not only that, but we haven't even scratched the surface of what's possible yet.
Agreed, there is more tooling and insight than ever before
Please respond to the actual concern, you cut out the entirely relevant part of his comment. Are you just trying to say you love React, Node, Java - cause that's what it sounds like you're saying which has nothing to do with his concern over ML to enhance tracking, etc.. If you think the tracking, etc.. has been getting better since 2006, then it clearly means you're advocating it.

That or you just didn't read the full comment?

No. He (or she) is saying that he (or she) has finally found "Linux on the Web", and he (or she) has seen the light.

Seriously though... my baby is starting to come alive. I've been banging away on it since 2012. The above phrase should allow you to find it if you know about modern search practices :)

We can start putting ML frameworks galore in LOTW, and have it all start being in service of the people.

Or how about this... a return to GOFP (Good Ol' Frickin' Programming)... possibly using numbered lines and goto statements, like we did back in the day, copying fun little snippets into the old TRS-80!

(LOTW is a new kind of client side paradigm. Actually, it is a return to the same old paradigm of something I would call "immediate mode programming", where all of the resources are simply right there in front of you. There is just a little bit of help from our friends who build and maintain the back-end infrastructure to allow all of the resources to get conveniently shipped in.)

If you think the tracking, etc.. has been getting better since 2006, then it clearly means you're advocating it.

Tracking is far better now than it was in 2006, and I say that as someone who is hugely against tracking. We have the Do Not Track header, which a lot of companies actually pay attention to, we have much better privacy plugins and ad-blockers (privacy badger, u-block origin, pi-hole, etc), and we have a growing consensus that tracking isn't actually that effective which seems to be pushing some companies to try alternative models in their advertising revenue, and their ad spend on the other side.

Things are better.

For the average user, against the larger players in the market?
This is not true, tracking is more prevalent than ever. Legislation and public backlash have forced service providers to ask before they track. However, advancements in ML and commoditization of big data engineering solutions have made it easier than ever for more events to be tracked and more accurate profiling to be possible.
It was not really relevant. It could be anything that's new, webassembly for example, or some new WebGL framework...

> Are you just trying to say you love React, Node, Java...

No stack I advocate in particular. I'm trying to say that the web is a wonderful platform and I hope it will stay for a very-very long time.

For the client side ML libraries, I don't think it makes sense to use it for tracking. You can already extract information with a high accuracy.

Tracking is a natural consequence of money flowing into the industry and tracking can be achieved with high accuracy. I'm not saying it's a good thing, but at least we can do something about it.

I first developed a web page in 1997. First got paid to do it in 1998. Innovated a lot of the DHTML/AJAX/SPA techniques before anyone else knew that was even possible, way before that first AJAX article was written.

Not sure how that's relevant, but yeah the web just gets worse and worse every year. Mostly due to the corporations of course, but the standards group are culpable too. I kind of want to write a book on the history of the W3C if nobody has already, it's such a horror show.

Can you ELI5 how standard groups have made the web worse?
That's the problem, though: The web has steadily been growing more convenient/friendly for developers, while steadily growing more hostile for users.

All these javascript "advances" just make it easier for people to e.g. mine monero on my system without my consent and enable mediocre web developers to load up previously quick-loading sites with custom scrolling animations, autoplay video, and malvertising.

I'm sure it's in better shape for you, a web developer. It's objectively worse for me, a user.

These advances also make it possible to have the user experiences of sites like spotify, netflix, soundcloud, etc. There's a lot of bad stuff but there is also a lot of good.
The experience of using the web is much worse than it used to be.
> starts adding

Oh believe me, this stuff was added a long time ago. This is a benefit though. Of course these people will want to offload some of that heavy ML computing onto the browser so they don't have to pay for their own cluster of p3.16xlarge or whatever. Which makes it easier to block and opt-out.

I'm not immediately sure what the benefit of running such a (EDIT: advertising/tracking) model on the client as opposed to server (aside from reducing server costs). At best, it exposes the model to the user, allowing competitors to reverse-engineer it.
Some benefits: for the user - the data stays private as all processing is done on device. You can get much faster inference times and create applications with real-time interactions. The applications can work offline once the models are downloaded. The browser comes with tons of sensors (microphone/camera/accelerometer/etc) and the data from these sensors can be fed into the models in real time without needing to do a round trip to a server. Yes if the model is proprietary it maybe wouldn’t make sense to have the user download the weights as it could be reverse engineered, but for open source models it’s not an issue. And anyways the value these days is in the dataset and training of the models. Check out this great article on edge computing: https://techcrunch.com/2017/08/03/edge-computing-could-push-...
Those are benefits for TensorFlow.js, sure, but none of those help tracking/advertising use cases.
Oh yeah didn't realize your response was to the original comment. In the case of tracking/advertising there isn't much of a benefit.
I think you're overlooking a lot with that aside. It's just one example but with tensorflow.js you can run your model on a video feed in the browser, frame-by-frame, in a way that wouldn't just increase server costs but would hobble performance as well.
Any company that attempts to do targeting/advertising based on the user's video camera feed without explicit consent will be shamed/sued out of existence, even if there technically isn't a privacy leak.
It seems I made my comment before I saw your edit, that you were writing about only advertising and targeting. I'm not sure what your definition of consent is, regarding video streaming on the web, but it seems to me that every implementation of the getUserMedia API on modern browsers asks the user for permission to access the device.

So yes, anyone surreptitiously gaining access to your camera or mic feed through the browser would get into heaps of trouble and invite bad press, especially if they were able to find a way around the consent dialog.

Applying ML is one's FREEDOM.
lol, it's the use case.

I have the FREEDOM of discharging a gun is different than I have the FREEDOM of discharging a gun into a person's brain are two very different things.

I'm using TensorFlow.js to make simple PWAs which run on iOS, Android, and desktop to provide interfaces for games which are accessible to people of various capabilities/accessibilities. Without it, it would take an order of magnitude more investment on my part to make this happen. Your world view is absurdly narrow.
20 authors ? Is a follow back on Twitter enough to get 10th author on a paper?
Why disparage their work? It's a large engineering effort. It's likely that only a few of the authors wrote a majority of the text in the paper, but it's appropriate and worthwhile to give recognition to the folks who did engineering work on the artifact being described as well.

It's better to be generous with credit than stingy.

Any ideas for more specific use cases than just "sharing models and applications"?
[Atwood's Law]

This was inevitable I guess, but does anyone know if there's a decent Pandas equivalent for Javascript? I'd love to be able to handle reasonably large datasets in Javascript as easily as I can in Python.

Not sure this exactly helps you with your question, but check out Observable Notebooks (https://beta.observablehq.com/). It's by Mike Bostock who wrote D3 (which people use to handle large data sets frequently).

A quick search brought me here(https://stackoverflow.com/questions/30610675/python-pandas-e...) and here (https://stratodem.github.io/pandas.js-docs/#introduction)— not sure pandas-js is maintained any longer, though.

edit: In that SO question, there's a pointer to Apache Arrow which appears to be maintained more regularly, with types—and library support for multiple languages. Never used it, myself, though.

https://github.com/apache/arrow

One thing that Python has that JS lacks is operator overloading, which allows for adding broadcasting. It's really nice to be able to do builtin math operations on Pandas columns or NumPy arrays. That's why languages like R, Julia and APL have broadcasting built in to the language. The mathematical notation is more natural and less cumbersome.
Two things that JS has over Python is lexical scoping and map/reduce/filter and lambda support.

JS can be verbose, but I find that functional style JS is, in my opinion, a bit more readable than Python list comprehensions.

> Two things that JS has over Python is lexical scoping and map/reduce/filter and lambda support.

???

Python does all of that. There are native map/reduce/filter methods in the standard library.

    >>> x = [1, 2, None, 3]
    >>> list(filter(None, x))
    [1, 2, 3]
and then map

    >>> list(map(float, [1, 2, 3]))
    [1.0, 2.0, 3.0]
Lambda's are everywhere in Python:

    >>> double = lambda x: x * 2
    >>> list(map(double, range(3)))
    [0, 2, 4]
https://docs.python.org/3/library/functions.html
I know that they exist, but if you look at your examples, you have to manually cast maps into a list which is a bit strange coming from Ruby/JS/Scala.

Once you have something sufficiently complex (such as using map, filter, and reduce all at the same time), there becomes so much line noise that it starts working against you.

With JS/Ruby/Scala, you chain functional methods as opposed to Python where you can keep wrapping functions.

Something like

  let arr =  [0,1,2,'test'];

  arr
    .filter(x => typeof(x) == 'number')
    .map(x => x*2)
    .reduce((x, y) => x * y)
becomes a little more cryptic with Python:

  from functools import reduce

  arr = [0,1,2,'test']

  # with lambdas
  reduce(lambda x,y: x + y, map(lambda x: x * 2, filter(lambda x: type(x) == int, arr)))

  # list comprehension equivalent
  sum([x * 2 for x in arr if type(x) == int])
While Python is very beginner friendly, it has a really strange (in my opinion) approach to functional concepts. However, it is has other features that make it really nice to work with (like decorators, data classes, sets, robust ML libraries, really nice built ins).
Chaining function calls makes things harder to debug, so I don’t do it.
I don't think it's any harder than broadcasting... I try to avoid chaining unless I know the structure of the data I am working with.
Broadcasting is even better than both for vector arithmetic and comparison operators, which is what you get with Python libraries built on top of NumPy arrays.

  > a = np.array([1, 2, 3, 4, 5])
  > a * 10
  array([10, 20, 30, 40, 50])
 
 > a[a < 3]
 array([1, 2])
It's even nicer in languages with builtin vectors like R:

  > a1 = 1:5
  > a2 = c(2, 4, 6, 8, 10)
  > a1 + a2
  3 6 9 12 15
In Pandas, you can add a new dataframe column that's the result of arithmetic operations on other numeric columns.

  > df["New Column Name"] = df.Col1 * (df.Col2 / df.Col3)
To each his own; I prefer JS/Ruby/Scala style map/filter/reduce functions for these sort of operations:

  let a = [1, 2, 3, 4, 5]
  > a.map(x => x * 10)
  (5) [10, 20, 30, 40, 50]

  > a.filter(x => x > 3)
  (2) [4, 5]

  > a1.map((x,i) => x + a2[i])
  (5) [3, 6, 9, 12, 15]
I don't hate broadcasting, but it can get a bit cryptic at times. Once the filtering starts getting complex, it can be a bit difficult to read unless you start breaking things out into variables and chaining filters together.

For JS, something similar to pandas creating a new column based on operations of other columns would be to do map an array of objects (list of dicts) and use a (Schwartzian_transform)[https://en.wikipedia.org/wiki/Schwartzian_transform] to create a new object property. I would love to look into how efficient these sort of operations can be, have had some success with this sort of thing for performing cosine similarity in the browser instead of creating sparse matrices with python.

I understand wanting to use map or filter when things get more complex. Pandas has filter and apply methods for that. I agree that the JS versions are quite nice with the arrow functions and method chaining.

But for simpler operations, if you're doing a lot of vector computations, then map and filter bloat the code considerably when the mathematical notation is easy to read.

Good luck with work on the JS implementation and efficiency comparisons. Pandas utilizes a Series object built on top of NumPy array for handling columns and rows. I don't know whether a similar approach would be helpful in JS.

What, no Jeff Dean?!
TF.js is just a wrapper. It develops independently with TF's core.
For everyone wondering what this could be useful for, take a look at https://github.com/tensorflow/tfjs-models for a few ideas.

Making apps interactive with poses or with speech commands are two examples that jump out.

If I can ask for 1 feature request for TensorFlow.js: It would be nice if the library abstracts out DOM objects (window, document, etc.).
Out of curiosity, why do you need this? Tensorflow is for tensor/matrix operations; I can't think of a reason why it would need to abstract out DOM objects.
This and ONNX.js are two projects I'm following very closely even as someone who mostly only works in PyTorch or Tensorflow. I think they both have a lot of potential to reduce the cost of deploying machine learning solutions, especially with everyone in the cloud essentially paying the Nvidia tax.
I am a huge fan TFJS. I have used it in one project and hope to use it again. Having TF compatible neural nets in the browser and inside Node, it's a game changer. Google was smart to buy Deepmind.
TensorFlow isn't a DeepMind project