← Lessons

quiz vs the machine

Gold1430

Machine Learning

Graph Neural Networks Intro

Neural networks that learn from nodes, edges, and the structure connecting them.

5 min read · core · beat Gold to climb

Why graphs need their own networks

Standard networks assume fixed grids or sequences. But social networks, molecules, and recommendation graphs are irregular: nodes have varying numbers of neighbors and no natural order. Graph neural networks, or GNNs, are built to learn directly on this structure.

The core idea

A GNN learns a vector for each node by aggregating information from its neighbors. Each layer lets a node gather a summary of its neighbors and combine it with its own features. Stack two layers and a node sees its two hop neighborhood.

What a layer does

  • Message: each neighbor sends its current vector, possibly transformed.
  • Aggregate: combine incoming messages with a permutation invariant function like sum or mean.
  • Update: mix the aggregate with the node own vector to produce the next layer vector.

What you get

The final node vectors capture both features and structure. They feed downstream tasks: classify a node, predict a missing edge, or classify a whole graph. Popular variants include graph convolutional networks, GraphSAGE, and graph attention networks.

Key idea

Graph neural networks learn node vectors by aggregating neighbor information layer by layer, capturing both features and graph structure.

Check yourself

Answer to earn rating on the learn ladder.

1. Why are standard neural networks ill suited to graphs?

2. How does a GNN build a node representation?

3. What does stacking two GNN layers achieve?