Hands-on Geometric Deep Learning

Hands-on Geometric Deep Learning

Graph Convolutional or SAGE Networks? Shootout

Patrick R. Nicolas's avatar
Patrick R. Nicolas
Sep 25, 2025
∙ Paid

The right tool for the job! GraphSAGE and Graph Convolutional Network (GCN) are the most commonly used Graph Neural Networks architectures. It is critical to understand the advantages and limitations of each model in order to apply to a specific problem and graph dataset.

Thanks for reading Hands-on Geometric Deep Learning! Subscribe for free to receive new posts and support my work.

Geometric Deep Learning, World Models use complex math to overcome limitations of traditional deep learning. We make that math practical through hands-on tutorials.


  1. Why this Matters

  2. Key Takeaways

  3. Graph SAGE Network Basics

    🏛️ Inductive vs. Transductive

    PyTorch Geometric Library

    🏛️ Evaluation Configuration

    • Model Parameters for Evaluation

    • Performance Metrics

    🏛️ Datasets

  4. Graph SAGE Network Deep Dive

    ⚙️ Architecture Design

    • Graph Neural Blocks

    • Graph Neural Models

    ⚙️ Python Environment

    ⚙️ Test Code

    • Setup

    • Graph SAGE Configuration

    • GCN Configuration

    📈 Evaluation

    • Cora Dataset

    • Flickr Dataset

  5. References

  6. Q & A

  7. Paper Review


👉 Patrick Nicolas is a 30-year software engineering veteran and consultant specializing in Geometric Deep Learning and World Models, author of Scala for Machine Learning, and writer of Geometric Learning in Python.

Why this matters

Purpose: Since 2017, countless Graph Neural Network variants have emerged, many implemented in PyTorch Geometric. The challenge is choosing the right model for a given dataset and task. We begin by comparing two staples: GraphSAGE and Graph Convolutional Network (GCN).

Audience: Data scientists and machine learning practitioners exploring or developing Graph Neural Networks.

Value: Learn how to evaluate two graph neural networks across two datasets: a case study of GraphSAGE vs GCN.

Key Takeaways

  • On small graphs with a limited neighborhood scope, GCN tends to perform better; however, GraphSAGE improves as you increase the number of neighbors per hop and the fanout

  • GraphSAGE clearly outperforms GCN on large graphs.

  • In our tests on two PyTorch Geometric datasets, adding more layers to either GCN or GraphSAGE did not yield gains.

  • PyG’s GitHub includes a section comparing methods under homogeneous evaluation (see [ref 12]).

  • Our experiments used a single sampling strategy—torch_geometric.loader.NeighborLoader—but readers are encouraged to try alternative loaders/samplers.

Graph Sage Network Basics

This section covers the essential Basics, while the Deep Dive section delivers advanced concepts, real-world applicability, dedicated Q&A and review.

The Graph Convolutional Network (GCN) {ref 1, 2] and GraphSAGE network [ref 3] have been studied in previous articles.


📌 I’ll treat GCN as a representative transductive GNN and GraphSAGE as a canonical inductive model. Comparing other type of GNNs might have produced different results.


🏛️ Inductive vs. Transductive

Inductive graph neural networks learn from existing (training) and new, unseen nodes, links or graphs (inference) [ref 4]. There is no need for these models to store and node/link embeddings. The graph SAGE model that leverages PyTorch Geometric is strictly inductive.

Transductive graph models are trained on the complete, fully defined graph (all nodes and edges). As a result, they tend to overfit the training set and struggle to generalize to unseen nodes, edges, or entirely new graphs. Their message passing and aggregation schemes are typically straightforward. Our PyTorch Geometric implementation of the Graph Convolutional Network follows this transductive setting.

A brief comparison between GCN and GraphSAGE was presented in a previous article [ref 5]. Here is a different perspective:

Table 1 Comparison attributes of inductive (GraphSAGE) and transductive (GCN) models


📌 Some of graph neural network (e.g., GAT) can run inductively and transductively, although they tend to be evaluated as transductive graphs.


PyTorch Geometric Library

Library Overview

PyTorch Geometric has emerged as a leading library for exploring and implementing Graph Neural Networks (GNNs) using PyTorch.

The key Features of PyTorch Geometric are:

  • Efficient Graph Processing: Optimizes memory and computation using sparse graph representations.

  • Flexible GNN Layers: Covers GCN, GAT, GraphSAGE, GIN, and other advanced architectures.

  • Batching for Large Graphs: Supports for mini-batching for handling graphs with millions of edges.

  • Seamless PyTorch Integration: Provides full compatibility with PyTorch tensors, autograd, and neural network modules.

  • Diverse Graph Support: PyTorch Geometric handles directed, undirected, weighted, and heterogeneous graphs.

The most important PyG Modules are:

  • torch_geometric.data to manages graph structures, including nodes, edges, and features.

  • torch_geometric.nn to provide data scientists prebuilt GNN layers like convolutional and gated layers.

  • torch_geometric.transforms to pre-process input data (e.g., feature normalization, graph sampling).

  • torch_geometric.loader to handle large-scale graph datasets with specialized loaders.

Installation

Verify environment

python -c “import torch; print(torch.__version__)”

PIP Installation

pip install torch_geometric

Conda Installation

conda install pyg -c pyg

Extension libraries and dependencies

pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-${TORCH}-{VERSION}+${CUDA}-{VERSION}.html

Core

pip install torch_geometric

🏛️ Evaluation Configuration

The objective is to compare the performance of GCN and GraphSAGE models for classifying nodes, given a set of dynamic evaluation parameters.

Model Parameters for Evaluation

Using the strengths of GraphSAGE and GCN outlined above, we set our evaluation knobs as follows.

  • Homophily: GraphSAGE is more robust on low-homophily graphs thanks to learnable aggregators (e.g., mean, sum), whereas GCN tends to degrade.

  • Network Depth: GraphSAGE often benefits from deeper stacks of graph layers than its convolutional counterpart.

  • Neighborhood scope: The depth vs. fan-out of sampling materially affects node-classification performance.

  • Size of the graph: GCN leverages the entire graph during training and therefore consumes significantly more memory.


📌 The choice of message aggregator (e.g., mean, GCN-style, max-pool) affects the performance of inductive models like GraphSAGE. We encourage readers to experiment with different aggregation functions.


Performance Metrics

We are using the following performance metrics: Accuracy, Precision, Recall, F1, Area under the ROC curve and Area under Precision/Recall curve.


📌 We make no task-specific assumptions (node classification, link prediction, etc.); instead, we use the most common performance metrics to ensure a consistent comparison.


🏛️ Datasets

We select two well-known datasets from PyTorch Geometric library

  • Cora, a small graph with high homophily. This is a standard benchmark dataset for semi-supervised node classification, containing 2,708 nodes (scientific publications) and 5,429 edges (citations). Each node is described by a 1,433-dimensional feature vector. GCN’s full-batch, Laplacian-based propagation matches this regime and typically edges out or matches GraphSAGE while being simpler. This dataset is also included in torch_geometric.datasets.Planetoid class collection.

  • Flickr, a large graph with low homophily. This dataset contains descriptions and common properties of 89,250 images along with 899.756 edges and a 500-dimensional feature vector. It is defined in torch_geometric.datasets.Flickr class. GraphSAGE commonly trained with mini-batch neighbor sampling of Flickr.

    Homophily is not as high as citation graphs, so simple Laplacian smoothing (GCN) can be less effective; SAGE’s learnable aggregations (mean/max/attention or “gcn” variant) tend to be more robust.

Cora node homophily: 0.825
Cora edge homophily: 0.810
Cora edge_insensitive homophily: 0.766

Flickr node homophily: 0.322
Flickr edge homophily: 0.319
Flickr edge_insensitive homophily: 0.070

🔓 The rest of this deep dive is exclusive to paid subscribers. By upgrading, you unlock this full article along with a comprehensive archive of engineering articles, paper review, concept breakdowns, code walkthrough, GitHub repository and Q&A.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2026 Patrick Nicolas · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture