# Inductive Representation Learning on Large Graphs

William L. Hamilton, Rex Ying, Jure Leskovec · arXiv · 2017-6-7

- **Problem** Most node embedding methods learn one vector per node of a fixed graph, so nodes that arrive later need extra optimization before they can be embedded.
- **Method** GraphSAGE learns aggregation functions that combine the features of sampled neighbors across depths, and trains them with a graph-based unsupervised loss or a supervised loss.
- **Results** Unsupervised GraphSAGE-pool reached a micro-averaged F1 of 0.798 on the citation data, against 0.701 for DeepWalk plus features.

## Why fixed-graph node embeddings struggle with new nodes

Node embeddings compress a node's graph neighborhood into a dense vector that downstream classifiers and link predictors can consume. Most of these methods optimize a separate vector for every node using matrix-factorization-style objectives on a single graph, so a node that appears later has no vector until the model is updated. Adapting these methods to unseen nodes is possible, but each new node then requires further optimization steps before it can be scored, which makes the adaptation expensive.

Several of these objectives do not change under orthogonal transformations of the embeddings, so embedding spaces learned from different graphs or training runs need not line up.

Graph convolutional networks offered a different route, but they had only been used in the transductive setting on fixed graphs, which leaves inductive unsupervised learning open. Generalizing to a new node means placing its newly observed subgraph relative to embeddings that were already optimized, so the model has to recognize neighborhood structure rather than rely on node identity.

## Learning aggregators instead of node vectors

GraphSAGE drops the per-node lookup table. It learns a small set of aggregation functions, and each one combines the features of a node's neighbors, so information from farther away enters the node's representation as the depth grows. Figure 1 illustrates the sample and aggregate pattern that this produces. Node features are the base input, and structural features such as node degree can also be used, so the same method applies to graphs that come without node features.

Because the learned functions are shared across nodes, a new node is embedded by running them over its own neighborhood, with no training on that node. Training is driven either by an unsupervised graph-based loss or by a supervised task loss, so the same architecture covers both settings.

## The forward pass in Algorithm 1

At depth k, each node combines the depth k minus one representations of its neighbors into one vector with the aggregator, \\\[ h\_{\\mathcal{N}(v)}^k \\leftarrow \\text{AGGREGATE}\_k\\big(\\{h\_u^{k-1}, \\forall u \\in \\mathcal{N}(v)\\}\\big) \\\] The node's own depth k minus one representation is concatenated with that aggregate, multiplied by the weight matrix \\(W^k\\), and passed through the nonlinearity \\(\\sigma\\), so that \\(h\_v^k \\leftarrow \\sigma(W^k \\cdot \\mathrm{CONCAT}(h\_v^{k-1}, h\_{\\mathcal{N}(v)}^k))\\).

Each depth's output is then divided by its L2 norm, \\(h\_v^k \\leftarrow h\_v^k / \\\|h\_v^k\\\|\_2\\), so every representation passed to the next depth has unit length.

After K depths, the output for each node is \\(z\_v \\equiv h\_v^K\\), and the aggregator is the only part that changes between architectures. The computation is defined node by node and assumes fixed parameters, which is why the same steps can be run on nodes that lie outside the training graph once training is finished.

## Fixed-size neighborhood sampling

Using all neighbors would make the memory and runtime of a batch depend on node degree, which in the worst case scales with the size of the whole graph. GraphSAGE instead draws a uniform, fixed-size set of neighbors for each node at every depth and every iteration, so that the cost of a batch stays bounded.

The per-batch space and time complexity is fixed at a product over the depths of the sample sizes \\(S\_i\\), which the authors found enough for high performance with K = 2 and \\(S\_1 \\cdot S\_2 \\leq 500\\). The experiments use K = 2 with \\(S\_1 = 25\\) and \\(S\_2 = 10\\).

## Unsupervised and supervised training

The unsupervised objective asks nearby nodes to have similar representations and disparate nodes to have dissimilar ones. Nearby means that two nodes co-occur on a fixed-length random walk. The loss is \\\[ J\_G(z\_u) = -\\log\\big(\\sigma(z\_u^\\top z\_v)\\big) - Q \\cdot \\mathbb{E}\_{v\_n \\sim P\_n(v)} \\log\\big(\\sigma(-z\_u^\\top z\_{v\_n})\\big) \\\] where \\(v\\) co-occurs with \\(u\\), \\(\\sigma\\) is the sigmoid, \\(P\_n\\) is the negative sampling distribution and \\(Q\\) is the number of negative samples.

