How to initialize edge feature/edge index tensors in Heterogeneous Graphs for edges with no features? #8879
-
Hi everyone, I have some questions regarding creating heterogeneous graphs. In the case that I have only one node type and multiple edge types, and only 1 edge type has edge features, should I initialize the empty tensors for those edge types that don't have edge features? For example: data = HeteroData()
data["node"].x = ... # [num_nodes, num_node_feats], only 1 type
data["node", "type1", "node"].edge_index = ... #[2, num_edge_type1]
data["node", "type2", "node"].edge_index = ... #[2, num_edge_type2]
data["node", "type1", "node"].edge_attr = ... #[num_edge_type1, num_edge_type1_feat]
data["node", "type2", "node"].edge_attr = ... # zeros-tensor or no init? Another question popping up is some graphs might not have a specific edge type, which leads to the data["node", "type3", "node"].edge_index = ... # [0]
dgl_data = to_dgl(data) # ValueError: not enough values to unpack (expected 2, got 0) Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
In general, node types/ edge types / their features need to be consistent across graphs. If an edge type of all graphs does not have edge features, then you don't need to specify them. |
Beta Was this translation helpful? Give feedback.
The answer would be the same, right?
edge_index
would need to be defined for the edge types that exist in the union of graphs.Maybe I am misunderstanding the question.