Graph convolution updates each node representation by combining its current features with information aggregated from neighboring nodes. The graph structure supplies the connectivity, so the resulting representation captures both local topology and node features. In a GNN pipeline, graph convolution is a practical mechanism for moving information through the graph and producing node embeddings. section 3.1.2 section 1.1
A graph-convolution layer is used as a short implementation pipeline:
- Accept node features and the graph structure, commonly represented in PyTorch Geometric by x and edge_index. section 3.1.2
- Aggregate neighborhood information for each node and update its feature representation. section 3.1.2
- Stack layers to refine representations, adding nonlinear activation between layers when needed. section 3.1.2
- Return embeddings for analysis or normalize final outputs for a classification task. section 3.1.2
Two-layer GCN in PyTorch Geometric
A practical model defines two GCNConv layers: the first maps input features to hidden representations, ReLU adds nonlinearity, and the second produces output representations. A return_embeds flag exposes the intermediate embeddings; otherwise, log_softmax produces classification outputs. Replacing GCNConv with SAGEConv gives a structurally similar GraphSAGE implementation with a different aggregation approach.
Listing 3.2 GCN class
class GCN(torch.nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels):
super(GCN, self).__init__()
self.conv1 = GCNConv(in_channels, hidden_channels) #1
self.conv2 = GCNConv(hidden_channels, out_channels)
def forward(self, x, edge_index, \
return_embeds=False): #2
x = self.conv1(x, edge_index)
x = torch.relu(x) #3
x = self.conv2(x, edge_index)
if return_embeds: #4
return x
return torch.log_softmax(x, dim=1) #5
Inspect the compact GCN class to connect graph convolution terminology with layer construction, forward-pass inputs, activation, embeddings, and classification output. section 3.1.2