The first term rewards a high sigmoid score for a co-occurring pair, and the second term lowers the score for \\(Q\\) negative samples drawn from \\(P\_n\\), so minimizing the loss pulls co-occurring pairs together and pushes random pairs apart. The vectors \\(z\_u\\) come from the neighborhood aggregation rather than from an embedding lookup, which is the change from earlier embedding objectives.

For a specific downstream task, the unsupervised loss can be replaced or augmented by a task-specific objective such as cross-entropy, and the supervised variants are trained that way. The parameters are updated by stochastic gradient descent with backpropagation, using Adam in the experiments.

## Three aggregator designs for an unordered neighbor set

A node's neighbors have no natural ordering, so an aggregator should be symmetric, or at least behave as if it were, to handle arbitrarily ordered neighbor sets. The mean aggregator takes the element-wise mean of the neighbor vectors, which is symmetric by construction. Its convolutional variant averages the node's own vector together with its neighbors and applies the weight matrix, \\\[ h\_v^k \\leftarrow \\sigma\\big(W \\cdot \\mathrm{MEAN}(\\{h\_v^{k-1}\\} \\cup \\{h\_u^{k-1}, \\forall u \\in \\mathcal{N}(v)\\})\\big) \\\] and it does not concatenate the node's own vector in the way the other variants do.

The authors read the concatenation as a skip connection between depths and report significant performance gains from it. The LSTM aggregator has larger expressive capacity than the mean, but an LSTM is not permutation invariant. The authors therefore apply it to a random permutation of each node's neighbors. The pooling aggregator passes each neighbor through a fully connected layer and then takes an element-wise max, \\\[ \\mathrm{AGGREGATE}^{\\mathrm{pool}}\_k = \\max\\big(\\{\\sigma(W\_{\\mathrm{pool}} h\_{u\_i}^k + b), \\forall u\_i \\in \\mathcal{N}(v)\\}\\big) \\\] where the experiments use single-layer transformations.

Mean and max pooling produced no significant difference in development tests, so the experiments focus on max-pooling.

## Link to the Weisfeiler-Lehman test

If Algorithm 1 uses K equal to the number of nodes, identity weight matrices and a hash function with no nonlinearity as its aggregator, it becomes the Weisfeiler-Lehman test, also called naive vertex refinement. GraphSAGE can be read as a continuous approximation of that test, with trainable neural aggregators in place of the hash function.

The authors use the link as theoretical context for the design, not as a method for testing graph isomorphism, and they note that the Weisfeiler-Lehman test fails in some cases.

## Datasets, baselines and training conditions

The citation data is an undirected graph from the Web of Science Core Collection covering six biology-related fields for 2000 to 2005. It has 302,424 nodes with an average degree of 9.15. Training uses the 2000-2004 data, testing uses the 2005 data, and 30% of the data is used for validation. Features are node degrees together with abstract embeddings computed with Arora et al.'s sentence embedding approach over 300-dimensional word vectors.

It has 232,965 posts with an average degree of 492. Training uses the first 20 days and testing uses the remaining days, with 30% of the data used for validation. Post features are 300-dimensional GloVe CommonCrawl vectors of the title and comments, together with the post score and the comment count.

The PPI collection has one graph per human tissue, with 121 gene ontology label sets and an average of 2373 nodes per graph. Training uses 20 graphs, testing uses two graphs that were unseen during training, and two other graphs are used for validation. Baselines are a random classifier, logistic regression on raw features, DeepWalk, and DeepWalk concatenated with the raw features.

The four GraphSAGE variants are GraphSAGE-GCN, GraphSAGE-mean, GraphSAGE-LSTM and GraphSAGE-pool, each trained unsupervised and supervised. For the citation and Reddit data, DeepWalk embeds test nodes through online training with new SGD rounds, while in the multi-graph setting DeepWalk is not applied because embedding spaces from disjoint graphs can be rotated arbitrarily relative to each other.

All GraphSAGE variants share one hyperparameter sweep, with the best setting for each chosen on a validation set, and the sweep ranges were set in early tests on subsets of the citation and Reddit data that were later discarded.

## Citation and Reddit results

On the citation data, unsupervised GraphSAGE-pool reached 0.798 micro-averaged F1, compared with 0.701 for DeepWalk plus features and 0.575 for raw features. The table lists gains over the features baseline of 39% for unsupervised and 46% for supervised GraphSAGE on the citation data. The full table of micro-averaged F1 scores for every method on the three datasets is given as Table 1.

