Questions of HGTConv use

I was reading the document and found that there is an official implementation of hgtconv ( HGTConv — DGL 1.1 documentation).
However I have a question about passing the parameters of hgtconv when forwarding, where it says that you need to pass in the parameters ntype, etype, both of which are one-dimensional Integer tensor respectively.

Does this mean that you need to pass type number of each node of the heterogeneous graph, for example, two vertices a,b, while a vertex type is author, its type number is 0, b vertex type is paper, its type number is 1, do I need to pass such a ntype parameter tensor ([0, 1])
Also, when I read the code implementation from OpenHGNN OpenHGNN/HGT.py at main · BUPT-GAMMA/OpenHGNN (github.com),

I found that it passed in g.ndata['_TYPE'], g.edata['_TYPE'], which made me a bit confused, because g.ndata, g.edata seems to be the features of nodes and edges.

Your understanding is correct. g.ndata and g.edata can store arbitrary node/edge data, not necessarily features. They probably store the node types and edge types with g.ndata['_TYPE'] and g.edata['_TYPE'].

Thanks a lot ! I’ll try it later.

Also, I have a question of the first parameter x when forwarding, the doc says x is a 2D tensor of node features Shape: (|V|,D)


So I try to pass a 2D tensor like this to x : Tensor.tensor( [ [node1_feature], [node2_feature], [node3_feature]......]),
and it raises an exception: Current HeteroNodeDataView has multiple node types, please passing the node type and the corresponding data through a dict.
So should I change the input x into a dict like: { 'type1': feature_data1, 'type2': feature_data2, ..... }
Thank you in advance !

Can you try converting the input graph to a homogeneous graph with to_homogeneous? It seems this module only takes a homogeneous representation of a heterogeneous graph.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.