Comparing graph convolutional and graph linear layers
In the previous chapter, our vanilla GNN outperformed the Node2Vec model, but how does it compare to a GCN? In this section, we will compare their performance on the Cora and Facebook Page-Page datasets.
Compared to the vanilla GNN, the main feature of the GCN is that it considers node degrees to weigh its features. Before the real implementation, let’s analyze the node degrees in both datasets. This information is relevant since it is directly linked to the performance of the GCN.
From what we know about this architecture, we expect it to perform better when node degrees vary greatly. If every node has the same number of neighbors, these architectures are equivalent: ():
- We import the
Planetoid
class from PyTorch Geometric. To visualize the node degrees, we also importmatplotlib
and two additional classes:degree
to get the number of neighbors of each node andCounter
to count the number of nodes for each...