Problem about deal with new dataset #2721
-
I got a new dataset that consist of two files. One is relation.txt and the other one is feature.txt The relation file is representing the connection relationship between different nodes like this: And the feature file is the one hot features of each node like this: Can I get some advice about how to transform them to the format like "planetoid" (https://github.com/kimiyoung/planetoid/tree/master/data) Thank you so much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi, x = torch.tensor([[1, 0, 0, 1, 1, 0, 0, 0],
[2, 0, 1, 0, 0, 0, 1, 0]], dtype=torch.long) As for your edge_attr = torch.tensor([[1, 0],
[0, 1],
[2, 0],
[0, 2],
[3, 0],
[0, 3],
[2, 1],
[1, 2],
[3, 1],
[1, 3]], dtype=torch.long) That's just the basics, but you will find the Pytorch Geometric is very consistent when it comes to data structures. For a more detailed explanation feel free to browse the linked documentation as well as the worked examples in this GitHub repository. There are also some Colab notebooks if you prefer. |
Beta Was this translation helpful? Give feedback.
Hi,
it would probably be best if you take a look here for a well detailed example on how to structure your data for Pytorch Geometric.
In a nutshell, your features are just a
torch.tensor
with shape(num_nodes, num_features)
. In your case:As for your
edge_list
(what you call connection relationship), that's anothertorch.tensor
of shape(2, num_edges)
. If you're working with an undirected graph, the index should report both directions. Like so: