$ cd ../
GNN — Graph Neural Networks — bash

user@devops:~$ cat README.md

GNN — Graph Neural Networks

# Description

Graph Neural Networks (GNN) from scratch in PyTorch. Implementation of Graph Convolutional Networks (GCN) as per Kipf & Welling (2017) for node classification on the classic Zachary's Karate Club dataset. The model builds a graph convolutional layer from scratch: symmetric adjacency normalization (D⁻¹ᐟ²·A·D⁻¹ᐟ²), message passing neighbor aggregation, and linear transformation with ReLU activation. The 2-layer GCN architecture (34 → 32 → 2, 1,186 parameters) learns node embeddings over 500 epochs with early stopping, achieving 88.24% overall accuracy (30/34 correct nodes). The 4 misclassifications occur at boundary nodes between the two rival karate club factions. 7 visualizations: original graph with real communities, training loss and accuracy curves, predictions vs ground truth, highlighted classification errors, t-SNE of 32D embeddings, confusion matrix, and message-passing diagram showing how node 0 aggregates information from its neighbors.

# Key features

$ GCN from scratch in PyTorch: GraphConv layer with symmetric adjacency normalization

$ Node classification on Zachary's Karate Club: 34 nodes, 78 edges, 2 communities

$ Message Passing: weighted neighbor aggregation with self-loops

$ 88.24% overall accuracy (30/34 nodes) — errors only on community boundary nodes

$ t-SNE of 32D embeddings shows community separation in latent space

$ Symmetric normalization D⁻¹ᐟ²·A·D⁻¹ᐟ² with self-loops for numerical stability

$ 7 educational visualizations: graph, training curves, confusion matrix, t-SNE, message passing

$ Minimalist implementation: 1,186 parameters, full CPU training in seconds

# Gallery

Project terminal
GNN — Graph Neural Networks - Project terminal
Original graph — ground truth communities
GNN — Graph Neural Networks - Original graph — ground truth communities
Training curves
GNN — Graph Neural Networks - Training curves
Predictions vs ground truth
GNN — Graph Neural Networks - Predictions vs ground truth
Classification errors
GNN — Graph Neural Networks - Classification errors
t-SNE of GCN hidden layer embeddings
GNN — Graph Neural Networks - t-SNE of GCN hidden layer embeddings
Confusion matrix
GNN — Graph Neural Networks - Confusion matrix
Message Passing — node 0 aggregates neighbors
GNN — Graph Neural Networks - Message Passing — node 0 aggregates neighbors

# Technologies used

PyTorch NumPy Matplotlib Seaborn scikit-learn NetworkX