Machine Learning

GCN, GraphSAGE, and GAT

GCN, GraphSAGE, and GAT differ by the neighbor operator: fixed normalized smoothing, sampled aggregation, or learned attention over a node's neighborhood.

status: reviewimportance: criticaldifficulty 4/5math: graduateread: 24mlive demo

Concept Structure

GCN, GraphSAGE, and GAT

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Manipulate the mechanism and watch the idea respond.

2prerequisites
1next concepts
4related links

Learner Contract

What this page should let you do.

You are here becauseGCN, GraphSAGE, and GAT differ by the neighbor operator: fixed normalized smoothing, sampled aggregation, or learned attention over a node's neighborhood.

This Machine Learning concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.

By the end4/4 sections ready | runnable code expected | live demo

Explain the mechanism, trace the main notation, and test one prediction in the live demo.

Do this firstIntuition

Read the intuition before the notation; the math should name a mechanism you already felt.

Then go nextGraph Transformers (planned)

Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.

Test the linkManipulate one control and predict the visible change.

Claim/source review status

Substantive review recorded

1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.
Claims1/1 reviewed
Sources5 cited
Codeattached
Demolive
Reviewed2026-07-02
Updatedpage 2026-07-02

Learning item flow

4/4 sections readyAsk about thisResearch room
ConceptGCN, GraphSAGE, and GATMachine Learning
5 sources attachedLocal snapshot ready
concept:machine-learning/gcn-graphsage-gat
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

You already know the message-passing template: a node gathers information from its neighbors, combines it, and updates its representation.

This page asks the next question:

When several neighbors can speak, who gets how much influence?

GCN, GraphSAGE, and GAT are not three unrelated inventions. They are three answers to the neighbor-operator question.

  • GCN: use the graph structure to assign fixed normalized coefficients. High-degree neighbors and the focus node are scaled by degree.
  • GraphSAGE: sample a neighborhood and aggregate it, often so the same learned rule can be used inductively on unseen nodes.
  • GAT: learn attention coefficients over the focus node's neighborhood, so some neighbors can matter more than others for this layer.

The important learning move is to keep the graph fixed. Do not compare the names in the abstract. Put one focus node under all three operators and ask which neighbor gets the strongest path into the updated representation.

That is the whole demo: one graph, focus node 3, and a single prediction about node 5's influence.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

Let G=(V,E)G=(V,E) be a graph with node-feature matrix

H()RV×d.H^{(\ell)}\in\mathbb R^{|V|\times d}.

We focus on one target node vv and its one-hop neighborhood N(v)\mathcal N(v). To compare operators cleanly, define a shared transformed feature

