AI Glossary / Deep learning / Intermediate
Graph neural network
Definition
A graph neural network, or GNN, is a neural model designed to learn from data represented as a graph of nodes and edges. Nodes represent entities, and edges represent specified relationships between them. Many GNNs update a node's representation by combining information from its neighbors, then use the learned representations for node, edge, or whole-graph predictions. The graph's construction is part of the model design, not a neutral preprocessing detail.
What it means
Ordinary feature tables describe individual records, while a graph also describes how records connect. A GNN can use both features and relational structure. For example, products may connect through observed interactions, or atoms through bonds. Graphs can be directed, weighted, heterogeneous, or changing over time, and the chosen model must match those distinctions. The word graph here means a network of relationships, not a bar chart or a plot of a mathematical function.
How it works
A common message-passing layer computes messages using neighboring representations and possibly edge features. It aggregates the messages with an order-independent operation, such as a sum or mean, then updates the receiving node's representation. Repeating layers lets information travel farther through the graph. A readout may combine node representations for a whole-graph result. Shared transformations and suitable aggregation let the model operate consistently under node relabeling. Different GNN families use different messages, normalizations, attention rules, and update functions; message passing is an important framework, not the only possible graph-learning design.
Three practical examples
- Molecular modeling: a graph uses atoms as nodes and bonds as edges to estimate a property of the whole molecule.
- Recommendation research: users and items form a relationship graph whose learned representations help score possible interactions.
- Infrastructure analysis: a graph of linked components helps estimate node or system behavior when relationships add useful information beyond individual component features.
Think of it this way
Think of people updating their understanding after receiving summarized information from neighbors. Several rounds can convey information from farther away. The analogy is limited because GNN messages are numerical transformations, the graph may encode nonhuman relationships, and more rounds do not necessarily improve understanding or preserve all distinctions.
Worked example
Consider an undirected chain with nodes A, B, and C, connected A-B-C. Their initial scalar features are 2, 4, and 8. Define a deliberately simple update: each node's new feature equals its old feature plus the mean of its neighbors' old features. All nodes update simultaneously. A becomes 2 plus 4 = 6. B becomes 4 plus the mean of 2 and 8, or 9. C becomes 8 plus 4 = 12.
Apply the same rule again using [6, 9, 12]. A becomes 15, B becomes 18, and C becomes 21. C's original feature can now influence A through B, despite there being no direct A-C edge. Renaming the nodes without changing features and connectivity would simply rename these results. This toy operation has no learned weights or activation and is not a trained predictive model. It illustrates neighborhood aggregation and simultaneous updates; processing nodes sequentially with already updated values would implement a different computation.
Illustrative case study
A fictional recommendation team builds a user-item graph and evaluates a GNN on later interactions. A review discovers that some future interactions were included as edges when constructing training representations. The apparent performance improvement therefore contains information that would not have been available at prediction time. The team rebuilds time-appropriate graphs and repeats evaluation before comparing the method with a non-graph baseline. The case shows why graph construction and temporal availability belong in validation design.
Common misconceptions and mistakes
An edge does not automatically indicate causation, similarity, or a trustworthy relationship; its meaning must be defined. More message-passing layers can lead to problems such as increasingly similar node representations or difficulty transmitting many distant signals through limited representations. Standard message-passing models also have expressivity limits and cannot distinguish every possible graph structure. A transductive setup using a known graph differs from inductive prediction for unseen nodes or graphs, and results should identify which setting was evaluated.
Business use
A GNN is worth considering when relationships plausibly add predictive information and the graph can be maintained reliably. Compare against models using node features alone and against simpler relational features to isolate the value of the learned graph processing. Include edge construction, storage, sampling, refresh frequency, and inference cost in the operational assessment. Missing or incorrect edges can affect predictions, so monitor graph quality as well as model metrics. Document which features and connections are available at the actual decision time.
People also ask
Must every node have the same number of neighbors?
No. Aggregation can handle different neighborhood sizes, although normalization and sampling choices matter.
Is a GNN the same as a graph database?
No. A database stores and queries graph data; a GNN learns numerical representations or predictions from graph structure and features.
Can it predict a whole graph's property?
Yes. A suitable readout combines node information into a graph-level representation.
Check your understanding
In a basic neighborhood message-passing model with no global links, can one layer transmit C's feature to A in the chain A-B-C?
Answer: Not directly. A receives from B's previous representation; two rounds can carry C's information through B under this setup.
Related terms
- Graph
- Node
- Message passing
- Embedding
- Inductive learning
- edge
- graph convolution
- graph attention
- transductive learning
Learn next
implement a single aggregation step on a tiny labeled graph and verify that renaming nodes does not change the underlying result. Then study graph-specific train-test splits, temporal leakage, and the distinction between node-level and graph-level tasks.
More in Deep learning
- Generalized Hebbian algorithm - The generalized Hebbian algorithm, or GHA, is an unsupervised learning rule for a linear neural network that learns leading directions of variation in its...
- Generative topographic map - A generative topographic map, usually discussed as generative topographic mapping or GTM, is a probabilistic nonlinear latent-variable model for...
- Gradient clipping - Gradient clipping is a training technique that limits the magnitude of gradients before an optimizer uses them to update model parameters.
- Grokking - Grokking is a machine-learning phenomenon in which a model achieves strong performance on its training examples, remains poor on unseen examples for an...
- Grossberg network - Grossberg network is a broad label associated with neural models developed by Stephen Grossberg, rather than one uniquely specified modern architecture.
- Group method of data handling - The group method of data handling, or GMDH, is a family of inductive modeling methods that generate candidate models, estimate their parameters from data...
Sources
Gilmer and colleagues, Neural Message Passing for Quantum Chemistry: https://arxiv.org/abs/1704.01212 PyTorch Geometric, creating message-passing networks: https://pytorch-geometric.readthedocs.io/en/latest/tutorial/create_gnn.html
Previous: Graph matching Next: Graph of a function