S TRATEGIES FOR P RE - TRAINING G RAPH N EURAL N ETWORKS
A BSTRACT
Many applications of machine learning require a model to make accurate predictions on test examples that are distributionally different from training ones, while task-speciﬁc labels are scarce during training.
An effective approach to this challenge is to pre-train a model on related tasks where data is abundant, and then ﬁne-tune it on a downstream task of interest.
While pre-training has been effective in many language and vision domains, it remains an open question how to effectively use pre-training on graph datasets.
In this paper, we develop a new strategy and self-supervised methods for pre-training Graph Neural Networks (GNNs).
The key to the success of our strategy is to pre-train an expressive GNN at the level of individual nodes as well as entire graphs so that the GNN can learn useful local and global representations simultaneously.
We systematically study pre-training on multiple graph classiﬁcation datasets.
We ﬁnd that naïve strategies, which pre-train GNNs at the level of either entire graphs or individual nodes, give limited improvement and can even lead to negative transfer on many downstream tasks.
In contrast, our strategy avoids negative transfer and improves generalization signiﬁcantly across downstream tasks, leading up to 9.4% absolute improvements in
ROC-AUC over non-pre-trained models and achieving state-of-the-art performance for molecular property prediction and protein function prediction.
I NTRODUCTION
Transfer learning refers to the setting where a model, initially trained on some tasks, is re-purposed on different but related tasks.
Deep transfer learning has been immensely successful in computer vision (Donahue et al., 2014;
Girshick et al., 2014; Zeiler & Fergus, 2014) and natural language processing (Devlin et al., 2019; Peters et al., 2018; Mikolov et al., 2013).
Despite being an effective approach to transfer learning, few studies have generalized pre-training to graph data.
Pre-training has the potential to provide an attractive solution to the following two fundamental challenges with learning on graph datasets (Pan & Yang, 2009;
Hendrycks et al., 2019):
First, task-speciﬁc labeled data can be extremely scarce.
This problem is exacerbated in important graph datasets from scientiﬁc domains, such as chemistry and biology, where data labeling ( e.g. , biological experiments in a wet laboratory) is resource- and time-intensive (Zitnik et al., 2018).
Second, graph data from real-world applications often contain out-of-distribution samples, meaning that graphs in the training set are structurally very different from graphs in the test set.
Out-of-distribution prediction is common in real-world graph datasets, for example, when one wants to predict chemical properties of a brand-new, just synthesized molecule, which is different from all molecules synthesized so far, and thereby different from all molecules in the training set.
However, pre-training on graph datasets remains a hard challenge.
Several key studies (Xu et al., 2017; Ching et al., 2018; Wang et al., 2019) have shown that successful transfer learning is not only a
[Figure]
Attributeprediction
AttributeMasking
SupervisedAttributePrediction
StructuralSimilarityPrediction Structureprediction
Context Prediction (b) Categorization of our pre-training methods
G r aph s pa c e
N ode s pa c e
[Figure]
matter of increasing the number of labeled pre-training datasets that are from the same domain as the downstream task.
Instead, it requires substantial domain expertise to carefully select examples and target labels that are correlated with the downstream task of interest.
Otherwise, the transfer of knowledge from related pre-training tasks to a new downstream task can harm generalization, which is known as negative transfer (Rosenstein et al., 2005) and signiﬁcantly limits the applicability and reliability of pre-trained models.
Present work.
Here, we focus on pre-training as an approach to transfer learning in Graph Neural
Networks (GNNs) (Kipf & Welling, 2017; Hamilton et al., 2017a;
Ying et al., 2018b; Xu et al., 2019; 2018) for graph-level property prediction.
Our work presents two key contributions.
(1) We conduct the ﬁrst systematic large-scale investigation of strategies for pre-training GNNs.
For that, we build two large new pre-training datasets, which we share with the community: a chemistry dataset with 2 million graphs and a biology dataset with 395K graphs.
We also show that large domain-speciﬁc datasets are crucial to investigate pre-training and that existing downstream benchmark datasets are too small to evaluate models in a statistically reliable way.
(2) We develop an effective pretraining strategy for GNNs and demonstrate its effectiveness and its ability for out-of-distribution generalization on hard transfer-learning problems.
In our systematic study, we show that pre-training GNNs does not always help.
Naïve pre-training strategies can lead to negative transfer on many downstream tasks.
Strikingly, a seemingly strong pre-training strategy ( i.e. , graph-level multi-task supervised pre-training using a state-of-the-art graph neural network architecture for graph-level prediction tasks) only gives marginal performance gains.
Furthermore, this strategy even leads to negative transfer on many downstream tasks (2 out ofmolecular datasets and 13 out of 40 protein prediction tasks).
We develop an effective strategy for pre-training GNNs.
The key idea is to use easily accessible node-level information and encourage GNNs to capture domain-speciﬁc knowledge about nodes and edges, in addition to graph-level knowledge.
This helps the GNN to learn useful representations at both global and local levels (Figure 1 (a.iii)), and is crucial to be able to generate graph-level representations (which are obtained by pooling node representations) that are robust and transferable to diverse downstream tasks (Figure 1).
Our strategy is in contrast to naïve strategies that either leverage only at graph-level properties (Figure 1 (a.ii)) or node-level properties (Figure 1 (a.i)).
Empirically, our pre-training strategy used together with the most expressive GNN architecture,
GIN (Xu et al., 2019), yields state-of-the-art results on benchmark datasets and avoids negative transfer across downstream tasks we tested.
It signiﬁcantly improves generalization performance across downstream tasks, yielding up to 9.4% higher average ROC-AUC than non-pre-trained GNNs, and up to 5.2% higher average ROC-AUC compared to GNNs with the extensive graph-level multitask supervised pre-training.
Furthermore, we ﬁnd that the most expressive architecture, GIN, beneﬁts more from pre-training compared to those with less expressive power ( e.g. , GCN (Kipf & Welling, 2017), GraphSAGE (Hamilton et al., 2017b) and GAT (Velickovic et al., 2018)), and that pre-training
GNNs leads to orders-of-magnitude faster training and convergence in the ﬁne-tuning stage.
P RELIMINARIES OF G RAPH N EURAL N ETWORKS
We ﬁrst formalize supervised learning of graphs and provide an overview of GNNs (Gilmer et al., 2017).
Then, we brieﬂy review methods for unsupervised graph representation learning.
Supervised learning of graphs.
Let G =
( V, E ) denote a graph with node attributes X v for v ∈ V and edge attributes e uv for ( u, v ) ∈ E .
Given a set of graphs { G 1 , ..., G N } and their labels { y 1 , ..., y
N }, the task of graph supervised learning is to learn a representation vector h G that helps predict the label of an entire graph G ,
y G
= g ( h G ) .
For example, in molecular property prediction, G is a molecular graph, where nodes represent atoms and edges represent chemical bonds, and the label to be predicted can be toxicity or enzyme binding.
Graph Neural Networks (GNNs) .
GNNs use the graph connectivity as well as node and edge features to learn a representation vector ( i.e. , embedding) h v for every node v ∈ G and a vector h G for the entire graph G .
Modern GNNs use a neighborhood aggregation approach, where representation of node v is iteratively updated by aggregating representations of v ’s neighboring nodes and edges (Gilmer et al., 2017).
After k iterations of aggregation, v ’s representation captures the structural information within its k -hop network neighborhood.
Formally, the k -th layer of a GNN is:
[Equation]
where h ( k ) v is the representation of node v at the k -th iteration/layer, e uv is the feature vector of edge between u and v , and N ( v ) is a set neighbors of v .
We initialize h (0) v = X v .
Graph representation learning.
To obtain the entire graph’s representation h G , the READOUT function pools node features from the ﬁnal iteration K ,
[Equation]
READOUT is a permutation-invariant function, such as averaging or a more sophisticated graph-level pooling function (Ying et al., 2018b; Zhang et al., 2018).
S TRATEGIES FOR PRE - TRAINING G RAPH N EURAL N ETWORKS
At the technical core of our pre-training strategy is the notion to pre-train a GNN both at the level of individual nodes as well as entire graphs.
This notion encourages the GNN to capture domain-speciﬁc semantics at both levels, as illustrated in Figure 1 (a.iii).
This is in contrast to straightforward but limited pre-training strategies that either only use pre-training to predict properties of entire graphs (Figure 1 (a.ii)) or only use pre-training to predict properties of individual nodes (Figure 1 (a.i)).
In the following, we ﬁrst describe our node-level pre-training approach (Section 3.1) and then graph-level pre-training approach (Section 3.2).
Finally, we describe the full pre-training strategy in
Section 3.3.
3. N ODE - LEVEL PRE - TRAINING
For node-level pre-training of GNNs, our approach is to use easily-accessible unlabeled data to capture domain-speciﬁc knowledge/regularities in the graph.
Here we propose two self-supervised methods, Context Prediction and Attribute Masking.
[Figure]
3.1. C ONTEXT P REDICTION : E XPLOITING DISTRIBUTION OF GRAPH STRUCTURE
In Context Prediction, we use subgraphs to predict their surrounding graph structures.
Our goal is to pre-train a GNN so that it maps nodes appearing in similar structural contexts to nearby embeddings (Rubenstein & Goodenough, 1965; Mikolov et al., 2013).
Neighborhood and context graphs.
For every node v , we deﬁne v ’s neighborhood and context graphs as follows.
K -hop neighborhood of v contains all nodes and edges that are at most K -hops away from v in the graph.
This is motivated by the fact that a K -layer GNN aggregates information across the K -th order neighborhood of v , and thus node embedding h ( K ) v depends on nodes that are at most K -hops away from v .
We deﬁne context graph of node v as graph structure that surrounds v ’s neighborhood.
The context graph is described by two hyperparameters, r 1 and r 2 , and it represents a subgraph that is between r 1 -hops and r 2 -hops away from v ( i.e. , it is a ring of width r 2 − r 1 ).
Examples of neighborhood and context graphs are shown in Figure 2 (a).
We require r 1 < K so that some nodes are shared between the neighborhood and the context graph, and we refer to those nodes as context anchor nodes .
These anchor nodes provide information about how the neighborhood and context graphs are connected with each other.
Encoding context into a ﬁxed vector using an auxiliary GNN.
Directly predicting the context graph is intractable due to the combinatorial nature of graphs.
This is different from natural language processing, where words come from a ﬁxed and ﬁnite vocabulary.
To enable context prediction, we encode context graphs as ﬁxed-length vectors .
To this end, we use an auxiliary GNN, which we refer to as the context GNN .
As depicted in Figure 2 (a), we ﬁrst apply the context GNN (denoted as GNN (cid:48) in Figure 2 (a)) to obtain node embeddings in the context graph.
We then average embeddings of context anchor nodes to obtain a ﬁxed-length context embedding.
For node v in graph G , we denote its corresponding context embedding as c Gv .
Learning via negative sampling.
We then use negative sampling (Mikolov et al., 2013;
Ying et al., 2018a) to jointly learn the main GNN and the context GNN.
The main GNN encodes neighborhoods to obtain node embeddings.
The context GNN encodes context graphs to obtain context embeddings.
In particular, the learning objective of Context Prediction is a binary classiﬁcation of whether a particular neighborhood and a particular context graph belong to the same node:
[Equation]
where σ ( · ) is the sigmoid function, and 1 ( · ) is the indicator function.
We either let v (cid:48)
= v and
G (cid:48)
=
G ( i.e. , a positive neighborhood-context pair), or we randomly sample v (cid:48) from a randomly chosen graph G (cid:48) ( i.e. , a negative neighborhood-context pair).
We use a negative sampling ratio of 1 (one negative pair per one positive pair), and use the negative log likelihood as the loss function.
After pre-training, the main GNN is retained as our pre-trained model
3.1. A TTRIBUTE M ASKING : E XPLOITING DISTRIBUTION OF GRAPH ATTRIBUTES
In Attribute Masking, we aim to capture domain knowledge by learning the regularities of the node/edge attributes distributed over graph structure.
Masking node and edges attributes.
Attribute Masking pre-training works as follows: We mask node/edge attributes and then we let GNNs predict those attributes (Devlin et al., 2019) based on neighboring structure.
Figure 2 (b) illustrates our proposed method when applied to a molecular graph.
Speciﬁcally, We randomly mask input node/edge attributes, for example atom types in molecular graphs, by replacing them with special masked indicators.
We then apply GNNs to obtain the corresponding node/edge embeddings (edge embeddings can be obtained as a sum of node embeddings of the edge’s end nodes).
Finally, a linear model is applied on top of embeddings to predict a masked node/edge attribute.
Different from Devlin et al.
(2019) that operates on sentences and applies message passing over the fully-connected graph of tokens, we operate on non-fullyconnected graphs and aim to capture the regularities of node/edge attributes distributed over different graph structures.
Furthermore, we allow masking edge attributes, going beyond masking node attributes.
Our node and edge attribute masking method is especially beneﬁcial for richly-annotated graphs from scientiﬁc domains.
For example, (1) in molecular graphs, the node attributes correspond to atom types, and capturing how they are distributed over the graphs enables GNNs to learn simple chemistry rules such as valency, as well as potentially more complex chemistry phenomenon such as the electronic or steric properties of functional groups.
Similarly, (2) in protein-protein interaction (PPI) graphs, the edge attributes correspond to different kinds of interactions between a pair of proteins.
Capturing how these attributes distribute across the PPI graphs enables GNNs to learn how different interactions relate and correlate with each other.
3. G RAPH - LEVEL P RE - TRAINING
We aim to pre-train GNNs to generate useful graph embeddings composed of the meaningful node embeddings obtained by methods in Section 3.1.
Our goal is to ensure both node and graph embeddings are of high-quality so that graph embeddings are robust and transferable across downstream tasks, as illustrated in Figure 1 (a.iii).
Additionally, there are two options for graph-level pre-training, as shown in Figure 1 (b): making predictions about domain-speciﬁc attributes of entire graphs ( e.g. , supervised labels), or making predictions about graph structure.
3.2. S UPERVISED G RAPH -L EVEL P ROPERTY P REDICTION
As the graph-level representation h G is directly used for ﬁne-tuning on downstream prediction tasks, it is desirable to directly encode domain-speciﬁc information into h G .
We inject graph-level domain-speciﬁc knowledge into our pretrained embeddings by deﬁning supervised graph-level prediction tasks.
In particular, we consider a practical method to pre-train graph representations: graph-level multi-task supervised pre-training to jointly predict a diverse set of supervised labels of individual graphs.
For example, in molecular property prediction, we can pre-train GNNs to predict essentially all the properties of molecules that have been experimentally measured so far.
In protein function prediction, where the goal is predict whether a given protein has a given functionality, we can pre-train GNNs to predict the existence of diverse protein functions that have been validated so far.
In our experiments in Section 5, we prepare a diverse set of supervised tasks (up to 5000 tasks) to simulate these practical scenarios.
Further details of the supervised tasks and datasets are described in Section 5.1.
To jointly predict many graph properties, where each property corresponds to a binary classiﬁcation task, we apply linear classiﬁers on top of graph representations.
Importantly, naïvely performing the extensive multi-task graph-level pre-training alone can fail to give transferable graph-level representations, as empirically demonstrated in Section 5.
This is because some supervised pre-training tasks might be unrelated to the downstream task of interest and can even hurt the downstream performance (negative transfer).
One solution would be to select “truly-relevant” supervised pre-training tasks and pre-train GNNs only on those tasks.
However, such a solution is extremely costly since selecting the relevant tasks requires signiﬁcant domain expertise and pre-training needs to be performed separately for different downstream tasks.
To alleviate this issue, our key insight is that the multi-task supervised pre-training only provides graph-level supervision; thus, local node embeddings from which the graph-level embeddings are created may not be meaningful, as illustrated in Figure 1 (a.ii).
Such non-useful node embeddings can exacerbate the problem of negative transfer because many different pre-training tasks can more easily interfere with each other in the node embedding space.
Motivated by this, our pre-training strategy is to ﬁrst regularize GNNs at the level of individual nodes via node-level pre-training methods described in Section 3.1, before performing graph-level pre-training.
As we demonstrate empirically, the combined strategy produces much more transferable graph representations and robustly improves downstream performance without expert selection of supervised pre-training tasks.
3.2. S TRUCTURAL S IMILARITY P REDICTION
A second approach is to deﬁne a graph-level predictive task where the goal would be to model the structural similarity of two graphs.
Examples of such tasks include modeling the graph edit distance (Bai et al., 2019) or predicting graph structure similarity (Navarin et al., 2018).
However, ﬁnding the ground truth graph distance values is a difﬁcult problem, and in large datasets there is a quadratic number of graph pairs to consider.
Therefore, while this type of pre-training is also very natural, it is beyond the scope of this paper and we leave its investigation for future work.
3. O VERVIEW : P RE - TRAINING GNN S AND F INE - TUNING FOR D OWNSTREAM T ASKS
Altogether, our pre-training strategy is to ﬁrst perform node-level self-supervised pre-training (Section 3.1) and then graph-level multi-task supervised pre-training (Section 3.2).
When the GNN pre-training is ﬁnished, we ﬁne-tune the pre-trained GNN model on downstream tasks.
Speciﬁcally, we add linear classiﬁers on top of graph-level representations to predict downstream graph labels.
The full model, i.e. , the pre-trained GNN and downstream linear classiﬁers, is subsequently ﬁne-tuned in an end-to-end manner.
Time-complexity analysis is provided in Appendix F, where we show that our pre-training methods incur little computational overhead to forward computation in GNNs.
F URTHER R ELATED W ORK
There is rich literature on unsupervised representation learning of individual nodes within graphs, which broadly falls into two categories.
In the ﬁrst category are methods that use local random walk-based objectives (Grover & Leskovec, 2016; Perozzi et al., 2014; Tang et al., 2015) and methods that reconstruct a graph’s adjacency matrix, e.g. , by predicting edge existence (Hamilton et al., 2017a;
Kipf & Welling, 2016).
In the second category are methods, such as Deep Graph Infomax (Veliˇckovi´c et al., 2019), that train a node encoder that maximizes mutual information between local node representations and a pooled global graph representation.
All these methods encourage nearby nodes to have similar embeddings and were originally proposed and evaluated for node classiﬁcation and link prediction.
This, however, can be sub-optimal for graph-level prediction tasks, where capturing structural similarity of local neighborhoods is often more important than capturing the positional information of nodes within a graph (You et al., 2019; Rogers & Hahn, 2010; Yang et al., 2014).
Our approach thus considers both the node-level as well as graph-level pretraining tasks and as we show in our experiments, it is essential to use both types of tasks in order for pretrained models to achieve good performance.
A number of recent works have also explored how node embeddings generalize across tasks (Jaeger et al., 2018;
Zhou et al., 2018; Chakravarti, 2018; Narayanan et al., 2016).
However, all of these methods use distinct node embeddings for different substructures and do not share any parameters.
Thus, they are inherently transductive, cannot transfer between datasets, cannot be ﬁne-tuned in an end-to-end manner, and cannot capture large and diverse neighborhoods/contexts due to data sparsity.
Our approach addresses all these challenges by developing pre-training methods for GNNs that use shared parameters to encode the the graph-level as well as node-level dependencies and structures.
E XPERIMENTS 5. D ATASETS
We consider two domains; molecular property prediction in chemistry and protein function prediction in biology.
We release the new datasets at: http://snap.stanford.edu/gnn-pretrain .
Pre-training datasets.
For the chemistry domain, we use 2 million unlabeled molecules sampled from the ZINC15 database (Sterling & Irwin, 2015) for node-level self-supervised pre-training.
For graph-level multi-task supervised pre-training, we use a preprocessed ChEMBL dataset (Mayr et al., 2018;
Gaulton et al., 2011), containing 456K molecules with 1310 kinds of diverse and extensive biochemical assays.
For the biology domain, we use 395K unlabeled protein ego-networks derived from PPI networks of 50 species ( e.g. , humans, yeast, zebra ﬁsh) for node-level self-supervised pretraining.
For graph-level multi-task supervised pre-training, we use 88K labeled protein ego-networks to jointly predict 5000 coarse-grained biological functions ( e.g. , cell apoptosis, cell proliferation).
Downstream classiﬁcation datasets.
For the chemistry domain, we considered classical graph classiﬁcation benchmarks (MUTAG, PTC molecule datasets) (Kersting et al., 2016;
Xu et al., 2019) as our downstream tasks, but found that they are too small (188 and 344 examples for MUTAG and PTC) to evaluate different methods in a statistically meaningful way (see Appendix B for the results and discussion).
Because of this, as our downstream tasks, we decided to use 8 larger binary classiﬁcation datasets contained in MoleculeNet (Wu et al., 2018), a recently-curated benchmark for molecular property prediction.
The dataset statistics are summarized in Table 1.
For the biology domain, we compose our PPI networks from Zitnik et al.
(2019), consisting of 88K proteins fromdifferent species, where the subgraphs centered at a protein of interest ( i.e. , ego-networks) are used to predict their biological functions.
Our downstream task is to predict 40 ﬁne-grained biological functions 1 that correspond to 40 binary classiﬁcation tasks.
In contrast to existing PPI datasets (Hamilton et al., 2017a), our dataset is larger and spans multiple species ( i.e. , not only humans), which makes it a suitable benchmark for evaluating out-of-distribution prediction.
Additional details about datasets and features of molecule/PPI graphs are in Appendices C and D.
Dataset splitting.
In many applications, conventional random split is overly optimistic and does not simulate the real-world use case, where test graphs can be structurally different from training graphs (Wu et al., 2018; Zitnik et al., 2019).
To reﬂect the actual use case, we split the downstream data in the following ways to evaluate the models’ out-of-distribution generalization .
In the chemistry domain, we use scaffold split (Ramsundar et al., 2019), where we split molecules according to their scaffold (molecular substructure).
In the biology domain, we use species split , where we predict functions of proteins from new species.
Details are in Appendix E. Furthermore, to prevent data leakage, all test graphs used for performance evaluation are removed from the graph-level supervised pre-training datasets.
5. E XPERIMENTAL S ETUP
We thoroughly compare our pre-training strategy with two naïve baseline strategies: (i) extensive supervised multi-task pre-training on relevant graph-level tasks, and (ii) node-level self-supervised pre-training.
GNN architectures.
We mainly study Graph Isomorphism Networks (GINs)
(Xu et al., 2019), the most expressive and state-of-the-art GNN architecture for graph-level prediction tasks.
We also experimented with other popular architectures that are less expressive: GCN (Kipf & Welling, 2016),
GAT (Veliˇckovi´c et al., 2019), and GraphSAGE (with mean neighborhood aggregation) (Hamilton et al., 2017b).
We select the following hyper-parameters that performed well across all downstream tasks in the validation sets: 300 dimensional hidden units, 5 GNN layers ( K = 5 ), and average pooling for the READOUT function.
Additional details can be found in
Appendix A.
Pre-training.
For Context Prediction illustrated in Figure 2 (a), on molecular graphs, we deﬁne context graphs by setting inner radius r 1 = 4 .
On PPI networks whose diameters are often smaller than 5, we use r 1 = 1 , which works well empirically despite the large overlap between the neighborhood and context subgraphs.
For both molecular and PPI graphs, we let outer radius r
=
r 1 + 3 , and
[Table]
[Table] [Table]
use a 3-layer GNN to encode the context structure.
For Attribute Masking shown in Figure 2 (b), we randomly mask 15% of node (for molecular graphs) or edge attributes (for PPI networks) for prediction.
As baselines for node-level self-supervised pre-training, we adopt the original Edge
Prediction (denoted by EdgePred) (Hamilton et al., 2017a) and Deep Graph Infomax (denoted by
Infomax) (Veliˇckovi´c et al., 2019) implementations.
Further details are provided in Appendix G.
5. R ESULTS
We report results for molecular property prediction and protein function prediction in Tables 2 andand Figure 3.
Our systematic study suggests the following trends:
Observation (1): Table 2 shows that the most expressive GNN architecture (GIN), when pre-trained, achieves the best performance across domains and datasets.
Compared with gains of pre-training achieved by GIN architecture, gains of pre-training using less expressive GNNs (GCN, GraphSAGE, and GAT) are smaller and can sometimes even be negative (Table 2).
This ﬁnding conﬁrms previous observations ( e.g. , Erhan et al.
that using an expressive model is crucial to fully utilize pre-training, and that pre-training can even hurt performance when used on models with limited expressive power, such as GCN, GraphSAGE, and GAT.
Observation (2): As seen from the shaded cells of Table 1 and highlighted region in the middle panel of Figure 3, the strong baseline strategy that performs extensive graph-level multi-task supervised pre-training of GNNs gives surprisingly limited performance gain and yields negative transfer on many downstream tasks (2 out of 8 datasets in molecular prediction, and 13 out of 40 tasks in protein function prediction).
Observation (3): From the upper half of Table 1 and the left panel of Figure 3, we see that another baseline strategy, which only performs node-level self-supervised pre-training, also gives limited performance improvement and is comparable to the graph-level multi-task supervised pre-training baseline.
Observation (4): From the lower half of Table 1 and the right panel of Figure 3, we see that our pre-training strategy of combining graph-level multi-task supervised and node-level self-supervised pre-training avoids negative transfer across downstream datasets and achieves best performance.
Observation (5): Furthermore, from Table 1 and the left panel of Figure 3, we see that our strategy gives signiﬁcantly better predictive performance than the two baseline pre-training strategies as well as non-pre-trained models, achieving state-of-the-art performance.
Speciﬁcally, in the chemistry datasets, we see from Table 1 that our Context Prediction + Graph-level multi-task supervised pre-training strategy gives the most promising performance, leading to an increase in average ROC-AUC of 7.2% over non-pre-trained baseline and 4.2% over graph-level multi-task supervised pre-trained baseline.
On the HIV dataset, where a number of recent works (Wu et al., 2018; Li et al., 2017; Ishiguro et al., 2019) have reported performance on the same scaffold split and using the same protocol, our best pre-trained model (ContextPred + Supervised) achieves state-ofthe-art performance.
In particular, we achieved a ROC-AUC score of 79.9%, while best-performing graph models in Wu et al.
, Li et al.
(2017), and Ishiguro et al.
(2019) had ROC-AUC scores of 76.3%, 77.6%, and 76.2%, respectively.
Also, in the biology datasets, which we have built in this work, we see from the left panel of Figurethat our Attribute Masking + Graph-level multi-task supervised pre-training strategy achieves the best predictive performance compared to other baseline strategies across almost all 40 downstream prediction tasks (the right panel of Figure 3).
On average, our strategy improves ROC-AUC by 9.4% over non-pre-trained baseline and 5.2% over graph-level multi-task supervised pre-trained baseline, again achieving state-of-the-art performance.
Observation (6): In the chemistry domain, we also report performance on classic benchmarks (MUTAG, PTC molecule datasets) in
Appendix B.
However, as mentioned in Section 5.1, the extremely small dataset sizes make these benchmarks unsuitable to compare different methods in a statistically reliable way.
Observation (7): Beyond predictive performance improvement, Figure 4 shows that our pre-trained models achieve orders-of-magnitude faster training and validation convergence than non-pre-trained models.
For example, on the MUV dataset, it took 1 hour for the non-pre-trained GNN to get 74.9% validation ROC-AUC, while it took only 5 minutes for our pre-trained GNN to get 85.3% validation
ROC-AUC.
The same trend holds across the downstream datasets we used, as shown in Figure 5 in
Appendix I. We emphasize that pre-training is a one-time-effort.
Once the model is pre-trained, it can be used for any number of downstream tasks to improve performance with little training time.
As a ﬁnal remark, in our preliminary experiments, we performed the Attribute Masking and Context
Prediction simultaneously to pre-train GNNs.
That approach did not improve performance in our experiments.
We leave a thorough analysis of the approach for future work.
C ONCLUSIONS AND F UTURE W ORK
We developed a novel strategy for pre-training GNNs.
Crucial to the success of our strategy is to consider both node-level and graph-level pre-training in combination with an expressive GNN.
This ensures that node embeddings capture local neighborhood semantics that are pooled together to obtain meaningful graph-level representations, which, in turn, are used for downstream tasks.
Experiments on multiple datasets, diverse downstream tasks and different GNN architectures show that the new pre-training strategy achieves consistently better out-of-distribution generalization than non-pre-trained models.
Our work makes an important step toward transfer learning on graphs and addresses the issue of negative transfer observed in prior studies.
There are many interesting avenues for future work.
For example, further increasing generalization by improving GNN architectures as well as pre-training and ﬁne-tuning approaches, is a fruitful direction.
Investigating what pre-trained models have learned would also be useful to aid scientiﬁc discovery (Tshitoyan et al., 2019).
Finally, it would be interesting
[Figure] [Figure]
to apply our methods to other domains, e.g. , physics, material science, and structural biology, where many problems are deﬁned over graphs representing interactions of e.g. , atoms, particles, and amino acids.
A CKNOWLEDGMENTS
We thank Camilo Ruiz, Rex Ying, Zhenqin Wu, Shantao Li, Srijan Kumar, Hongwei Wang, and
Robin Jia for their helpful discussion.
W.H is supported by Funai Overseas Scholarship and Masason
Foundation Fellowship.
J.L is a Chan Zuckerberg Biohub investigator.
We gratefully acknowledge the support of DARPA under Nos.
FA865018C7880 (ASED), N660011924033 (MCS); ARO under
Nos.
W911NF-16-1-0342 (MURI), W911NF-16-1-0171 (DURIP); NSF under Nos.
OAC- (CINES), OAC-1934578 (HDR); Stanford Data Science Initiative, Wu Tsai Neurosciences Institute,
Chan Zuckerberg Biohub, JD.com, Amazon, Boeing, Docomo, Huawei, Hitachi, Observe, Siemens,
UST Global.
The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright notation thereon.
Any opinions, ﬁndings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reﬂect the views, policies, or endorsements, either expressed or implied, of DARPA, NIH, ARO, or the U.S.
Government.
The Pande Group acknowledges the generous support of Dr. Anders G. Frøseth and Mr. Christian
Sundt for our work on machine learning.
The Pande Group is broadly supported by grants from the
NIH (R01 GM062868 and U19 AI109662) as well as gift funds and contributions from Folding@home donors.
V.S.P is a consultant & SAB member of Schrodinger, LLC and Globavir, sits on the Board of
Directors of Apeel Sciences, Asimov, BioAge Labs, Ciitizen, Devoted Health, Freenome, Insitro,
Omada Health, PatientPing, and is a General Partner at Andreessen Horowitz.
A D ETAILS OF GNN ARCHITECTURES
Here we describe GNN architectures used in our molecular property and protein function prediction experiments.
For both domains we use the GIN architecture (Xu et al., 2019) with some minor modiﬁcations to include edge features, as well as center node information in the protein ego-networks.
As our primary goal is to systematically compare our pre-training strategy to the strong baseline strategies, we ﬁx all of these hyper-parameters in our experiments and focus on relative improvement directly caused by the difference in pre-training strategies.
Molecular property prediction.
In molecular property prediction, the raw node features and edge features are both 2-dimensional categorical vectors (see Appendix C for details), denoted as ( i v, 1 , i v, 2 ) and ( j e, 1 , j e, 2 ) for node v and edge e , respectively.
Note that we also introduce unique categories to indicate masked node/edges as well as self-loop edges.
As input features to GNNs, we ﬁrst embed the categorical vectors by
[Equation]
where EmbNode 1 ( · ) , EmbNode 2 ( · ) , EmbEdge ( k ) 1 ( · ) , and EmbNode ( k ) 1 ( · ) represent embedding operations that map integer indices to d -dimensional real vectors, and k represents the index of GNN layers.
At the k -th layer, GNNs update node representations by
[Equation]
where N ( v ) is a set of nodes adjacent to v , and e = ( v, v ) represents the self-loop edge.
Note that for the ﬁnal layer, i.e., k = K , we removed the ReLU from Eq.
(A.1) so that h ( k ) v can take negative values.
This is crucial for pre-training methods based on the dot product, e.g. , Context Prediction and
Edge Prediction, as otherwise, the dot product between two vectors would be always positive.
The graph-level representation h G is obtained by averaging the node embeddings at the ﬁnal layer, i.e.,
[Equation]
The label prediction is made by a linear model on top of h G .
In our experiments, we set the embedding dimension d to 300.
For MLPs in Eq.
(A.1), we use the
ReLU activation with 600 hidden units.
We apply batch normalization (Ioffe & Szegedy, 2015) right before the ReLU in Eq.
(A.1) and apply dropout (Srivastava et al., 2014) to h ( k ) v at all the layers except the input layer.
Protein function prediction.
The GNN architecture used for protein function prediction is similar to the one used for molecular property prediction except for a few differences.
First, the raw input node features are uniform (denoted as X here) and second, the raw input edge features are binary vectors (see Appendix D for the detail), which we denote as c e ∈ { 0 , 1 } d 0 .
As input features to GNNs, we ﬁrst embed the raw features by
[Equation]
where W ∈ R d × d 0 and b ∈ R d are learnable parameters, and h (0) v , h ( k ) e ∈ R d .
At each layer, GNNs update node representations by
[Equation]
h
[Equation]
k
[Equation]
u ,
[Equation] [Equation]
v
[Equation]
v
[Equation]
h
[Equation]
e   
 
 , (A.3)
[Table]
where CONCAT( · , · ) takes two vectors as input and concatenates them.
Since the downstream task is ego-network classiﬁcation
[Table]
we use the embedding of the center node v center together with the embedding of the entire ego-network.
More speciﬁcally, we obtain graph-level representation h G by
[Equation]
Other GNN architectures.
For GCN, GraphSAGE, and GAT, we adopt the implementation in the
Pytorch Geometric library (Fey & Lenssen, 2019), where we set the number of GAT attention heads to be 2.
The dimensionality of node embeddings as well as the number of GNN layers are kept the same as GIN.
These models do not originally handle edge features.
We incorporate edge features into these models similarly to how we do it for the GIN; we add edge embeddings into node embeddings, and perform the GNN message-passing on the obtained node embeddings.
B E XPERIMENTS ON CLASSIC GRAPH CLASSIFICATION BENCHMARKS
In Table 3 we report our experiments on the commonly-used classic graph classiﬁcation benchmarks (Kersting et al., 2016).
Among the datasets Xu et al.
(2019) used, MUTAG, PTC, and NCI1 are molecule datasets for binary classiﬁcation.
Out of these three, we excluded the NCI1 dataset, because it misses edge information ( i.e. , bond type) and therefore, we cannot recover the original molecule information, which is necessary to construct our input representations described in Appendix C.
For fair comparison, we used exactly the same evaluation protocol as Xu et al.
(2019), i.e. , report 10-fold cross-validation accuracy.
All the hyper-parameters in our experiments are kept the same in the main experiments except that we additionally tuned dropout rate from { 0 , 0 . 2 , 0 . 5 } and the batch size from { 8 , 64 } at the ﬁne-tuning stage.
While the pre-trained GNNs (especially those with Context Prediction) give competent performance, all the accuracies (including all the previous methods) are within a standard deviation with each other, making it hard to reliably compare different methods.
As Xu et al.
(2019) has pointed out, this is due to the extremely small dataset size; a validation set at each fold only contains around 19 tomolecules for MUTAG and PTC, respectively.
Given these results, we argue that it is necessary to use larger datasets to make reliable comparison, so we mainly focus on MoleculeNet (Wu et al
C D ETAILS OF MOLECULAR DATASETS
Input graph representation.
For simplicity, we use a minimal set of node and bond features that unambiguously describe the two-dimensional structure of molecules.
We use RDKit (Landrum et al., 2006) to obtain these features.
• Node features: – Atom number: [1, 118] – Chirality tag: {unspeciﬁed, tetrahedral cw, tetrahedral ccw, other} • Edge features: – Bond type: {single, double, triple, aromatic} – Bond direction: {–, endupright, enddownright}
Downstream task datasets.
8 binary graph classiﬁcation datasets from Moleculenet (Wu et al., 2018) are used to evaluate model performance.
• BBBP.
Blood-brain barrier penetration (membrane permeability) (
Martins
et al., 2012).
• Tox21.
Toxicity data on 12 biological targets, including nuclear receptors and stress response pathways (Tox21).
• ToxCast.
Toxicology measurements based on over 600 in vitro high-throughput screenings (Richard et al., 2016).
• SIDER.
Database of marketed drugs and adverse drug reactions (ADR), grouped intosystem organ classes (Kuhn et al., 2015).
• ClinTox.
Qualitative data classifying drugs approved by the FDA and those that have failed clinical trials for toxicity reasons (Novick et al., 2013; AACT).
• MUV.
Subset of PubChem BioAssay by applying a reﬁned nearest neighbor analysis, designed for validation of virtual screening techniques (Gardiner et al., 2011).
• HIV.
Experimentally measured abilities to inhibit HIV replication ( ? ).
• BACE.
Qualitative binding results for a set of inhibitors of human β -secretase 1 (Subramanian et al., 2016).
D D ETAILS OF PROTEIN DATASETS
Input graph representation.
The protein subgraphs only have edge features.
• Edge features: – Neighbourhood: {True, False} – Fusion: {True, False} – Co-occurrence: {True, False} – Co-expression: {True, False} – Experiment: {True, False} – Database: {True, False} – Text: {True, False}
These edge features indicate whether a particular type of relationship exists between a pair of proteins:
• Neighbourhood: if a pair of genes are consistently observed in each other’s
genome neighbourhood • Fusion: if a pair of proteins have their respective orthologs fused into a single protein-coding gene in another organism •
Co-occurrence: if a pair of proteins tend to be observed either as present or absent in the same subset of organisms • Co-expression: if a pair of proteins share similar expression patterns
• Experiment: if a pair of proteins are experimentally observed to physically interact with each other • Database: if a pair of proteins belong to the same pathway, based on assessments by a human curator • Text mining: if a pair of proteins are mentioned together in PubMed abstracts Datasets
A
dataset containing protein subgraphs
from
50 species
is
used (Zitnik et al., 2019).
The original PPI networks do not have node attributes, but contain edge attributes that correspond to the degree of conﬁdence for 7 different types of protein-protein relationships.
The edge weights range from 0, which indicates no evidence for the speciﬁc relationship, to 1000, which indicates the highest conﬁdence.
The weighted edges of the PPI networks are thresholded such that the distribution of edge types across the 50 PPI networks are uniform.
Then, for every node in the PPI networks, subgraphs centered on each node were generated by: (1) performing a breadth ﬁrst search to select the subgraph nodes, with a search depth limit of 2 and a maximum number of 10 neighbors randomly expanded per node, (2) including the selected subgraph nodes and all the edges between those nodes to form the resulting subgraph.
The entire dataset contains 394,925 protein subgraphs derived from 50 species.
Out of thesespecies, 8 species (arabidopsis, celegans, ecoli, ﬂy, human, mouse, yeast, zebraﬁsh) have proteins with
GO protein annotations.
The dataset contains 88,000 protein subgraphs from these 8 species, of which 57,448 proteins have at least one positive coarse-grained GO protein annotation and 22,876 proteins have at least one positive ﬁne-grained GO protein annotation.
For the self-supervised pre-training dataset, we use all 394,925 protein subgraphs.
We deﬁne ﬁne-grained protein functions as Gene Ontology (GO) annotations that are leaves in the
GO hierarchy, and deﬁne coarse-grained protein functions as GO annotations that are the immediate parents of leaves (Ashburner et al., 2000; Consortium, 2018).
For example, a ﬁne-grained protein function is “Factor XII activation”, while a coarse-grained function is “positive regulation of protein”.
The former is a speciﬁc type of the latter, and is much harder to derive experimentally.
The GO hierarchy information is obtained using GOATOOLS (Klopfenstein et al., 2018).
The supervised pre-training dataset and the downstream evaluation dataset are derived from the 8 labeled species, as described in
Appendix E.
The 40-th most common ﬁne-grained protein label only has 121 positively annotated proteins, while the 40-th most common coarse-grained protein label has 9386 positively annotated proteins.
This illustrates the extreme label scarcity of our downstream tasks.
For supervised pre-training, we combine the train, validation, and prior sets described previously, with the 5,000 most common coarse-grained protein function annotations as binary labels.
For our downstream task, we predict the 40 most common ﬁne-grained protein function annotations, to ensure that each protein function has at least 10 positive labels in our test set.
E D ETAILS OF DATASET SPLITTING
For molecular prediction tasks, following Ramsundar et al.
(2019), we cluster molecules by scaffold (molecular graph substructure) (Bemis & Murcko, 1996), and recombine the clusters by placing the most common scaffolds in the training set, producing validation and test sets that contain structurally different molecules.
Prior work has shown that this scaffold split provides a more realistic estimate of model performance in prospective evaluation compared to random split (Chen et al., 2012; Sheridan, 2013).
The split for train/validation/test sets is 80%:10%:10%.
In the PPI network, species split simulates a scenario where we have only high-level coarse-grained knowledge on a subset of proteins (prior set) in a species of interest (human in our experiments), and want to predict ﬁne-grained biological functions for the rest of the proteins in that species (test set).
For species split, we use 50% of the protein subgraphs from human as test set, and 50% as a prior set containing only coarse-grained protein annotations.
The protein subgraphs from 7 other labelled species (arabidopsis, celegans, ecoli, ﬂy, mouse, yeast, zebraﬁsh) are used as train and validation sets, which are split 85% : 15%.
The effective split ratio for the train/validation/prior/test sets is 69% : 12% : 9.5% : 9.5%.
F T IME COMPLEXITY OF PRE - TRAINING
Here we analyze the time complexity for processing graphs in Attribute Masking and Context
Prediction.
First, the time complexity for Attribute Masking is linear with respect to the number of edges/nodes as it only involves sampling nodes/edges to be masked.
Second, the time complexity for Context Prediction is again linear with respect to the number of edges/nodes, because it involves sampling a center node per graph plus extracting K -hop neighborhood and context graph.
Extracting the neighborhood/context graphs is performed by the breadth-ﬁrst search, which takes at most linear time with respect to the number of edges in the graph.
In summary, the time complexity for both of our pre-training methods are at most linear with respect to the number of edges, which is as efﬁcient as message-passing computation in GNNs, and thus, is as efﬁcient as the ordinary supervised learning using GNNs.
Also, there is almost no memory overhead as we transform data (e.g., mask input node/edge features, sample the context graphs) on-the-ﬂy.
G F URTHER DETAILS OF THE EXPERIMENTAL SETUP
Optimization.
All models are trained with Adam optimizer (Kingma & Ba, 2015) with a learning rate of 0.001.
We use Pytorch (Paszke et al., 2017) and Pytorch Geometric (Fey & Lenssen, 2019) for all of our implementation.
We run all pre-training methods for 100 epochs.
For self-supervised pre-training, we use a batch size of 256, while for supervised pre-training, we use a batch size ofwith dropout rate of 20%.
Fine-tuning.
After pre-training, we follow the procedure in Section 3.3 to ﬁne-tune the models on the training sets of the downstream datasets.
We use a batch size of 32 and dropout rate of 50%.
Datasets with multiple prediction tasks are ﬁt jointly.
On the molecular property prediction datasets, we train models for 100 epochs, while on the protein function prediction dataset (with the 40 binary prediction tasks), we train models for 50 epochs.
Evaluation.
We evaluate test performance on downstream tasks using ROC-AUC (Bradley, 1997) with the validation early stopping protocol, i.e. , test ROC-AUC at the best validation epoch is reported.
For datasets with multiple prediction tasks, we take the average ROC-AUC across all their tasks.
The downstream experiments are run with 10 random seeds, and we report mean ROC-AUC and standard deviation.
Computation time for pre-training.
The computation time for the two stages of our pre-training is reported below.
Chemistry: Self-supervised pre-training takes about 24 hours, while supervised pre-training takes about 11 hours.
Biology: Self-supervised pre-training takes about 3.8 hours, while supervised pre-training takes about 2.5 hours.
H C OMPARISON OF PRE - TRAINING WITH DIFFERENT GNN ARCHITECTURES
Table 4 shows the detailed comparison of different GNN architectures on the chemistry datasets.
We see that the most expressive GIN architectures beneﬁt most from pre-training compared to the other less expressive models.
I A DDITIONAL T RAINING AND VALIDATION CURVES
Training and validation curves.
In Figure 5, we plot training and validation curves for all the datasets used in the molecular property prediction experiments.
Additional scatter plot comparisons of ROC-AUCs.
In Figure 6, we compare our Context Prediction + graph-level supervised pre-training with a non-pre-trained model and a graph-level supervised pre-trained model.
We see from the left plot that the combined strategy again completely avoids negative transfer across all the 40 downstream tasks.
Furthermore, we see from the right plot that additionally adding our node-level Context Prediction pre-training almost always improves ROC-AUC scores of supervised pre-trained models across the 40 downstream tasks .
[Table]
[Figure]
[Table]
[Figure]
C on t e x t
P r ed +
G r aph - l e v e l s upe r v
i s ed
p r et r a i n i ng
No pre-training
Graph-level supervised pre-training only
Context Prediction helps avoiding negative transfer across tasks .
Context Prediction improves generalization over pure graph-level pretraining across tasks .