Closed tongzhu194 closed 1 year ago
No examples to offer but you could
Thanks for the idea. I would expect a method/layer like tfgnn.keras.layers.GraphUpdate which can directly modify features to change the adjacency.It seems that there is not or I missed something. For now what I am doing is defining another graph which copy the context and nodesets and build new edgesets.
Hi @tongzhu194!
What you're describing is the right solution at the GraphTensor
level: tfgnn.GraphTensor
objects and their pieces are immutable, just like tf.Tensor
objects, so you need to create a new GraphTensor
from pieces, including the modified EdgeSet
objects. To integrate that into a TF-GNN model built with Keras layers, you simply need to wrap those operations in a custom Keras layer.
Free-form manipulation of EdgeSets is tricky, and care must be taken to keep the Adjacency and any features in sync. Is the manipulation you need to do easy to express by some higher-level abstraction, like tfgnn.mask_edges()
?
If there is no enhancement request here regarding specific types of adjacency updates, may I close this issue?
Background: Like I said in my previous comment, free-form manipulation of EdgeSets is tricky. It usually requires non-trivial amounts of code. Wrapping that code in a custom Keras layer is easy by comparison. The converse -- constructing the new fields of an Edge set with many freestanding ops, and then having a Keras layer to fold them into GraphTensor -- looks like an inversion of abstraction levels to me.
Sure! Thank you for the answer and help! My layer works now!
在 2023年3月30日,01:02,arnoegw @.***> 写道:
If there is no enhancement request here regarding specific types of adjacency updates, may I close this issue?
Background: Like I said in my previous comment, free-form manipulation of EdgeSets is tricky. It usually requires non-trivial amounts of code. Wrapping that code in a custom Keras layer is easy by comparison. The converse -- constructing the new fields of an Edge set with many freestanding ops, and then having a Keras layer to fold them into GraphTensor -- looks like an inversion of abstraction levels to me.
— Reply to this email directly, view it on GitHubhttps://github.com/tensorflow/gnn/issues/278#issuecomment-1488974520, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A227SJFGGPJMRXRM5RMSJQ3W6RTK7ANCNFSM6AAAAAATYPFSGQ. You are receiving this because you were mentioned.Message ID: @.***>
Glad it works! Let me close this issue, then.
Hi, I am able to update edge/node features while training and looking for a way to update the adjacency of edge sets (i.e. changing the whole graph structure). I am not sure whether this is achievable. It would be great to have some examples from you. Thanks a lot