Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update edge attributes based on relevant node features

See original GitHub issue

❓ Questions & Help

For my application, I am considering updating edge features along with node ones. Let’s suppose for now that in each step (aka network layer) the edge attributes will be updated using their current values and the feature values of the two nodes that are relevant to the edge (e.g. using an MLP).

I have followed the discussion here, which suggests a way of caching the edge attributes. I am also thinking of overriding the forward() method such that it returns both the updated node and edge features, which are then passed into the next layer.

However, I am struggling to come up with an efficient way of implementing the edge attribute update operation based on the current edge attribute values and those of the two relevant nodes. In other words, how could I filter/access the relevant node features efficiently? Could perhaps pytorch_scatter come into the rescue here?

Any ideas would be much appreciated. Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

rusty1scommented, Aug 28, 2020

Updating edge features is actually quite easy with the use of edge_index:

src, dst = edge_index
edge_repr =[x[src], edge_attr, x[dst]], dim=-1)
edge_attr = self.mlp(edge_repr)

You can apply this in addition to propagating nodes via MessagePassing.propagate, and return the results as a tuple in forward.

Hope this helps!

dariush-salamicommented, Sep 7, 2020

Thank you for the code, @rusty1s. It’s not the exact thing that I was looking for. But it was quite helpful. I got the idea. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to update edge features in a graph using a loss function?
List the nodes in which the edges from step 3 are incoming. Construct a subgraph with node N, the nodes from step 4...
Read more >
set_edge_attributes — NetworkX 2.8.8 documentation
Sets edge attributes from a given value or dictionary of values. ... value or a dict of attribute key/value pairs used to update...
Read more >
1.3 Node and Edge Features — DGL 0.8.2post1 documentation
The nodes and edges of a DGLGraph can have several user-defined named features for storing graph-specific properties of the nodes and edges.
Read more >
How to use edge features in Graph Neural Networks (and ...
In this video I talk about edge weights, edge types and edge features and how to include them in Graph Neural Networks.
Read more >
Mutation - Graphology
Adds an edge with the given key only if the edge does not exist in the graph yet. Else it will update the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found