Transfer Learning with Graph Neural Network

Machine Learning
Introduced by
Hu et al. (GNN-specific); Pan & Yang (transfer learning framework)
Year
2010–2020
Type
Transfer learning / graph representation learning
Family
Deep learning / NLP / CV

What does it do?

Transfer learning with graph neural networks (GNNs) adapts a GNN pre-trained on a large source graph dataset to a smaller target graph task, often one with few labels.

The pre-trained node and edge representations are reused as a starting point, which can improve predictive performance where labeled graph data are costly or slow to collect, as in chemistry, biology, and social network analysis.

The intuition behind the method

Graph neural networks learn to encode structural patterns, such as how a node relates to its neighbours, and some of these patterns may carry over between datasets. A GNN pre-trained on a large collection of molecular graphs can capture recurring bonding patterns. Whether such representations also help on a different domain, such as a protein-interaction dataset, is an open question: it is a hypothesis to be tested against a from-scratch baseline, not a result to assume. The idea parallels ImageNet pre-training in computer vision: invest in a large source dataset once, then reuse the learned representations for related tasks.

History

The general framework of transfer learning was reviewed by Pan and Yang in their survey, which discusses knowledge transfer for classification, regression, and clustering when training and future data differ in feature space or distribution. The survey appeared in IEEE Transactions on Knowledge and Data Engineering in 2010 (online record year 2009). The GNN-specific study by Hu et al. (2020, ICLR), 'Strategies for Pre-training Graph Neural Networks', examines strategies for pre-training GNNs and is the primary reference for pre-training approaches in this area; its experimental results should be consulted in the paper itself.

When to use it

Consider this approach when labeled target graphs are scarce relative to what a GNN needs to learn from scratch, and a structurally related source graph collection is available for pre-training or as a published checkpoint. It fits tasks such as molecular property prediction, node classification on citation networks, and knowledge graph completion, where source and target share similar node and edge semantics. Avoid it when source and target differ strongly in topology or attribute meaning, because transferred weights may then hurt performance (negative transfer). It is also unnecessary when the target dataset is large enough to train a GNN from scratch, and when the graph structure is unavailable, in which case simpler tabular models may suffice.

Limitations and considerations

  • Negative transfer can occur when source and target graphs differ substantially in topology or in the meaning of their node and edge attributes.
  • Pre-training at scale requires substantial compute and large curated graph datasets, which are not always available.
  • Node and edge attribute schemas must be aligned between source and target, which can require non-trivial feature engineering.
  • The transferred representations are hard to interpret, so it is difficult to explain why a pre-trained structural pattern helps on a given target task.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Can improve performance on label-scarce target tasks when the source representations are relevant to the target structure.
  • Can reduce training time and compute on the target task compared with training a GNN from scratch.
  • Self-supervised pre-training objectives, such as masked attribute prediction, allow the source encoder to be trained on unlabeled graphs.
  • Compatible with several GNN backbones (GIN, GAT, GraphSAGE, GCN) and with graphs of different types, provided the feature schemas can be aligned.

Applications

  • Molecular property and toxicity prediction in drug discovery using pre-trained chemical GNNs.
  • Protein function prediction by transferring from large protein interaction graph datasets.
  • Citation network node classification with limited labeled papers.
  • Social network community detection with sparse target labels.
  • Knowledge graph completion and entity classification in low-resource domains.

How it works

How it works

1

A GNN (for example GIN, GAT, or GraphSAGE) is trained on a large labeled or self-supervised source graph dataset. Pre-training objectives may be node-level (such as predicting masked node attributes), edge-level (link prediction), or graph-level (property prediction), and each encourages the encoder to capture different structural signals.

2

The pre-trained backbone, meaning its message-passing layers and learned node embeddings, is extracted and loaded into the target pipeline. Its weights may encode structural regularities such as local neighbourhood patterns and connectivity motifs, which can be useful on target graphs that share similar structural properties.

3

