question-mark
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.

Can I put the edges' weights into the edge_attr?

See original GitHub issue

❓ Questions & Help

Hi, first of all, thank you so much for this wonderful tool for PyTorch. I am a newbie in this library so I have two very strange questions.


1. edge_attr

I notice that the Data class has an attribution named edge_attr which holds the edges’ features in the graph. And currently, I need to construct a weighted directed graph Data instance for GCNConv. So here is my question: Can I put the weight into the edge_attr for creating the Data instance? In my view, I think it is just okay, but seems so strange. Because in this time the shape of the edge_attr tensor is actually [num_edges, 1].

So, is it okay to do it?


2. Dynamical batch

I also want to confirm one thing. Here FAQ2, your introduction seems to show that I can dynamically construct a graph DataLoader in this way:

from torch_geometric.data import Data, DataLoader

data_list = [Data(...), ..., Data(...)]
loader = DataLoader(data_list, batch_size=32)

Is that all I need to do? Don’t I need to do some stuff like padding for the batches?

Finally, thank you so much for your work and hope you to respond to my questions.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dabao0903commented, May 7, 2020

You can save your edge weights into edge_attr. This is no problem. Alternatively, you can save them to any attribute, e.g., data.edge_weight = edge_weight. The DataLoader correctly merges all attributes into a single graph. So this is indeed all you need to do.

Hello, author. Can you explain the principle of “Weighted GCN layer”, thanks!

0reactions
rusty1scommented, Aug 1, 2020

Please have a look at the GATConv layer in torch_geometric.nn.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I put the edges' weights into the edge_attr? · Issue #708
I notice that the Data class has an attribution named edge_attr which holds the edges' features in the graph. And currently, I need...
Read more >
graph - What is the difference edge_weight and edge_attr ...
No, the edge attribute contains features for the edges which can be used to calculate the message in a learnable way. The edge...
Read more >
set_edge_attributes — NetworkX 2.8.8 documentation
Name of the edge attribute to set if values is a scalar. Examples. After computing some property of the edges of a graph,...
Read more >
How do I make the edge_attr (the weights of each edge) in ...
I have a GNN where I am using the standard node level features and graph level features, right now I have my edge_attr(edge...
Read more >
How igraph functions handle attributes when the graph ...
I.e. specifies that the weight of the new edge should be sum of the weights of the corresponding edges in the old graph;...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found