On Reddit, unsupervised GraphSAGE-LSTM reached 0.907, compared with 0.691 for DeepWalk plus features, 0.585 for raw features and 0.324 for DeepWalk alone. Unsupervised GraphSAGE-pool outperforms DeepWalk plus features by 13.8% on the citation data and by 29.1% on Reddit, while the supervised version gains 19.7% and 37.2% respectively.

The authors note that unsupervised GraphSAGE stays reasonably close to its supervised version, which they read as the framework reaching strong performance without task-specific fine-tuning. The LSTM aggregator performs well even though it is designed for sequential data rather than unordered sets.

## Generalizing to unseen PPI graphs

Supervised GraphSAGE-LSTM reached 0.612 micro-averaged F1 on the PPI test graphs, compared with 0.422 for raw features. Supervised GraphSAGE-pool reached 0.600 and GraphSAGE-mean 0.598, while the GCN-based variant reached 0.500. The table gives gains over features of 19% unsupervised and 45% supervised on PPI.

The authors report that the LSTM and pooling aggregators provide substantial gains over the mean and GCN-based aggregators on this task. The comparison is against raw features only, because DeepWalk cannot be applied across disjoint PPI graphs.

## Runtime and neighborhood size

Training times are comparable across methods, with GraphSAGE-LSTM the slowest, while DeepWalk must sample new random walks and run new SGD rounds for unseen nodes. That makes DeepWalk 100-500 times slower than GraphSAGE at test time.

Setting K = 2 gave a consistent boost of around 10-15% on average over K = 1 for the GraphSAGE variants. Increasing K beyond 2 gave only 0-5% more, while raising runtime by a factor of 10-100, depending on the neighborhood sample size.

Larger neighborhoods give diminishing returns, so sub-sampling keeps the runtime low at a modest accuracy cost.

## Which aggregator performs best across settings

The six settings are the three datasets crossed with unsupervised and supervised training, and each is treated as one trial in a Wilcoxon signed-rank test. The LSTM, pool and mean aggregators each give a statistically significant gain over the GCN-based aggregator, with T = 1.0 and p = 0.02 for all three.

The gains of the LSTM and pool aggregators over the mean aggregator are smaller: LSTM against mean gives T = 1.5 and p = 0.03, and pool against mean gives T = 4.5 and p = 0.10. LSTM and pool do not differ significantly, with T = 10.0 and p = 0.46. GraphSAGE-LSTM is roughly 2 times slower than GraphSAGE-pool, which the authors take as a slight overall edge for the pooling aggregator.

## Can feature-based GraphSAGE capture clustering coefficients?

The clustering coefficient of a node measures how many of the node's neighbor pairs are linked, that is, the share of triangles closed within its one-hop neighborhood. The authors ask whether GraphSAGE, which sees only features, can learn this quantity.

