Create Heterogeneous Graphs #4265
DuanhaoranCC
started this conversation in
General
Replies: 1 comment 15 replies
-
I assume you create the graph as follows? import numpy as np
import torch
from torch_geometric.data import HeteroData
A_list = list(range(200))
B_list = list(range(500))
data = HeteroData()
data['A', 'relation1', 'B'].edge_index = torch.tensor(
np.array([[A_list[5], B_list[365]], [A_list[56], B_list[2]]]),
dtype=torch.long).t().contiguous()
data['A', 'relation2', 'B'].edge_index = torch.tensor(
np.array([[A_list[15], B_list[35]], [A_list[9], B_list[78]]]),
dtype=torch.long).t().contiguous()
print(data)
print(data['A', 'relation1', 'B'].edge_index)
print(data['A', 'relation2', 'B'].edge_index) This should work just fine. Can you show me where your script crashes? |
Beta Was this translation helpful? Give feedback.
15 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.
-
Dear author, Hello! I'm building my own heterogeneous graph dataset, but I seem to have a problem. I have two kinds of nodes A (200), B (450), and 75 different types of edges connecting A and B.
A_list = [0,1,...199] B_list = [0,1,...449] data['A', 'relation1', 'B'].edge_index = torch.tensor(np.array([A_list[5], B_list[365], [A_list[56], B_list[2]]), dtype=torch.long).t().contiguous() data['A', 'relation2', 'B'].edge_index = torch.tensor(np.array([A_list[15], B_list[35], [A_list[9], B_list[78]]), dtype=torch.long).t().contiguous()
But in doing so, I am reporting an error that the dimension exceeds the index in the input model. I would like to ask if this composition is correct?
Beta Was this translation helpful? Give feedback.
All reactions