The pre-trained encoder is connected to a new task-specific head, such as a classifier or regressor, suited to the target task. Only the head is initialised randomly; the encoder starts from its pre-trained weights. The target graphs must be preprocessed so that their node and edge features match the input schema expected by the source model.

4

Fine-tuning decides how much of the encoder changes. A practical procedure is: (1) initialise the task head randomly and train it with the encoder frozen (feature extraction) until validation performance stabilises; (2) unfreeze the upper message-passing layers and continue training with a learning rate lower than the one used to train the same model from scratch; (3) if validation performance keeps improving, optionally unfreeze further layers, and stop when it no longer does. Fewer trainable layers reduce the risk of overfitting on small target sets, while more unfrozen layers allow stronger adaptation at the risk of overwriting useful source knowledge. The schedule and the number of unfrozen layers should be selected on a validation set rather than fixed in advance.

5

The adapted GNN produces node-, edge-, or graph-level predictions on unseen target graphs. Evaluation follows standard supervised protocols, such as train/validation/test splits or cross-validation, with metrics suited to the target task (for example accuracy, ROC-AUC, or RMSE).

Common pitfalls

  • Pre-training on a source dataset from a structurally unrelated domain (for example, social graphs for a molecular task) without first checking domain similarity.
  • Fine-tuning with a learning rate that is too high, which can overwrite the useful pre-trained weights and erase the benefit of transfer.
  • Reporting results on the training data or on a validation set only, without a held-out test set; this is especially risky when the target dataset is small.
  • Reporting accuracy alone on an imbalanced target task, which can hide poor performance on the minority class.
  • Omitting a comparison with a GNN trained from scratch on the same target data, which is needed to confirm that transfer actually helps.
  • Leakage between pre-training and evaluation data: duplicated graphs, shared nodes, or near-identical structural scaffolds (for example, the same molecular scaffold) appearing in both the source pre-training set and the target test set can inflate measured transfer gains. Remove or group overlapping graphs before splitting, and report how the split was made.

Frequently asked questions

What pre-training strategy works best for GNNs?

Hu et al. (2020) study strategies for pre-training GNNs at the node and graph level. Which combination performs best, and on which benchmarks, should be taken from the paper itself. The right choice depends on whether unlabeled source graphs are plentiful and whether graph-level labels exist in the source domain.

How do I know if transfer learning will help on my target task?

Compare a GNN trained from scratch with the transfer-learned model on a held-out test set. If the source and target graphs are structurally similar (for example, both are molecular graphs), transfer is more likely to help. If the domains differ strongly, negative transfer may occur and a from-scratch baseline may perform as well or better.

Should I freeze or fine-tune the pre-trained GNN layers?

When labeled target data are very limited, freezing the encoder and training only the task head reduces the risk of overfitting. When more labels are available, partially unfreezing the upper layers with a small learning rate often gives a reasonable trade-off. The choice should be checked on a validation set rather than fixed in advance.

Can I use this approach without a pre-existing pre-trained GNN?

Yes. You can pre-train a GNN yourself on a large related graph dataset before fine-tuning, or use published pre-trained checkpoints where they are available. Self-supervised objectives such as masked node attribute prediction do not require labels in the source data.

What GNN architectures are compatible with this approach?

The approach is architecture-agnostic: GIN, GAT, GraphSAGE, and GCN can each serve as the pre-trained backbone. As general design considerations rather than established results, GAT's learned attention weights neighbour contributions, which may suit graphs where neighbours differ in relevance to the task, and GIN is often chosen for graph-level tasks. The choice should follow the graph type and the task level (node, edge, or graph) and be confirmed on a validation set.

Related methods

Sources

  1. Hu, W., Liu, B., Gomes, J., Zitnik, M., Liang, P., Pande, V., & Leskovec, J. (2020). Strategies for Pre-training Graph Neural Networks. In International Conference on Learning Representations (ICLR 2020).

    Open publication reference
  2. Pan, S. J., & Yang, Q. (2010). A survey on transfer learning. IEEE Transactions on Knowledge and Data Engineering, 22(10), 1345–1359.

    Open DOI reference