News for hackers. Stuff that matters.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by fredley on Monday February 04, 2019 @10:26AM (#19077025)
[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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by 52-6F-62 on Monday February 04, 2019 @10:34AM (#19077101)
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

Re:TensorFlow.js: Machine Learning for the Web and Beyond by goatlover on Monday February 04, 2019 @03:28PM (#19080303)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by rajangdavis on Monday February 04, 2019 @10:08PM (#19082757)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by whalesalad on Tuesday February 05, 2019 @12:26AM (#19083186)
> 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
Re:TensorFlow.js: Machine Learning for the Web and Beyond by rajangdavis on Tuesday February 05, 2019 @01:08AM (#19083320)
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).
Re:TensorFlow.js: Machine Learning for the Web and Beyond by naveen99 on Tuesday February 05, 2019 @08:16AM (#19084970)
Chaining function calls makes things harder to debug, so I don’t do it.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by rajangdavis on Wednesday February 06, 2019 @01:08AM (#19093092)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by goatlover on Tuesday February 05, 2019 @01:28AM (#19083397)
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)
Re:TensorFlow.js: Machine Learning for the Web and Beyond by rajangdavis on Tuesday February 05, 2019 @01:54AM (#19083472)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by goatlover on Tuesday February 05, 2019 @02:21AM (#19083548)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by pablobaz on Monday February 04, 2019 @10:37AM (#19077128)
Re:TensorFlow.js: Machine Learning for the Web and Beyond by eddieone on Monday February 04, 2019 @04:32PM (#19080845)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by spongepoc on Tuesday February 05, 2019 @07:30AM (#19084683)
TensorFlow isn't a DeepMind project
Re:TensorFlow.js: Machine Learning for the Web and Beyond by dak1 on Monday February 04, 2019 @11:32AM (#19077649)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by abetlen on Monday February 04, 2019 @03:52PM (#19080512)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by didip on Monday February 04, 2019 @01:53PM (#19079385)
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.).
Re:TensorFlow.js: Machine Learning for the Web and Beyond by rajangdavis on Monday February 04, 2019 @10:10PM (#19082768)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by dinghy on Monday February 04, 2019 @10:27AM (#19077037)
Crazy tech!
Re:TensorFlow.js: Machine Learning for the Web and Beyond by endofcapital on Monday February 04, 2019 @09:56AM (#19076786)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by kowdermeister on Monday February 04, 2019 @10:09AM (#19076890)
> 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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by coding123 on Monday February 04, 2019 @10:31AM (#19077078)
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?

Re:TensorFlow.js: Machine Learning for the Web and Beyond by kowdermeister on Monday February 04, 2019 @03:56PM (#19080548)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by onion2k on Monday February 04, 2019 @11:25AM (#19077592)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by DevKoala on Monday February 04, 2019 @03:04PM (#19080095)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by newaccoutnas on Monday February 04, 2019 @01:10PM (#19078865)
For the average user, against the larger players in the market?
Re:TensorFlow.js: Machine Learning for the Web and Beyond by na85 on Monday February 04, 2019 @12:32PM (#19078422)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by wuliwong on Thursday February 07, 2019 @11:29AM (#19106222)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by kmlx on Monday February 04, 2019 @10:23AM (#19076998)
totally agree. not only that, but we haven't even scratched the surface of what's possible yet.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by rhizome on Monday February 04, 2019 @02:11PM (#19079589)
The experience of using the web is much worse than it used to be.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by endofcapital on Monday February 04, 2019 @10:35AM (#19077110)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by AriaMinaei on Monday February 04, 2019 @10:40AM (#19077159)
Can you ELI5 how standard groups have made the web worse?
Re:TensorFlow.js: Machine Learning for the Web and Beyond by AtHeartEngineer on Monday February 04, 2019 @10:31AM (#19077073)
Agreed, there is more tooling and insight than ever before
Re:TensorFlow.js: Machine Learning for the Web and Beyond by fredley on Monday February 04, 2019 @10:28AM (#19077048)
> 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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by minimaxir on Monday February 04, 2019 @11:18AM (#19077517)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by mmcwilliams on Monday February 04, 2019 @11:35AM (#19077679)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by minimaxir on Monday February 04, 2019 @11:40AM (#19077723)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by mmcwilliams on Monday February 04, 2019 @02:32PM (#19079805)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by stangogh on Monday February 04, 2019 @11:29AM (#19077629)
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-...
Re:TensorFlow.js: Machine Learning for the Web and Beyond by minimaxir on Monday February 04, 2019 @11:33AM (#19077660)
Those are benefits for TensorFlow.js, sure, but none of those help tracking/advertising use cases.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by bearcherian on Monday February 04, 2019 @10:40AM (#19077162)
ML is already used for targeted ads and other content

EDIT: Example - https://www.adobe.com/marketing-cloud/target/automation.html

Re:TensorFlow.js: Machine Learning for the Web and Beyond by grrowl on Monday February 04, 2019 @09:37PM (#19082664)
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.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by adam12 on Monday February 04, 2019 @10:06AM (#19076857)
starts?

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

Re:TensorFlow.js: Machine Learning for the Web and Beyond by xodast on Monday February 04, 2019 @10:19AM (#19076967)
Analysis done in browser using the clients resources ? Would love to see an example.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by pjmlp on Monday February 04, 2019 @11:02AM (#19077375)
Not in the browser, but that is what all those analytics like the ones from Google and Adobe already offer since the last decade.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by tanilama on Monday February 04, 2019 @12:23PM (#19078311)
Applying ML is one's FREEDOM.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by rhacker on Monday February 04, 2019 @02:59PM (#19080054)
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.

Re:TensorFlow.js: Machine Learning for the Web and Beyond by 1024core on Monday February 04, 2019 @10:30AM (#19077070)
What, no Jeff Dean?!
Re:TensorFlow.js: Machine Learning for the Web and Beyond by tanilama on Monday February 04, 2019 @12:26PM (#19078343)
TF.js is just a wrapper. It develops independently with TF's core.
Re:TensorFlow.js: Machine Learning for the Web and Beyond by focom on Monday February 04, 2019 @10:01AM (#19076821)
20 authors ? Is a follow back on Twitter enough to get 10th author on a paper?
Re:TensorFlow.js: Machine Learning for the Web and Beyond by dgacmu on Monday February 04, 2019 @10:15AM (#19076931)
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.