Replies: 1 comment 4 replies
-
Yes, this actually is implemented quite similar to DGL: from torch_geometric.nn import SAGEConv
src = torch.tensor([0, 1, 2, 3, 4, 5, 6, 7, 8])
dst = torch.tensor([0, 0, 0, 1, 2, 2, 2, 2, 2])
edge_index = torch.stack([src, dst], dim=0)
x_src = torch.rand(9, 10)
x_dst = torch.rand(3, 3)
conv = SAGEConv((10, 3), 8)
out_dst = conv((x_src, x_dst), edge_index) Note that in PyG master, you can now store this bipartite graph via a from torch_geometric.data import HeteroData
data = HeteroData()
data['src'].x = x_src
data['dst'].x = x_dst
data['src', 'dst'].edge_index = edge_index
from torch_geometric.transforms import ToUndirected
data = ToUndirected()(data) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to model a very simple unidirectional bipartite graph where there are src nodes and dst nodes. I want to predict only on the dst nodes and there is a many to one (src to dst) relationship.
Here is an example edge list with 9 src nodes and 3 dst nodes.
In this case I would like to do a graph convolution (Sage, GAT, etc) on src nodes 0,1,2 and the dst node 0 to make a prediction for dst node 0 and so on...
Is there a way to do this easily with pytorch_geometric or would it be better to just implement from scratch?
This is how you can do it in
dgl
:Beta Was this translation helpful? Give feedback.
All reactions