I’m kind of a bit stuck on GCNs in that I am somewhat proficient with GNNs, i.e. extracting data from a graph, and then putting it through a sequential model, but I do not understand fundamentally if for GCNs a model with a different structure to a sequential model must be used, i.e. instead of a sequential model, is the neural net meant to represent the structure of the source graph? Certainly when the brains trust of GCNs do their presos they very much seem to indicate you need the neural net config to mirror the input graph structure. I need this concept clarified before I can make any further progress.
Understood. Unfortunately I have not had a chance to look into these either, but maybe @pyu has some thoughts or @Laurence_Moroney could loop someone who knows about these areas in?
[Question / Help] Unfortunately everything I’ve found so far on message passing and code level demo abstract the mechanics through Python libraries, but in trying to implement something like GraphSage for TF.js I’ll need to figure out this connection. @Greg_Matthews your Observable link was helpful (thanks again) but also a little beyond my current understanding. So I’ve made a webapp to edit/visualise json graphs, and an attempt to write a very naive/basic node embedding function (codepen) …
Summary
to capture k hops of nodes as an array—one hop per array index:
with an aggregation function ready to sum or average with each hop, or I guess one-hot encodings first…but this basic level is where I’m stuck figuring out how best to format and connect the arrays to TF.js’s api? Ultimately I’m aiming to understand graph recommender models for node predictions, and I’m wondering from here what the options are to connect to TF.js or if anyone has pointers to code I can study it would be much appreciated.
Thanks in advance, or next stop Stackoverflow.
I’d been texting Zak Jost on Discord, and he’d mentioned that if you do 2 hops as part of building your embeddings then that’s what he calls ‘Simple GCN’ – it can offer value, but better for it to be set up so that back propagation works as you train the model, hence why it seems you can’t use a sequential model, and must somehow instead have the NN structure be a graph – which seems perhaps feasible to do but I then wonder how that model can be used for other graph data that doesn’t have the same structure. There’s a fundamental concept that doesn’t seem to have been explained very well, that I would have thought should be a core concept that didn’t require reverse engineering Python code to understand.
bump…any further progress on this? i.e. GCNs in TensorFlow.js?
The current released version doesn’t seem to allow the construction of a GraphModel (in JS), only loading a GraphModel that was created with python – which isn’t useful if you want the whole thing to run in a browser.
Has any behind-the-scenes work started?
I think enabling GCNs to be created + trained + used all in JavaScript would be pretty valuable since being able to make context-sensitive predictions I think will be next level compared to a normal GNN.
+1 to this, I have bumped the FR over on Github above too to see if any scope for the future here. My gut feeling though is that this may need to be turned into a SIG project led by the community which graduates to product one day. @pyu Do you think that is reasonable if folk are willing to work on this?
I work on the tensorflow_gnn library ( GitHub - tensorflow/gnn: TensorFlow GNN is a library to build Graph Neural Networks on the TensorFlow platform. ), a Python+TF implementation of GNNs, specifically message-passing neural networks (which encompass GCNs/GraphSAGE/Graph Attention networks/etc). It’s designed from the start for heterogeneous (relational) graphs, so it supports all the features you mention (typed edges/nodes, directional heterogeneous edges, and node + edge features).
The docs have some more information about the how and why of GNNs, as well as links to Colab examples. If you have any more questions for your specific use-case, please feel free to open an issue on the GitHub page.
I am after these features in tensorflow.js, i…e Javascript not python, because I want to create + train GCNs in my node app, and I don’t want to use Python.
There’s some basic stuff missing in tensorflow.js like the ability to create graph structure neural nets.
Is there any plan to lift tensorflow.js to a similar level to tensorflow (python)?
Hi Greg, so GNNs are not on our immediate plan for implementation (though I am bringing it up in our team meetings from time to time to ensure it is on our mind for the future) as we have to look after the core library / models / backends that we support and ensure they evolve with emerging web standards like Web GPU etc so we do not have bandwidth right now to take on a new large project like this at this time given the hiring freeze and all that going on in the tech world.
If GNNs were to be ported to TensorFlow.js right now it would probably need to be a community driven SIG effort is my guess. If you are able to find some people who would be willing to lead this effort externally we could look at putting a proposal for a SIG project that if successful would then graduate to being part of TensorFlow.js when mature enough to go into production build.
It seems there’s some basic enabling functionality that’s missing in tensorflow.js that is preventing people like me experimenting to a stage where I or others could lead such an initiative like you’ve outlined. The key feature seems to be lack of ability to create graph networks in tensorflow.js.
What if those enabling features were identified and added?
You talked about a “new large project”, which presumably refers to a more full blown GNN/GCN implementation in tensorflow.js
I’m raising a different question about whether the minimal underpinnings of GNN/GCN support could be added to tensorflow.js, e.g. ability to create a graph network rather than sequential network. This would presumably still need a lot of work added on top for it to be useful.
Without me really understandintg the internals of tensorflow.js, I’m asking if adding these minimal enabling features is feasible, so that the community can start building towards this “new large project”.
A possible downside might be that the tensorflow team would prefer that the Python code was ported to Javascript rather than a separate unaligned JavaScript implementation evolving.
I’m also now kind of wondering if Transformers have somewhat overtaken GNNs/GCNs – if one is able to approach their problem as a NLP problem.
I am under the impression that you need to be able to create a neural net that has a graph structure, not a sequential network if the graphs/inputs you’re wanting to use to make predictions are as follows:
multiple node types
nodes have features
multiple edge types
edges have features.
None of the examples seem to show how to solve for all of the above, and so do show message passing but they’re for simpler examples, perhaps multiple node types, but that’s it, i.e. no node features, multiple edge types, or edge features.
Very happy to be corrected if there’s a JavaScript example that shows the 4 points above, and where you can make both node predictions and edge predictions.
Sorry for being late to the party. I have very limited knowledge about GNN, here is a paper on TF-GNN using Tensorflow to construct the GNN model. From the surface, TFJS should be able to provide similar foundation.
I think the key is how to map the GNN to GraphTensor and build operations on top of that.
“I think the key is how to map the GNN to GraphTensor and build operations on top of that.”
That’s been the thing I’ve been discussing – there’s no way to create a GraphTensor in tensorflow.js – you can import one from a model created with Python but that’s useless if you’re in a pure JS world.
My question has been whether it’s feasible to enable allowing creation of a GraphTensor in tensorflow.js, so we can start playing around with then building on top.