About applying GATConv on unidirectional bipartite graph

The doc says :“GATConv can be applied on homogeneous graph and unidirectional bipartite graph”
And the example :
>>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2]
>>> g = dgl.heterograph({(‘A’, ‘r’, ‘B’): (u, v)})
>>> u_feat = th.tensor(np.random.rand(2, 5).astype(np.float32))
>>> v_feat = th.tensor(np.random.rand(4, 10).astype(np.float32))
>>> gatconv = GATConv((5,10), 2, 3)
>>> res = gatconv(g, (u_feat, v_feat))
>>> res
tensor([[[-0.6066, 1.0268],
[-0.5945, -0.4801],
[ 0.1594, 0.3825]],
[[ 0.0268, 1.0783],
[ 0.5041, -1.3025],
[ 0.6568, 0.7048]],
[[-0.2688, 1.0543],
[-0.0315, -0.9016],
[ 0.3943, 0.5347]],
[[-0.6066, 1.0268],
[-0.5945, -0.4801],
[ 0.1594, 0.3825]]], grad_fn=)

The question is why the results only contain four nodes’ feature?

it’s because first dimension of v_feat is 4. please check the shape of returned tensor here: NN Modules (PyTorch) — DGL 0.7.2 documentation

Thanks. So the output is dst nodes’ feature? @Rhett-Ying

yes. you are right. it’s features of DST nodes…

Thanks a lot. Now I’m wondering why the src nodes’ feature is neglected… Is there any explanation?
@Rhett-Ying

messages are passed from src to dst and it’s uni-bipartite graph, so only data of dst is returned.

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