Theorem 1 takes features \\(x\_v\\) in a compact subset \\(U\\) of \\(\\mathbb{R}^d\\), with \\(\\\|x\_v - x\_{v'}\\\|\_2 \> C\\) for all pairs of nodes and a fixed positive constant \\(C\\). Under these conditions, for any \\(\\epsilon \> 0\\) there is a parameter setting \\(\\Theta^\*\\) such that after K = 4 iterations \\(\|z\_v - c\_v\| \< \\epsilon\\) for all \\(v \\in V\\), where \\(c\_v\\) is the clustering coefficient.

The statement is an existence result for each graph, so it does not say that gradient-based training reaches that parameter setting. The proof relies on properties of the pooling aggregator. Distinct features let each node map to an indicator vector, which identifies its neighborhood. As a corollary, GraphSAGE can learn local graph structure when node features are sampled from an absolutely continuous random distribution.

## Limitations

The aggregator comparison uses six trials, and the authors state that this makes the Wilcoxon test underpowered, so its T-statistics and p-values serve as relative indicators. Sub-sampling neighborhoods induces higher variance, and the authors report that performance remains strong despite it.

The sampler draws neighbors uniformly, and non-uniform samplers are left as future work. The theorem covers only clustering coefficients and only node features that are pairwise separated and drawn from a compact set. The PPI comparison has no DeepWalk entry, so its gains are measured against raw features only.

## Paper info

- **Authors**: William L. Hamilton, Rex Ying, Jure Leskovec
- **Venue**: arXiv · Preprint
- **First published**: 2017-6-7
- **Added**: 2026-10-20
- **Updated**: 2018-9-10
- **Version**: v4
- **arXiv**: 1706.02216
- **Category**: cs.SI · cs.LG · stat.ML
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1706.02216v4) · [PDF ↗](https://arxiv.org/pdf/1706.02216v4)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

William L. Hamilton, Rex Ying, Jure Leskovec (2017). Inductive Representation Learning on Large Graphs. arXiv:1706.02216v4. https://arxiv.org/abs/1706.02216v4

**BibTeX**

```
@misc{hamilton2017inductive,
  title = {{Inductive Representation Learning on Large Graphs}},
  author = {William L. Hamilton and Rex Ying and Jure Leskovec},
  year = {2017},
  eprint = {1706.02216},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1706.02216v4}
}
```

## Other paper commentary

- [Bootstrap your own latent: A new approach to self-supervised Learning](https://refivu.com/en/papers/e1bafe00-ea17-46b4-a31b-5db9555dcd50-bootstrap-your-own-latent-a-new-approach-to.md)
- [ALBERT: A Lite BERT for Self-supervised Learning of Language Representations](https://refivu.com/en/papers/7a3fbf64-0a8d-440d-a8cf-5d65c573adde-albert-a-lite-bert-for-self-supervised-learning.md)
- [Beyond task diversity: provable representation transfer for sequential multitask linear bandits](https://refivu.com/en/papers/6f518ea7-2bdf-47ac-a17e-67345dad8aa7-beyond-task-diversity-provable-representation-transfer-for.md)
- [Spiked-CFR: Causal Representation Learning from LLMs via Wasserstein Projection Pursuit](https://refivu.com/en/papers/a092dcb5-227e-4a9c-9f4c-0ed769acba0a-spiked-cfr-causal-representation-learning-from-llms-via.md)
- [Deneb-Vritra: Descriptions, Edges and Names Examined by Blocking Via Restoring Token Representations and Attention](https://refivu.com/en/papers/0b67f9eb-1c6f-468f-98bf-5eb090a75bfd-deneb-vritra-descriptions-edges-and-names-examined-by.md)
- [Embedding Dimension of Contrastive Learning and $k$-Nearest Neighbors](https://refivu.com/en/papers/9df2424e-149a-4953-912c-2bdfc9b778bc-embedding-dimension-of-contrastive-learning-and-k-nearest.md)
- [Emerging Properties in Self-Supervised Vision Transformers](https://refivu.com/en/papers/d2f53db5-080e-4342-beab-1de92f307256-emerging-properties-in-self-supervised-vision-transformers.md)
- [Efficiently Modeling Long Sequences with Structured State Spaces](https://refivu.com/en/papers/9047ef9d-9e54-48f1-8609-ea4ce704605e-efficiently-modeling-long-sequences-with-structured-state.md)
- [Masked Autoencoders Are Scalable Vision Learners](https://refivu.com/en/papers/d17cea4d-36fc-40d3-bc98-6bc3e98f24df-masked-autoencoders-are-scalable-vision-learners.md)
- [Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity](https://refivu.com/en/papers/2712d011-b4e2-4181-89ce-e47fc4a5117c-switch-transformers-scaling-to-trillion-parameter-models.md)
- [Wasserstein GAN](https://refivu.com/en/papers/6fbb2587-49dc-4b1a-9bb9-ee89b40b9221-wasserstein-gan.md)
- [Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer](https://refivu.com/en/papers/01d9fd25-ae98-40fb-a44a-08c4b727555b-outrageously-large-neural-networks-the-sparsely-gated.md)

## Terms in this paper

- [Negative sampling](https://refivu.com/en/terms/1dbdea971d8c-negative-sampling)
- [GraphSAGE](https://refivu.com/en/terms/c4baff75600a-graphsage)
- [DeepWalk](https://refivu.com/en/terms/6f5bcebcffef-deepwalk)
- [Random Walk](https://refivu.com/en/terms/1eea91355912-random-walk)
- [aggregator](https://refivu.com/en/terms/37f07f5ceea8-aggregator)
- [graph convolutional network](https://refivu.com/en/terms/8c589506f1df-graph-convolutional-network)
- [Mean aggregator](https://refivu.com/en/terms/a2158cd74a8a-mean-aggregator)
- [PPI](https://refivu.com/en/terms/6839f59f724d-ppi)
- [transductive](https://refivu.com/en/terms/3cb3141f0ac4-transductive)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/ff5e1161-efee-4eaf-8a5b-ca4227613b73-inductive-representation-learning-on-large-graphs)
