-
When I use PYG to construct a graph for a paragraph based on the sequence of words, for example: I am a student, I set the ID for each word in the dictionary, such as I, am: 10, 15, student: a: 20, 30, when I sequence according to the structure diagram, Be based on the relationship between the edge of [10], [15, 10], [15, 30], [30], [30], [20, 30], node for [[10], [15], [20], [30]], when I use the Data appeared abnormal, when I put all of the id is amended as: When 0,1,2,3, the relation of edges also becomes [0,1],[1,0],[1,2],[2,1],[2,3],[3,2], which is found to be correct at this time. Therefore, I would like to ask, when I construct a graph, do nodes have to start from 0? data = Data(x=x, edge_index=edge_index.t().contiguous()) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Yes, |
Beta Was this translation helpful? Give feedback.
I think you are mixing up node IDs and the IDs that are used to map to words. While the
edge_index
always needs to refer to0
tonumber_of_nodes - 1
(to index the corresponding feature matrix), you can have a node ID/attribute for each node that maps to the ID of the corresponding word.