-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge Cluster-GCN and GCN graph classification into GCN layer #1205
Conversation
Check out this pull request on You'll be able to see Jupyter notebook diff and discuss changes. Powered by ReviewNB. |
The core layer in a full batch method (like `GraphConvolution` inside `GCN`) natively computes information about a whole graph, but this doesn't directly work with machine learning (and, in particular, how it works with `Keras`). In particular, there's usually only a subset of labelled nodes, so training needs to only compute candidate embeddings for those nodes to compare against the ground-truth target array. We currently handle this in full batch methods by having each layer know whether it is the `final_layer` in the model, and do `tf.gather` using a tensor of indices of relevant nodes. This means that the individual full-batch layers have to: - always accept the tensor of indices, even if they won't use it (and, potentially, even if they are being used as part of a model that doesn't ever use it) - do the appropriate `tf.gather` invocation to select the relevant nodes This patch adjusts this approach to make the output filtering a model level concern: layers always compute all the information, and models that need to can do a `tf.gather` call (via the new `layer.misc.GatherIndices`) to select out the relevant output elements. This has a few benefits: - it seems conceptually more "correct" to me, because it's the training/using of a overall model that needs to filter out elements, _not_ the operation of an individual layer - it reduces the amount of code required noticeably, and will reduce if further when we remove the left-over-`final_layer` detection (that is designed to help us migrate). - it makes #1201 easier (in #1205): graph classification doesn't have any output indices to feed into the graph convolution layers, and so this patch makes `GraphConvolution` closer to the behaviour required for that - it may also ease implementing models that incorporate information from multiple convolution layers, because it's easy to make sure all the convolution layers compute embeddings for all nodes See: #1201
dd91833
to
62d18e2
Compare
Code Climate has analyzed commit bf54b3a and detected 0 issues on this pull request. View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍 Just some minor comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
ClusterGraphConvolution
andGraphConvolution
were practically identical, with just some minor differences in the details of the code, andGraphClassificationConvolution
only differed by:GraphConvolution
in Gather output nodes in full batch models, not the layers #1204GraphConvolution
to handle a batch size > 1 for dense matrices, not sparse ones (yet, since it's harder: Keras's.batch_dot
doesn't seem to support sparse matrices).That is, by building on #1204, this patch can merge all three of our implementations of the GCN layer.
This deprecates
ClusterGraphConvolution
because it has been released for a while, but removesGraphClassificationConvolution
entirely, because it has only been released@experimental
-y.See: #1201