How to Train and Validate a GCN on Several Graphs?

@ghaffarian When using GNN-based approaches for graph-level prediction, we first update node representations, then compute graph-level representations out of node-level representations and finally make a prediction. So in your case I guess you did not compute the graph-level representation out of node-level representations. For a most naive case, you can simply take a sum over the node representations as @VoVAllen suggested here. Also see the corresponding section in the tutorial.

Thanks a lot @mufeili.
It seems I had misunderstood how GCNs work; but now I get it.
I solved it using your suggestion to apply a dgl.sum_nodes and then applying torch.softmax on the output.
If you know about any other better method than a sum I’ll be glad to know about it.
Even a reference would be great to deepen my understanding of the topic.

See https://github.com/dmlc/dgl/blob/master/python/dgl/nn/pytorch/glob.py

1 Like