x
here is a dictionary mapping node type to tensor :
>>> x
{'protein': tensor([[ 1.5659e+00, 7.6492e-01, -1.3036e-01, 1.0010e+00, 7.0579e-01,
1.3227e-02, 1.3354e-01, 1.3097e-01, 2.2603e-02, 1.6489e-01,
1.1034e+00, 4.6917e-01],
...,
grad_fn=<AddBackward0>)}
which is also saved in the ndata
of the edge_subgraph
:
>>> edge_subgraph.ndata
{'disease': {'feature': tensor([], size=(0, 500)), '_ID': tensor([], dtype=torch.int64)}, 'drug': {'feature': tensor([], size=(0, 7467)), '_ID': tensor([], dtype=torch.int64)}, 'protein': {'feature': tensor([[ 0.0000, 0.0000, 0.0000, ..., 0.0000, 0.0000, 0.0000], ..., ]),
'_ID': tensor([327, 35, 264, 27, 211, 114, 355, 367, 108, 303, 25, 238, 188, 194,
272, 351, 157, 63, 343, 245, 331, 167, 120]),
'x': tensor([[ 1.5659e+00, 7.6492e-01, -1.3036e-01, 1.0010e+00, 7.0579e-01, 1.3227e-02, 1.3354e-01, 1.3097e-01, 2.2603e-02, 1.6489e-01, 1.1034e+00, 4.6917e-01], ...,
, grad_fn=<AddBackward0>)}}
it has the shape:
>>> x['protein'].shape
torch.Size([23, 12])
since the edge_subgraph
has corresponding number of nodes:
>>> edge_subgraph
Graph(num_nodes={'disease': 0, 'drug': 0, 'protein': 23},
...,
)
I am not sure if this is correct, since it is a dictionary. But when I try to just take the dictionary value of x, it throws me an error that x has to be a dictionary. I could not find the source code of dgl.function.u_dot_v()
, so I am not sure if it can handle the input being a dictionary.