About heterogeneous graph's feature

This example is :

g = dgl.heterograph({ … (‘drug’, ‘interacts’, ‘drug’): (th.tensor([0, 1]), th.tensor([1, 2])), … (‘drug’, ‘treats’, ‘disease’): (th.tensor([1]), th.tensor([2]))}) >>> g.nodes[‘drug’].data[‘hv’] = th.zeros(3, 1) >>> g.nodes[‘disease’].data[‘hv’] = th.ones(3, 1) >>> g.edges[‘interacts’].data[‘he’] = th.zeros(2, 1) >>> g.edges[‘treats’].data[‘he’] = th.zeros(1, 2)

The question is : the number of ‘disease’ nodes is 2, why do we should write ‘th.zeros(3, 1)’

The node IDs start from 0, so DGL treats the input as having disease #0, #1 and #2, where #0 has no incoming edges.

1 Like

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