GCNConv is a PyTorch Geometric layer for graph convolution and neighborhood message aggregation. It updates each node representation using its features and information gathered from neighboring nodes. section 2.2.1 section 3.1.2
A typical GCNConv pipeline works as follows:
- Accept node features as x and graph connectivity as edge_index. section 2.2.1
- Aggregate neighborhood information and combine it with each node’s existing features. section 2.2.1 section 3.1.2
- Pass the resulting representations through additional GCNConv layers, commonly adding ReLU between layers. section 2.2.1 section 3.1.2
- Return node embeddings directly or transform the final output for classification. section 3.1.2
Two-layer GCN
A model can define self.conv1 = GCNConv(in_channels, hidden_channels) and self.conv2 = GCNConv(hidden_channels, out_channels), then call x = self.conv1(x, edge_index), apply torch.relu(x), and call the second layer. Returning x yields node embeddings; applying torch.log_softmax supports classification. section 3.1.2
Listing 2.4 Our SimpleGNN class
class SimpleGNN_embeddings(torch.nn.Module):
def __init__(self, num_features, hidden_channels): #1
super(SimpleGNN, self).__init__()
self.conv1 = GCNConv(num_features, \
hidden_channels) #2
self.conv2 = GCNConv(hidden_channels,\
hidden_channels) #3
def forward(self, x, edge_index): #4
x = self.conv1(x, edge_index) #5
x = torch.relu(x) #6
x = torch.dropout(x, p=0.5, train=self.training) #7
x = self.conv2(x, edge_index) #8
return x #9
Inspect the complete SimpleGNN implementation, including layer construction, forward propagation, ReLU, dropout, and the second graph-convolution step. section 2.2.1
Using GCNConv without optimization produces preliminary embeddings that reflect graph structure and node features; training can tailor them to node classification or link prediction. section 2.2.1
