tfjs-vis in node

453 views
Skip to first unread message

Jerry G.

unread,
Oct 23, 2018, 1:28:41 AM10/23/18
to TensorFlow.js Discussion
Kind of a "pie in the sky" type question before I waste of bunch of time digging into the source code...

Do you think it would be feasible to eventually make tfjs-vis work with something like JSDom so it could be used in node (for example, in Jupyter notebooks via ijavascript)? I guess that would imply building some workaround to access surfaces directly without having to go through a visor instance? Or would this be so opposed to the intent that it wouldn't be worth even considering?

Thanks,

Shanqing Cai

unread,
Oct 23, 2018, 9:31:11 AM10/23/18
to blue...@gmail.com, Yannick Assogba, Nick Kreeger, tf...@tensorflow.org

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/91b736b8-76bb-4e0f-aae7-af240adacaac%40tensorflow.org.


--
---
Shanqing Cai
Software Engineer
Google

yass...@google.com

unread,
Oct 23, 2018, 11:02:35 AM10/23/18
to TensorFlow.js Discussion, blue...@gmail.com, yass...@google.com, kre...@google.com
Hi,

I'm not sure I understand your question, but it may not be too pie in the sky. It might work with JSDom, but then I'm not sure how you would see the result. However I think you probably could integrate it into Jupyter notebooks since the notebook is an HTML document. There are articles like https://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/JavaScript%20Notebook%20Extensions.html and https://blog.thedataincubator.com/2015/08/embedding-d3-in-an-ipython-notebook/ might help you. With regard to surfaces, render.* methods will work with any dom elements (and so will most show.* methods) 

But I might be misunderstanding your question. What overall would you be trying to do in integrating the two? 

Yannick


On Tuesday, October 23, 2018 at 9:31:11 AM UTC-4, Shanqing Cai wrote:
On Tue, Oct 23, 2018 at 1:28 AM Jerry G. <blue...@gmail.com> wrote:
Kind of a "pie in the sky" type question before I waste of bunch of time digging into the source code...

Do you think it would be feasible to eventually make tfjs-vis work with something like JSDom so it could be used in node (for example, in Jupyter notebooks via ijavascript)? I guess that would imply building some workaround to access surfaces directly without having to go through a visor instance? Or would this be so opposed to the intent that it wouldn't be worth even considering?

Thanks,

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+unsubscribe@tensorflow.org.
Message has been deleted

Jerry G.

unread,
Oct 24, 2018, 2:19:08 PM10/24/18
to TensorFlow.js Discussion, blue...@gmail.com, yass...@google.com, kre...@google.com
iJavascript has a $$.html method for rendering HTML content to the cell of a Jupyter notebook.

In general the question is mostly about using the visualizations in something other than a browser, like server side in a node environment. Specifically I am interested in using the tool in a Jupyter / iJavascript kernel notebook. That type of notebook is node REPL based, so pretty much anything you can do in node you can do in the notebook. This is how I am using Tensorflow.js in Jupyter - via the node-gpu installation. I am currently using stdlib and eCharts visualizations in my notebooks since they work in node.

This is a marginal case. There are probably not a lot of groups doing data science work in Javascript like we are. On the other hand, Hydrogen and nteract also use iJavascipt so if it did work tfjs-vis could be used in those tools as well.

Jerry G.

unread,
Oct 25, 2018, 4:58:48 PM10/25/18
to TensorFlow.js Discussion, blue...@gmail.com, yass...@google.com, kre...@google.com
To clarify my question, this isn't a feature request - I was planning on working on some sort of integration myself. My question is -- is this sort of thing compatible with the long term goals of this project? Would attempting to make this work in Node be a waste of time? The README does somewhat emphasize 'in browser'.

Thanks,

yass...@google.com

unread,
Oct 31, 2018, 10:23:27 AM10/31/18
to TensorFlow.js Discussion, blue...@gmail.com, yass...@google.com, kre...@google.com
I would say that Jupyter integration would make sense to me in the context of this project. I'm guessing that by executing the visualization in node you mean that charts are rendered to JSDOm and then that DOM tree is serialized to the browser/renderer component of the notebook? If so tfjs-vis should just work as is with JS-DOM (though i'm not sure if interaction handlers would survive the serialization). Feel free to try it and let me know if you run into any problems, the library is geared towards the browser, but tools like JSDOM make many browser api's available in on node, if there are tweaks that would make that work better I'd be open to considering them. 

Another approach to integrations would be to run all the tfjs code in the kernel and serialize the things you want rendered to the browser side of jupyter and call the tfjs-vis render.* and show.* functions there, that way you also get the interactive plots if they do not work with the approach above.

Yannick

Jerry G.

unread,
Nov 24, 2018, 12:47:12 AM11/24/18
to TensorFlow.js Discussion, blue...@gmail.com, yass...@google.com, kre...@google.com
I made a TINY bit of progress on this over the holiday. If it continues to work as I hope it will, you would install the node specific package along with tfjs-vis and require the visor from the extension instead of the tfjs-vis visor. For now I pipe the output of the renderHTML() method I added to iJavascript's $$.html() method. The code is a disaster as I am still experimenting and there is every possibility that I will hit an impassible roadblock, but at least I have buttons :)


Reply all
Reply to author
Forward
0 new messages