Renaming a node type name in DGL heterograph

Hi,

I have built a heterograph with just one node type and 158 edge types. When I do hetero_graph.ntype, I get [0] as an output but when I try to assign a feature to all nodes using

hetero_graph.nodes[0].data['feature'] = torch.randn(n_nodes, n_hetero_features)

I get an error,
DGLError: Expect number of features to match number of nodes (len(u)). Got 85938 and 1 instead.

Is there anything that I am missing here? I think nodes[0] is trying to assign a feature to only first node instead of all 85938 nodes, is there any way to overcome this or rename the node types perhaps?

Thanks in Advance!

I used hetero_graph.ndata['feature'] = torch.randn(n_nodes, n_hetero_features) and that solved the issue, however, when I try to build RGCN - Entity Classification model, I get an error -
TypeError: parameter name should be a string. Got int

Is there any way to change the name of the node type from “int” to “string”?

hetero_graph.nodes[0].data['feature'] = torch.randn(n_nodes, n_hetero_features)
I get an error,
DGLError: Expect number of features to match number of nodes (len(u)). Got 85938 and 1 instead.

Have you tried replacing 0 with '0'?

Is there any way to change the name of the node type from “int” to “string”?

Note types should be strings. You cannot change the node types for an existing graph. In that case, you need to construct a new graph.