zu=Whu(),zuRd.z_u = W h_u^{(\ell)}, \qquad z_u\in\mathbb R^{d'}.

The page's finite demo uses this same zuz_u for all three operators so the visible difference is which nodes get how much influence, not a hidden difference in learned matrices.

GCN: fixed normalized adjacency

With self-loops, let

A^=A+I,D^ii=jA^ij.\hat A = A + I, \qquad \hat D_{ii}=\sum_j \hat A_{ij}.

A common GCN layer has the propagation form

H(+1)=σ(D^1/2A^D^1/2H()W).H^{(\ell+1)} = \sigma\left(\hat D^{-1/2}\hat A\hat D^{-1/2}H^{(\ell)}W\right).

For a single node vv, the coefficient from source node uu into vv is

cv,uGCN=1d^vd^uwhen uN(v){v}.c^{\mathrm{GCN}}_{v,u} = \frac{1}{\sqrt{\hat d_v\hat d_u}} \quad\text{when } u\in \mathcal N(v)\cup\{v\}.

The key point: the coefficient is fixed by the graph degrees. It is not learned per edge in this layer.

GraphSAGE: sampled aggregate plus self/root term

GraphSAGE keeps the neighborhood-aggregation idea but emphasizes sampling and inductive aggregation. A simplified mean-aggregator view is

av=1S(v)uS(v)zu,S(v)N(v),a_v = \frac{1}{|S(v)|}\sum_{u\in S(v)} z_u, \qquad S(v)\subseteq \mathcal N(v),

then combines the aggregate with the node's own transformed state:

hv(+1)=σ(Wselfhv()+Wnbrav).h_v^{(\ell+1)} = \sigma\left(W_{\mathrm{self}}h_v^{(\ell)} + W_{\mathrm{nbr}}a_v\right).

The demo uses a transparent root blend:

h~v=12zv+12(1S(v)uS(v)zu).\tilde h_v = \frac{1}{2}z_v+\frac{1}{2}\left(\frac{1}{|S(v)|}\sum_{u\in S(v)}z_u\right).

That is not the full GraphSAGE training recipe. It is a finite witness for the operator idea: only sampled neighbors can contribute in that step.

GAT: learned attention over the neighborhood

Graph Attention Networks compute a coefficient for each allowed neighbor:

αv,u=softmaxuN(v){v}(ev,u),\alpha_{v,u} = \operatorname{softmax}_{u\in\mathcal N(v)\cup\{v\}} \left(e_{v,u}\right),

where ev,ue_{v,u} is a learned compatibility score computed from transformed node features. The update is an attention-weighted sum:

h~v=uN(v){v}αv,uzu.\tilde h_v = \sum_{u\in\mathcal N(v)\cup\{v\}}\alpha_{v,u}z_u.

The key point: the graph still masks which nodes are allowed to speak, but the relative influence inside that neighborhood is learned.

So the comparison is:

GCN:degree-normalized fixed coefficients,GraphSAGE:sampled aggregate plus self/root information,GAT:learned attention coefficients over allowed neighbors.\begin{aligned} \text{GCN} &:\quad \text{degree-normalized fixed coefficients},\\ \text{GraphSAGE} &:\quad \text{sampled aggregate plus self/root information},\\ \text{GAT} &:\quad \text{learned attention coefficients over allowed neighbors}. \end{aligned}
03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
import numpy as np

h = {
    "self": np.array([0.2, 0.8]),
    "n1":   np.array([1.0, 0.1]),
    "n4":   np.array([-0.4, 0.9]),
    "n5":   np.array([-0.8, 0.7]),
}
W = np.array([[0.6, -0.3], [0.2, 0.75]])
z = {k: W @ v for k, v in h.items()}

# Focus node 3 has self, n1, n4, n5 in its self-loop neighborhood.
# Self-loop degrees: d_self=4, d_n1=3, d_n4=4, d_n5=3.
gcn = {
    "self": 1 / np.sqrt(4 * 4),
    "n1":   1 / np.sqrt(4 * 3),
    "n4":   1 / np.sqrt(4 * 4),
    "n5":   1 / np.sqrt(4 * 3),
}
graphsage = {"self": 0.50, "n1": 0.25, "n4": 0.00, "n5": 0.25}
gat = {"self": 0.15, "n1": 0.11, "n4": 0.28, "n5": 0.46}

def mix(weights):
    return sum(weights[k] * z[k] for k in weights)

for name, weights in [("GCN", gcn), ("GraphSAGE", graphsage), ("GAT", gat)]:
    print(name, "node-5 coefficient", round(weights["n5"], 3),
          "output", np.round(mix(weights), 3))

This code intentionally uses one shared transform WW. In a trained model, each architecture may learn different weights. Here the witness isolates the neighbor operator: fixed normalization, sampled aggregation, or learned attention.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

Section prompt

Use the Neighbor Operator Comparison Lab to predict which operator gives node 5 the most influence on focus node 3.

Before reveal, the coefficients, sampled-neighbor mask, attention weights, and mixed output vectors stay locked. After you commit, the ledger shows exactly how much influence node 5 received under each operator.

This is a comparison of one layer on one tiny graph. It teaches the operator difference, not a universal ranking of GCN, GraphSAGE, and GAT.

Live Concept Demo

Explore GCN, GraphSAGE, and GAT

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 4/5graduatecode-aligned
Demo Prediction Checkpoint

Manipulate one control and predict the visible change.

Commit to what GCN, GraphSAGE, and GAT should make visible before reading the result.

After The First Pass

Turn the concept into an inspected object.

Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.

Mechanism Storyboard

See the idea move before the page explains it

GCN, GraphSAGE, and GAT differ by the neighbor operator: fixed normalized smoothing, sampled aggregation, or learned attention over a node's neighborhood.

Prediction open01 / Intuition
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change GCN, GraphSAGE, and GAT should make visible.

Visual Inquiry

Make the image answer a mathematical question

GCN, GraphSAGE, and GAT differ by the neighbor operator: fixed normalized smoothing, sampled aggregation, or learned attention over a node's neighborhood.

4/4 stages readyLive demo connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make GCN, GraphSAGE, and GAT easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

paper · 2017Semi-Supervised Classification with Graph Convolutional NetworksKipf and Welling

Primary source for the GCN layer and the renormalized self-loop adjacency form.

Open source
paper · 2017Inductive Representation Learning on Large GraphsHamilton, Ying, and Leskovec

Primary source for GraphSAGE's sample-and-aggregate inductive framing.

Open source
paper · 2018Graph Attention NetworksVelickovic et al.

Primary source for learned masked self-attention over node neighborhoods.

Open source
course-notes · 2026Stanford CS224W: Graph Neural Networks 2Stanford CS224W

Course source for comparing GCN, GraphSAGE, and GAT families.

Open source
documentation · 2026PyTorch Geometric convolution layer documentationPyTorch Geometric

Implementation reference for GCNConv, SAGEConv, and GATConv layer APIs.

Open source

Claim Review

GCN, GraphSAGE, and GAT differ by the neighbor operator: fixed normalized smoothing, sampled aggregation, or learned attention over a node's neighborhood.

Status1 substantive review recorded

Claims without a substantive review badge still need exact source-support review.

Sources5 references

kipf-welling-2017-gcn, hamilton-2017-graphsage, velickovic-2018-gat, cs224w-gnn2, pyg-gcn-sage-gat-2026

Local checks4 local checks

Use equations, runnable code, and demos to check whether the source support is operational.

Substantively reviewedGCN, GraphSAGE, and GAT are all one-hop message-passing families, but they differ in how a focus node weights or selects neighbors: fixed degree-normalized coefficients, sampled aggregation, or learned attention coefficients.Claim metadata: source checked

The sources support the page's comparison of fixed normalized adjacency mixing, sampled neighborhood aggregation, and learned attention-weighted neighborhood mixing.

Sources: Semi-Supervised Classification with Graph Convolutional Networks, Inductive Representation Learning on Large Graphs, Graph Attention Networks, Stanford CS224W: Graph Neural Networks 2, PyTorch Geometric convolution layer documentationFinite one-node teaching witness only; it does not train the models, compare accuracy, cover edge features, multi-head aggregation, layer stacking, over-smoothing, sampling variance at scale, sparse batching, or graph-transformer variants.A bounded review summary is present; still check caveats and exact reference scope.

Checked Kipf/Welling for the normalized self-loop graph convolution, Hamilton/Ying/Leskovec for sample-and-aggregate inductive GraphSAGE, Velickovic et al. for masked attention over neighbors, Stanford CS224W for the course-level comparison, and PyTorch Geometric docs for implementation-level layer forms. GPT Pro publication critique remains pending because 127.0.0.1:51672 is unavailable.

Reviewer: codex-local-source-review; reviewed 2026-07-02

Practice Loop

Try the idea before it explains itself

GCN, GraphSAGE, and GAT differ by the neighbor operator: fixed normalized smoothing, sampled aggregation, or learned attention over a node's neighborhood.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in GCN, GraphSAGE, and GAT.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded research drawerClose
ConceptGCN, GraphSAGE, and GATMachine Learning
Runnable code comparisonGCN, GraphSAGE, and GAT runnable code 1h = {Prediction before revealGCN, GraphSAGE, and GAT interactive demoManipulate one control and predict the visible change.
Grounded room questionWhat is the smallest example that makes GCN, GraphSAGE, and GAT click without losing the math?Local snapshot ready

Research Room

Attach the question to a claim, equation, code, or demo

Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptMachine Learning

GCN, GraphSAGE, and GAT

Attached question

What is the smallest example that makes GCN, GraphSAGE, and GAT click without losing the math?

Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays in this browser, attached to the selected learning item.

No local draft saved.
Evidence to inspect
  • References to inspect: attached references on this page.
  • Definition, prerequisite, and contrast concept links
  • The equation or runnable code that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Grounded AI handoff

I am working in Continuous Function's research reading room. Object: concept - GCN, GraphSAGE, and GAT Selected item key: recorded for copy. Context: Machine Learning Page anchor: recorded for copy. Open question: What is the smallest example that makes GCN, GraphSAGE, and GAT click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.

View it in context
concept/concept-notebook/machine-learning/gcn-graphsage-gat concept:machine-learning/gcn-graphsage-gat