Get node features size

please, how can i set the features of a node of a heterogeneous graph, and how can i get get its size ?
here is my graph:

G = dgl.heterograph({
        ('user', 'rates', 'item') : M.nonzero(),
        ('item', 'rated_by', 'user') : M.transpose().nonzero()})

thank you

Hi @driss, features of the heterogeneous graph can be set like this:
G.nodes[NTYPE].data[FEATURE_NAME] = ...

for example:
G.nodes['user'].data['x'] = th.ones(...)
G.nodes['item'].data['x'] = th.ones(...)

More details can be found in 1.5 Heterogeneous Graphs — DGL 1.1 documentation.

1 Like

thank you very much for your help

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