Graph Self-supervised Learning with Accurate Discrepancy Learning
Abstract
Self-supervised learning of graph neural networks (GNNs) aims to learn an accurate representation of the graphs in an unsupervised manner, to obtain transferable representations of them for diverse downstream tasks.
Predictive learning and contrastive learning are the two most prevalent approaches for graph self-supervised learning.
However, they have their own drawbacks.
While the predictive learning methods can learn the contextual relationships between neighboring nodes and edges, they cannot learn global graph-level similarities.
Contrastive learning, while it can learn global graph-level similarities, its objective to maximize the similarity between two differently perturbed graphs may result in representations that cannot discriminate two similar graphs with different properties.
To tackle such limitations, we propose a framework that aims to learn the exact discrepancy between the original and the perturbed graphs, coined as Discrepancy-based Self-supervised
LeArning (D-SLA).
Specifically, we create multiple perturbations of the given graph with varying degrees of similarity, and train the model to predict whether each graph is the original graph or the perturbed one.
Moreover, we further aim to accurately capture the amount of discrepancy for each perturbed graph using the graph edit distance.
We validate our D-SLA on various graph-related downstream tasks, including molecular property prediction, protein function prediction, and link prediction tasks, on which ours largely outperforms relevant baselines 1 .
Introduction
A graph, consisting of nodes and edges, is a data structure that defines a relationship among objects.
Recently, graph neural networks (GNNs) [17, 9, 35, 43], which aim to represent this structure with neural networks, have achieved great successes in modeling real-world graphs such as social networks [5], knowledge graphs [1], biological networks [22] and molecular graphs [41].
However, it is extremely costly and time-consuming to annotate every label of the graphs.
For example, labeling the properties of molecular graphs requires time-consuming laboratory experiments [12].
Recently, various self-supervised learning methods for GNNs [12, 51, 13, 31] have been studied to overcome this issue of the lack of labeled graph data.
The existing self-supervised learning methods can be classified into two categories: predictive learning and contrastive learning.
Predictive learning methods [12, 25, 16] aim to learn representations by predicting contexts of a graph (Figure 1, (a-1)).
However, predictive learning schemes are limited as they consider only the subgraphical semantics.
Contrastive learning [36, 30, 47, 52, 48, 42], which is a popular self-supervised learning approach in the computer vision field [27, 39, 4, 10], can learn the global semantics by maximizing the similarity between instances (images) perturbed by semantic-invariant perturbations (e.g. color jittering or flipping).
Graph contrastive learning methods also use a similar strategy, generating positive examples
[Figure]
𝑑 =
Global Graph Prediction 𝑑 =
Original
D i sc r
i m i
na t o r
Perturbed Perturbed
[Figure] [Figure]
with edge perturbation, attribute masking, and subgraph sampling, and then maximizing the similarity between two differently perturbed graphs from the original graph (See Figure 1, (b-1)).
However, is it always correct to assume that the perturbed graphs by such perturbations will preserve the semantics of the original graph?
In computer vision, there exists a set of well-defined perturbations, that does not change the human perception of the given image.
However, in contrast to images that reside in a continuous domain, graphs are discrete data structures by nature, and thus their properties could become completely different even with slight perturbations.
For example, two molecules in
Figure 1 (d) and (e) show that, although they have a highly correlated structure, one molecular graph could be actively bound to a set of inhibitors of human β -secretase 1 [38], whereas the other is not.
In this case, existing contrastive learning with perturbations may lead the representations for two semantically dissimilar graphs to collapse into the one representation (See Figure 1 (b-2)).
To tackle this problem, we propose a novel self-supervised learning method which aims to learn the discrepancy between graphs, which we refer to as D iscrepancy-based S
elf-supervised L e A rning (DSLA).
Specifically, we first perturb the given graph similarly as with contrastive learning schemes, but instead of maximizing the similarities across the perturbed graphs as done with contrastive learning, we aim to learn their discrepancies.
To this end, we first introduce a discriminator which learns to discriminate real graphs from the perturbed ones (See Discriminator in Figure 1, (c-1)).
This allows the model to learn small differences that may largely impact the global property of the graph, as illustrated by the example in Figure 1 (d) and (e).
However, simply knowing that two graphs are different is insufficient, and we would want to learn the exact amount of discrepancy between them.
Notably, with our perturbation scheme, the exact discrepancy can be trivially obtained since the graph edit distance [26] is automatically derived as the number of edges we perturb for a given graph.
Then, we enforce the embedding-level difference between original and perturbed graphs to be proportional to the graph edit distance (See dotted circles in Figure 1 (c-1)).
Finally, to discriminate the original and perturbed graphs from the completely different graphs, we enforce the relative distance of the latter to be larger than the former, by a large margin (See blue arrows in Figure 1, (c-1)).
This will enable our D-SLA to capture both small and large topological differences (See Figure(c-2)).
Thus, our framework can enjoy the best of both worlds for graph self-supervised learning: predictive and contrastive learning.
The experimental results show that our model significantly outperforms baselines, especially on the datasets where graphs with different properties have highly correlated structures, demonstrating the effectiveness of ours.
Our main contributions are as follows:
• We propose a novel graph self-supervised learning framework with a completely opposite objective from contrastive learning, which aims to learn to differentiate a graph and its perturbed ones using a discriminator, as even slight perturbations could lead to completely different properties for graphs.
• Utilizing the graph edit distance that is obtained for perturbed graphs at no cost, we propose a novel objective to preserve the exact amount of discrepancy between graphs in the representation space.
• We validate our D-SLA by pre-training and fine-tuning it on various benchmarks of chemical, biology, and social domains, on which it significantly outperforms baselines.
Related Work
We now briefly review the existing works on graph neural networks (GNNs), and self-supervised learning methods for GNNs including predictive and contrastive learning.
Most existing graph neural networks (GNNs) could be formulated under the message passing scheme [8], which represents each node by firstly aggregating the features from its neighbors, and then combining the aggregated message with its own node representation.
Different variants of update and aggregation functions have been studied.
To mention a few, Graph Convolutional Network (GCN)
[17] generalizes the convolution operation in a spectral domain of graphs, approximated by the mean aggregation.
GraphSAGE [9] concatenates the representations of neighbors with its own representation when updating the node representation.
Graph Attention Network (GAT) [35] considers the relative importance among neighboring nodes for neighborhood aggregation, which helps identify relevant neighbors for the given task.
Graph Isomorphism Network (GIN)
[43] uses the sum aggregation, allowing the model to distinguish two different graphs as powerfully as the Weisfeiler-Lehman (WL) test [19].
While GNNs have achieved impressive results on various graphrelated tasks, the trained representations from one dataset are usually not transferable to different downstream tasks.
Moreover, labels of such task-oriented data are often scarce, especially in scientific domains (e.g., chemistry and biology)
Thus, in this work, we aim at obtaining transferable representations of graph-structured data with self-supervised learning, without using any labels.
Self-supervised learning for GNNs can be broadly classified into two categories: predictive learning and contrastive learning, which we will briefly introduce in the following paragraphs.
Predictive learning aims to learn contextual relationships by predicting subgraphical features, for example, nodes, edges, and subgraphs.
Specifically, Hu et al.
[12] propose to predict the attributes of masked nodes.
Also, Hwang et al.
[14] and Kim and Oh [16] propose to predict the presence of an edge or a path with the link prediction scheme.
Furthermore, Hu et al.
[13] and Rong et al.
[25] propose to predict the generative sequence, contextual properties, and motifs of the given graphs.
However, the predictive learning methods are limited in that they may not well capture the global structures and/or semantics of graphs.
The limitations of predictive learning gave rise to contrastive learning methods, which aim to capture global graph-level information.
Early contrastive learning methods for GNNs aim to learn the similarity between the entire graph and its substructure, to obtain the representations for them without using any perturbations [36, 30].
Despite their successes, to further expand the embedding space of a model, contrastive learning methods have been actively studied with perturbation methods such as attribute masking, edge perturbation, and subgraph sampling [47, 52, 37, 48].
Recently proposed adversarial methods further generate positive examples either by adaptively removing the edges [32] or by adjusting the attributes [45].
Further, Xu et al.
[44] aim to cluster graph representations via contrastive learning, and Thakoor et al.
[33] propose a memory-efficient method for large-scale graph representation learning.
However, while contrastive learning allows learning the global semantics with perturbed graphs, there exists a potential risk where the model can consider two dissimilar graphs as the same (See Figure 1 (b), (d), and (e)), due to the discrete nature of graphs.
Contrarily, our novel pretext task of predicting the correct graph from multiple choices, which includes both slightly perturbed graphs and strongly perturbed graphs, allows the model to learn the correct relationships among local elements, but also learn the global graph-level differences.
Method
In this section, we introduce our novel graph self-supervised learning framework, D iscrepancy-based
S elf-supervised L e A rning ( D-SLA ), which is illustrated in Figure 2.
Specifically, we first recount the notion of graph neural networks and existing graph self-supervised learning in section 3.1.
Then, we introduce each component of our D-SLA in Section 3.2, 3.3, and 3.4, respectively.
After that, we finally describe the overall framework that combines all three components in Section 3.5.
𝐺 0 (Original Graph)
Edge Addition
Edge Deletion 𝐺 1 :𝑑 =𝐺 3 :𝑑 =2 𝐺 2 :𝑑 =
N ode
A tt r i bu t e M
a sk
i ng
G r aph
E n c od
i ng
Node Masking
Other graphs in the same batch
Original
Graph Discriminator
Perturbed Perturbed Perturbed 𝑮′𝑮𝑮𝑮 𝟑 𝑮𝑮′ 𝟐 𝒅= 𝒅=𝟐 Distance-based Learning 𝒅>𝜶+ 𝟐 𝒅>𝜶+ 3.1 Preliminaries
Graph Neural Networks A graph G can be defined by four components: G =
( V , E , X V , X E ) , where V is the set of nodes
, E is the set of edges, X V ∈ R |V|× d is the matrix of node features, and X E ∈ R |E|× d ′ is the matrix of edge features, where d and d ′ are the dimensionalities of node and edge attributes, respectively.
Let h v be a representation of a node v , and h G be a representation of a graph G .
Then, the goal of graph neural networks (GNNs) is to represent nodes of the given graph by leveraging its topological structure.
To be specific, GNNs learn node representations (i.e., h v ) by iteratively aggregating messages from their neighbors in a layer-wise manner, which is usually referred to as message-passing [8] and formally defined as follows:
[Equation]
where f ( l ) U denotes an update function that updates a representation of the given node along with its neighbors’ representations, f ( l ) A denotes an aggregate function that aggregates messages from the node’s neighbors, N ( v ) denotes a set of neighbors of the node v , and l denotes a l -th layer of GNNs.
To further obtain the representation for an entire graph, we usually summarize all node representations from Equation 1 into a single embedding vector with a permutation-invariant function f R as follows:
[Equation]
While a natural choice of f R is to use simple operations, such as mean or sum, various graph representation learning methods have been recently studied to accurately capture the entire graph information, including node clustering based [46, 2], and node drop based methods [7, 18].
Contrastive Learning for Self-supervised Learning of GNNs We now describe why contrastive learning fails to distinguish two topologically similar graphs yet having completely different properties.
In particular, contrastive learning aims to increase the similarity between positive pairs of graphs while increasing the dissimilarity between negative pairs [47, 52, 48].
Thereat, to define positive pairs, they perturb the original graph by manipulating edges, masking attributes, and sampling subgraphs, and then consider the perturbed graphs as the same as the original graph.
On the other hand, they consider other graphs in the same batch as dissimilar.
Formally, for the perturbed graphs G i and G j from the original graph G 0 , the objective of contrastive learning is defined as follows:
[Equation]
where G ′ is the other graph in the same batch with the graph G 0 , which is also referred to as a negative graph .
Therefore, G i and G j are a positive pair, whereas, G i and G ′ are a negative pair.
f sim denotes a similarity function between two graphs, for example, L 2 distance or cosine similarity.
By minimizing the objective in Equation 3, existing contrastive learning methods closely embed two perturbed graphs
G i and G j : G i ∼ G j .
However, as the perturbations may not preserve the properties of the given graph due to the discrete nature of graph-structured data, they indeed should not be similar: G i ̸∼ G j (See
Figure 1 (d) and (e)).
To this end, we propose a new objective that can differentiate between the original graph and its perturbations, which we describe in the next subsection.
3.2 Discrepancy Learning with Graph Discrimination
We now introduce our novel graph self-supervised learning objective to preserve the discrepancy between two graphs in the learned representation space, for which we then describe the perturbation scheme to generate augmented graphs from the original graph.
Discriminating Original Graphs from Perturbed Graphs Contrarily to contrastive learning that trains perturbed graphs to be similar, our goal is to distinguish the original graph from perturbed graphs, by predicting the original graph among original and perturbed graphs, which we term as the original graph discrimination (See Graph Discriminator in Figure 2).
Let G 0 be an original graph, and G i be a perturbed graph with i ≥ 1 .
Then objective of our discrimination scheme is as follows:
[Equation]
where S k is a score of the graph G k , obtained from a learnable score network f S of the discriminator, i.e., f S : h G (cid:55)→ S ∈ R .
By training to discriminate the original graph from the perturbed graphs, the model is enforced to embed the perturbed graphs apart from the original graph (Figure 3 (b)).
Therefore, the model learned by our discrimination scheme will be capable of distinguishing even the slight differences between the original graph and its perturbations, as well as be capable of capturing the correct distribution of the graphs, since perturbed graphs could be semantically incorrect.
Perturbation The remaining question is how to perturb the graph to generate negative examples (i.e., G i ).
We aim at adding or deleting the subset of edges in the given graph, and thus such perturbed graphs are slightly different from the original graph but also could be semantically incorrect.
Again, in this way, since our graph discrimination objective in Equation 4 discriminates the original graph from slightly perturbed graphs, the graph-level representations from our pre-trained GNNs can capture subtle difference that may have a large impact on the properties of graphs, for downstream tasks.
In particular, our perturbation scheme consists of the following two steps: 1) removing and adding a small number of edges, and 2) masking node attributes (Figure 2).
To be specific, given an original graph G =
( V , E , X V , X E ) , we aim to perturb it n times, to obtain {G 1 , ..., G n } .
To do so, we first manipulate the edge set E by removing existing edges as well as adding new edges on it and then adjust its corresponding edge matrix X E .
After that, we further randomly mask the node attributes on X V for both original and perturbed graphs, to make it more difficult to distinguish between them.
Formally, the original and perturbed graphs from our node/edge perturbations are obtained as follows:
[Equation]
where M and P are the node masking and edge perturbation functions, respectively.
The scores of original and perturbed graphs are then computed with the score function f S :
[ S 0 , S 1 , ..., S n ] = [ f S ( G 0 ) , f S ( G 1 ) , ..., f S ( G n )] , which are then used for our previous learning objective in Equation 4.
3.3 Learning Discrepancy with Edit Distance
While the learning to discriminate original and perturbed graphs described in Section 3.2 allows the model to learn the discrepancy between original and perturbed graphs by embedding them onto different points, it cannot learn how dissimilar the perturbed graph is from the original one as all perturbed graphs are considered as equal (Figure 3 (b)).
Thus, to further learn the accurate discrepancy among different graphs, here we introduce a method for efficiently computing the graph discrepancy between original and perturbed graphs leveraging the graph edit distance [26].
Then we describe how to preserve the calculated discrepancy in the learned graph representation space.
[Table]
Graph Edit Distance To preserve the exact amount of discrepancies between original and perturbed graphs in the learned representation space, we first need to measure the graph distance.
Graph edit distance, which is widely used to measure the dissimilarity between two graphs [26], is defined by the number of insertion, deletion, and substitution operations for nodes and edges, to transform one graph into the other graph.
Although computing [Figure] the graph edit distance is the NP-hard problem [50], for our case, it is trivially obtained without any cost.
This is because, for each perturbed graph, we know the exact number of edge addition and deletion steps as we have generated it using the same process.
In other words, the number of added and deleted edges is simply the edit distance between original and perturbed graphs.
This brings us significant computational advantages, as we generally require a significant amount of costs for calculating or estimating the distances between two graphs, as shown in Table 1.
Note that although several existing works [20, 3] leverage graph edit distance, they are completely different from our work since they are neither self-supervised learning methods nor leverage the graph perturbation.
Distance-based Discrepancy Learning Based upon the graph edit distance, we design the regularization term to learn the exact amount of differences between original and perturbed graphs over the embedding space.
To be specific, we regularize the model to learn that the embedding-level difference between original and perturbed graphs is proportional to their actual graph edit distance (i.e., if the edit distance between two graphs is large, then they are far away in the embedding space, whereas, if it is small, then they are close to each other) as shown in Distance-based Learning of Figure 2.
We first let an original graph G 0 be an anchor graph, then a graph edit distance and an embedding-level distance between the anchor graph G 0 and the perturbed graph G i are defined as e i and d i , respectively.
With such notations, to achieve our objective of learning an exact amount of discrepancy across original and perturbed graphs, we formalize our edit distance-based regularization loss as follows:
[Equation]
where f diff measures the embedding-level differences between graphs with L 2 -norm.
We find that Equation 6 can capture the exact amount of differences as shown in Figure 3 (c).
Note that
Equation 6 alone does not work as shown in Table 5, since the trivial solution of Equation 6 is to set all the embedding-level distance between original and perturbed graphs as zero (i.e., d i = 0 ∀ i ) .
However, learning the accurate amount of discrepancy without the trivial solution is feasible by jointly training with the objective of original graph discrimination in Equation 4 where the model should differently embed G
and G i to discriminate them.
Furthermore, as we can generate different levels of perturbations according to the graph edit distance, our graph embedding space can interpolate between two different graphs, for example, weakly and strongly perturbed graphs in terms of their actual distances, unlike previous predictive and contrastive learning methods.
3.4 Relative Discrepancy Learning with Other Graphs
Thus far, we aimed toward distinguishing the perturbed graphs from the original graph in Section 3.2, with their actual edit distance-based discrepancy learning in Section 3.3.
However, such schemes alone will not allow the model to learn the discrepancy between two completely different graphs (Figure 3 (c)).
While one might consider learning the discrepancy between original and its negative graphs (other graphs in the same batch) with their graph edit distance, it is impractical as computing the edit distance between completely different graphs is NP-hard [50].
Thus, we instead propose to learn a relative distance, exploiting the assumption that the distance between original and negative graphs in the same batch is larger than the distance between original and perturbed graphs with some amount of margin (See Figure 2, Distance-based Learning).
The usage of margin is highly beneficial for our discrepancy-based learning framework, since, if the negative graphs are far apart than the amount of margin plus the distance between original and perturbed graphs, the model does not attract the perturbed graphs to the original graph, therefore not losing the discrepancy learned in Equation 6.
Formally, we realize the relative discrepancy learning with the triplet margin loss as follows:
[Equation]
where d i is the distance between original and its perturbed graphs: d i = f diff ( h G 0 , h G i ) , d ′ j is the distance between original and its negative graphs: d ′ j = f diff ( h G 0 , h G ′ j ) with G ′ as in-batch negative graphs, and α > 0 as a margin hyperparameter.
In this way, we can allow the model to learn that, for the original graph, negative graphs are more dissimilar than the perturbed graphs, while perturbed graphs are also marginally dissimilar to it with the amount of edit distances as shown in Figure 3 (d).
3.5 Overall Framework
To sum up, our D-SLA framework aims to learn a graph representation space which preserves the discrepancy among graphs.
Our graph discriminator described in Section 3.2 helps learn a space that can discriminate even the slightly perturbed graph from its original graph (Figure 3 (b)).
Then, the discrepancy learning with graph edit distance described in Section 3.3 (Figure 3 (c)) enforces the embedding space to preserve the exact discrepancy among graphs.
Finally, the margin-based triplet constraints between the perturbed and completely different graphs in Section 3.4 allow the learned embedding space to capture the relative distance between graphs (Figure 3 (d)).
Our overall learning objective, dubbed as Discrepancy-based Self-supervised LeArning (D-SLA), is given as follows:
[Equation]
where hyperparameters λ 1 and λ 2 are scaling weights to each loss.
Note that, unlike predictive learning [12] which aims to capture local semantics of graphs by masking and predicting local components, such as nodes and edges, our D-SLA learns the graph-level representations where the subtle differences on corner regions of different graphs could be captured by distinguishing original and perturbed graphs.
Moreover, our D-SLA can discriminate differently perturbed graphs having different properties, unlike contrastive learning [47, 48] that considers them as similar.
Experiments
In this section, we first experimentally validate the proposed Discrepancy-based Self-supervised LeArning (D-SLA) on graph classification tasks to verify its effectiveness in obtaining accurate graph-level representations. After that, we further evaluate our D-SLA on link prediction tasks for which capturing the local semantics of graphs is important.
4.1 Graph Classification
Accurately capturing the global semantics of given graphs is crucial for graph classification tasks, on which we validate the performance of our D-SLA against existing baselines.
Experimental Setup We evaluate our D-SLA on two different domains: the molecular property prediction task from chemical domain [38, 11] and the protein function prediction task from biological domain [12].
For the chemical domain, we follow the experimental setup from You et al.
[48], whose goal is to predict the molecules’ biochemical activities.
For the self-supervised learning, we use 2M molecules from the ZINC15 dataset [29].
Then, after the self-supervised learning, we perform fine-tuning on datasets from MoleculeNet [38] to evaluate the down-stream performances of models.
For the biological domain, we follow the setup from You et al.
[48], for which the goal is to predict the proteins’ biological functions.
For pre-training and fine-tuning, we use the dataset of PPI networks [53]. We use the ROC-AUC value as an evaluation metric, and report the average performance over five different runs following Xu et al.
See Appendix A.2 for dataset details.
Models We compare our D-SLA against predictive learning baselines:
EdgePred [9], AttrMasking [12] and ContextPred [12], and contrastive learning baselines: Infomax [36], GraphCL [47],
JOAO [48], GraphLoG [44], and BGRL [33].
Detailed explanations of models including baselines and ours are provided in Appendix A.1.
Implementation Details We follow the conventional experimental setup of graph self-supervised learning from Hu et al.
[12], where we use the GIN [43] as the base network.
For pre-training of our model, we perturb the original graph three times.
To be specific, to obtain the perturbed graphs from the original graph, we first randomly select a subgraph of it, and then add or remove edges in the range of { 20% , 40% , 60% } over the sampled subgraph.
For fine-tuning, we follow the hyperparameters from You et al.
We provide additional details in Appendix A.2. [Table] [Figure] [Figure]
Results Table 2 shows that our D-SLA achieves the best average performance against existing predictive and contrastive learning baselines on tasks from both chemical and biological domains, demonstrating the effectiveness of our discrepancy-based framework.
To better see what aspects of
D-SLA contribute to the performance improvements, we perform in-depth analyses of each dataset, and how our model can effectively handle the task on it, in the next paragraph.
Analysis To analyze whether the structural similarity of molecules is correlated to their biochemical activities, we measure the inherent discrepancy of graphs with the Tanimoto similarity over Morgan fingerprints [24].
To be specific, we first iteratively sample an anchor molecule among active molecules in the dataset, and then measure the average Tanimoto similarities of the five most similar active/inactive molecules.
In other words, the high similarity values of Inact.
Sim.
in Table 3 suggests that the molecules have highly overlapped structures regardless of their biochemical activities.
For example, as shown in Table 3, the molecules in the BACE dataset are highly correlated, although their activities are different.
Also, we further observe that, as shown in Figure 4 that visualizes the most similar active/inactive molecules with respect to the certain anchor molecule in the BACE dataset, the structures between active and inactive molecules are highly similar.
From the above observations, we suggest that, due to the discrete nature of graphs, two slightly different graphs can have completely different properties, which may be the reason for the performance degeneration of contrastive learning methods in Table 2 – which consider perturbed graphs as similar while they might not be the semantically same – on such particular datasets (e.g., BACE, MUV, Tox21,
ToxCast) having the high Inact.
Sim. scores in Table 3.
However, our D-SLA largely outperforms contrastive learning baselines on them 2 , because ours not only discriminates an original graph from its perturbations but also can learn their exact discrepancy via the graph edit distance.
We note that our method shows the competitive performance on ClinTox and SIDER in Table 2, since they have the lowest structural similarities across different biochemical properties, for which contrastive learning could be effective.
We provide more analysis in Appendix B.1.
4.2 Link Prediction
Accurately capturing the local semantics of a graph is an important requisite for solving node/edgelevel tasks.
Thus, we further validate our D-SLA on the link prediction task.
Experimental Setup We conduct link prediction experiments on social network datasets – COLLAB, IMDB-B, and IMDB-M – from the TU benchmarks [21].
We separate the dataset into four parts: pre-training, training, validation, and test sets in the ratio of 5:1:1:3. We use the average [Table] [Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure] [Table] [Figure] [Table]
precision as an evaluation metric, and report the results over five different runs.
We provide more details in Appendix A.3. Implementation Details For GNNs, we use the GCN [17] following You et al.
For perturbation, we add or delete only a tiny amount of edges (e.g., 1 or 2 edges) while increasing the magnitude of perturbation to obtain three perturbed graphs.
Note that we do not use the margin triplet loss in
Section 3.4, since for local prediction tasks, the graph-level discrepancy learning between completely different graphs is not much helpful in capturing local semantics.
For fine-tuning, we train the GNNs to predict whether there is an edge between nodes, and evaluate the GNNs for predicting the existence of 10 edges.
For more implementation details, please see Appendix A.3.
Results As shown in Table 4, predictive learning baselines outperform other baselines, since it learns to predict local node/edge attributes.
However, our D-SLA largely outperforms all baselines, while it aims to discriminate graph-level representations though.
We suggest that this is because ours can capture subtle differences of graphs by leveraging the graph edit distance, demonstrating that accurate discrepancy learning is obviously useful for the local link prediction task.
4.3 Analysis
In this section, we further analyze the efficacy of our D-SLA.
We provide the additional experimental details in Appendix A.4.
Rank Correlation Coefficient To see whether learned representations capture the exact amount of discrepancy, we compare the ranks of the calculated vs actual similarities between original and perturbed graphs with Spearman’s rank correlation coefficient.
Note that the results of the WL algorithm [19] are merely a performance indicator of discriminative power since it cannot obtain representations that generalize to downstream tasks.
As shown in Figure 5, unlike baselines that mostly fail to discriminate different graphs, our D-SLA has the discriminative power that is on par with the powerful WL algorithm, while ours can generalize to downstream tasks as shown in Table 2.
[Table]
Ablation Study To see how much each component contributes to the performance gain, we conduct an ablation study.
As shown in Table 5, we observe that our graph discrimination task ( L GD ) significantly improves the performance on down-stream tasks against no-pretraining.
However, leveraging the exact edit distance alone ( L edit ) does not learn meaningful representations, since the model trivially sets all the distances between original and its perturbations as zero, as discussed in Section 3.3.
Also, we further observe that each component of distance-based learning in Section 3.3 and 3.4 helps to improve the performance, verifying that accurate discrepancy learning with edit and relative distances is important for modeling graphs.
We further discuss the ablation study in Appendix B.2.
Embedding Visualization We visualize the embedding space from various pre-training methods: predictive, contrastive, and ours, in Figure 1 (a,b,c-2).
We observe that predictive learning cannot capture the global graph-level similarity well, as it aims to predict subgraphical semantics of graphs during the pretext task.
While contrastive learning can closely embed the highly similar graphs to the original graph, it cannot accurately capture the exact amount of discrepancies among perturbed graphs.
Contrarily, our D-SLA can accurately distinguish between the original, perturbed, and negative graphs, while accurately capturing the exact amount of discrepancy for the perturbed graphs.
Conclusion
In this work, we focused on the limitations of existing self-supervised learning for GNNs: predictive learning does not capture the graph-level similarities; contrastive learning might treat two semantically different graphs from perturbations as similar.
To overcome such limitations, we proposed a novel framework (D-SLA) that can learn the graph-level differences among different graphs while also can learn the slight edge-wise differences, by discriminating the original from perturbed graphs.
Further, the model is trained to differentiate the target graph from its perturbations and other graphs, while preserving the accurate graph edit distance, allowing the model to discriminate between not only two structurally different graphs but also similar graphs with slight differences.
We validated our D-SLA on 12 benchmark datasets, achieving the best average performance.
Further analysis shows that it learns a discriminative space of graphs, reflecting the graph edit distances between them.
In this section, we discuss the limitation and potential societal impacts of our work.
Limitation In this work, we propose a graph self-supervised learning framework, which aims to learn the discrepancy between the original and perturbed graphs, by discriminating the original graph among the original and its perturbations, but also by learning the exact amount of discrepancy across them with the graph edit distance. Note that, while our perturbation scheme can easily make the slight structural differences, it cannot be aware of the semantic differences across differently perturbed graphs, since the graph semantics depend on the target domain.
In other words, nodes and edges could differently contribute to the graph semantics depending on the target graph domain (e.g., molecular graphs or social networks), which are hard to pre-define in one framework.
As manually annotating the semantic differences across different graphs is impossible to do in an end-to-end fashion, one may need to devise a clever way to be aware of the semantics of graphs for further reflecting the exact semantic difference in the embedding space, which we leave as future work.
Potential Societal Impacts Discovering de novo drugs is significantly important to our society since they can be used for curing a disease or enhancing agricultural production, that is directly related to our life.
However, it is extremely costly and time-consuming to design drug candidates and validate them, requiring immense lab experiments and labor.
In this work, we verify our proposed method in the graph classification task in Table 2 of the main paper, and ours outperforms the other baselines for classifying toxicity on the Tox21 and ToxCast datasets.
We strongly believe that such aspects of our method can positively contribute to our society in developing valuable drugs.
However, when validating the toxicity of the most acceptable drug candidates, someone might badly use our method to reduce the money and time (i.e., does not check the toxicity of drugs for reducing costs, however, which may be used for clinical trials to humans), which can negatively affect our society. We sincerely hope that our method would not be utilized for such a bad purpose.
We thank anonymous reviewers for their constructive feedback.
This work was supported by Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by the
Korea government (MSIT) (No.2019-0-00075, Artificial Intelligence Graduate School Program (KAIST), and No.2021-0-02068, Artificial Intelligence Innovation Hub), the Engineering Research
Center Program through the National Research Foundation of Korea (NRF) funded by the Korean Government MSIT (NRF-2018R1A5A1059921), and Samsung Electronics (IO201214-08145-01). A Experimental Details
In this section, we first introduce the computing resources that we use, the baselines, and our model in Section A.1. After that, we describe the experimental setups of the graph classification and link prediction tasks in Section A.2 and Section A.3 as well as the analysis in Section A.4.
Computing Resources For all experiments, we use PyTorch and PyTorch Geometric libraries [23, 6], for easy usage of GPU resources. We use TITAN XP and GeForce RTX 2080 Ti for training and evaluating all models.
EdgePred is a predictive learning baseline adopted from the link prediction task of Hamilton et al.
[9], whose goal is to predict the existence of edges between the given two nodes. AttrMasking [12] is a predictive learning baseline that predicts the attributes of masked nodes and edges from the embeddings of nodes. ContxtPred [12] is a predictive learning baseline that first samples two different subgraphs from the same centered node, and then trains them to be similar while the subgraphs from the other graphs are trained to be dissimilar. Infomax [36] is a contrastive learning baseline, whose goal is to learn the representations for the given graph and the substructure within the same given graph to be similar while learning the representations for the given graph and the substructures from the negative graphs to be dissimilar.
GraphCL [47] is a contrastive learning baseline, whose goal is to learn the similarity between two perturbed graphs from the same graph contrasting to in-batch negative graphs over the global graph-level representations.
In particular, this method uses the following four perturbation methods: attribute masking, edge perturbing, node dropping, and subgraph sampling.
JOAO [48] is a contrastive learning baseline that, while the learning objective of it is the same as the GraphCL model described above, learns to automatically select the perturbation schemes.
JOAOv2 [48] is a variant of JOAO, which has individual projection heads according to the perturbation schemes. Specifically, a perturbed graph is fed into the typical projection head according to the selected perturbation. GraphLoG [44] is a baseline that has two learning objectives: 1) it matches the masked nodes/graphs to their unmasked counterparts; 2) it clusters a group of globally similar graphs with learnable cluster prototypes. BGRL [33] is a baseline that maximizes the similarity between two perturbed graphs from the original graph without considering in-batch negative graphs, aiming to represent large-scale graphs with efficiency in memory usage.
D-SLA is our discrepancy-based graph self-supervised learning framework, which aims to learn the accurate discrepancy between original, perturbed, and negative graphs, by not only discriminating the original graph from its perturbations but also preserving the accurate amount of discrepancy with the graph edit distance between them.
A.2 Graph Classification
[Table]
Datasets We use the available benchmark datasetsfor the graph classification task. Specifically, for the chemical domain, we use 2M molecules sampled from the ZINC15 dataset [29] without using any labels on it. The fine-tuning datasets consist of the molecular graphs from MoleculeNet [38], where the classes are given by the biophysical and physiological properties of the molecules. For the biological domain, the datasets are constructed by the sampled ego-networks from the PPI networks [53].
In particular, the pre-training dataset consists of 306K unlabeled protein ego-networks of 50 species, and the fine-tuning dataset consists of 88K protein ego-networks of 8 species with the label given by the functionality of the ego protein. We report the statistics of graph classification datasets in Table 6. Strategy for Selecting Edges for Perturbations In this paragraph, we describe the detailed edge selection scheme for our graph perturbation.
In our experiments of graph classification, we first select the node and then sample the 3 -hop subgraph of it. After that, we randomly add and remove edges on the subgraph. The reason behind selecting the target subgraph for perturbation is that we aim to reduce the potential risk of making unreasonable cycles, which are impractical especially on the chemical domain. Therefore, to prevent the model to learn such an incorrect bias in the embedding space, we rather sample the subgraph for perturbing the edges.
Common Implementation Details We follow the conventional design choice of GNNs for evaluating the graph self-supervised learning methods from Hu et al. [12]: Graph Isomorphism Networks (GINs) [43] consisting of 5 layers with 300 dimensions along with mean average pooling for obtaining the entire graph representations. For pre-training of our D-SLA, we sample a subgraph by randomly selecting a center node and then select 3-hop neighbors of it, and then remove the edges on the selected subgraph three times with different magnitudes (20%, 40%, 60%) to make three perturbed graphs, while memorizing the number of deleted and added edges to calculate the graph edit distance. To prevent the situation where the deleted edges are added again, we add edges that are not present in the given original graphs.
{+We mask 80% of nodes in the selected subgraph to confuse the model to distinguish the original graph from its perturbed graphs. Furthermore, we include the strong perturbation, where 80% of edges are perturbed and 80% of nodes are masked among entire nodes and edges in the given graph. λ 
 and λ 2 are set as 0.7 and 0.5, respectively.+}
Implementation Details on Molecular Property Prediction We follow the conventional molecule representation setting from Hu et al. [12], where the node attributes contain the atom number along with the chirality, and the edge attributes contain the bond type (e.g., Single, Double, Triple or Aromatic) along with the bond direction which is represented if an edge is a double or aromatic bond. When adding an edge during edge perturbation, we sample its type by following the distribution of edge attributes in the pre-training dataset.
Specifically, we first sample the bond type following the distribution and then sample also the bond direction depending on the bone type.
For pre-training, we use the batch size of 256, the number of epochs of 100, the learning rate in the range of [0.01, 0.001, 0.0001], and the margin α in the range of [3,4,5,6,7] by grid search. For the splitting of fine-tuning datasets, we use the scaffold splitting following the conventional setting from Hu et al.
[12] and You et al.
For fine-tuning, we also follow the conventional setting from You et al. Implementation Details on Protein Function Prediction We use the pre-defined biological graphs from Hu et al. [12], where a node corresponds to a protein without any attributes, and an edge corresponds to a relation type between two proteins such as biological interaction or co-expression.
As in molecular property prediction, we add reasonable edges by following the distribution of edge attributes in the pre-training dataset.
For pre-training, the number of epochs is 100, the batch size is 128, the learning rate is 0.001, and the margin is 10.
For data splitting of the fine-tuning dataset, we use the provided conventional setting from Hu et al. For fine-tuning, we also follow the conventional setting from Hu et al. Note that, as the result of GraphLoG [44] on this protein function prediction task is not available in the referred paper, we produce the result by following the experimental setups along with the provided public source code. A.3 Link Prediction
[Table]
Datasets The datasets 4 we used for the link prediction task are COLLAB, IMDB-B (IMDB-BINARY), IMDB-M (IMDB-MULTI) – the social network datasets from TU dataset benchmark [21].
COLLAB dataset consists of egonetworks extracted from public scientific collaboration networks, namely High Energy Physics, Condensed Matter Physics, and Astro Physics. IMDB-B and IMDB-M are movie collaboration ego-networks where a node represents an actor/actress. The statistics of social network datasets are provided in Table 7.
Strategy for Selecting Edges for Perturbations To capture the fine-grained local semantics, we suggest that the weaker magnitude of perturbation is the better (See Section B.6 verifying the effect of edge perturbation strengths).
Therefore, we only perturb the tiny amount of edges (e.g., 1 oredges), as shown in Table 7, rightmost column. Implementation Details We use the Graph Convolutional Network (GCN) [17] consisting of three layers with 300 hidden dimensions. Following the previous works [47, 48], we let the node attributes correspond to the degree of the node. For pre-training, we remove the complete graphs – that always have the edges between any two nodes – as we cannot include additional edges during perturbation.
For node masking used in AttrMaksing and our D-SLA, we replace the node attribute with the masked token.
For hyperparameters, we use the learning rate of 0.001, the batch size of 32, and the λ 1 of 0.7. During pre-training of our D-SLA, we generate three perturbed graphs by increasing the perturbation magnitudes (e.g., 1%, 2%, 3%). Also, we further mask 20% of nodes in perturbation. A.4 Analysis
Rank Correlation Coefficient The spearman’s rank correlation coefficient measures the correlation between two rank series in the range from -1 to 1, where the value is 1 if the two rank series are perfectly and monotonically the same.
We build the following two rank series to compare: 1) the labeled similarity rank between the original and perturbed graphs using the graph edit distance, and 2) the predicted similarity rank based on the embedding-level distances between original and perturbed graphs from pre-trained models.
Specifically, we perturb edges of the entire graph by gradually increasing the magnitude of edge perturbation (i.e., 5%, 10%, 15%, 25%, 35%, 45%, 60%, 75%, 90%), and then label ranks of the perturbed graphs to the original graph according to the graph edit distance. Then, the original and perturbed graphs are fed into the pre-trained models, and the ranks are measured by the embedding-level distance between the original and perturbed graphs. Therefore, if a pre-trained model can capture the exact amount of discrepancy, the rank correlation coefficient would be 1, by locating the embedding of a similar graph (a weakly perturbed graph) closer to the original graph than the embedding of a dissimilar graph (a strongly perturbed graph). We measure the coefficient with randomly sampled 1 , 000 different graphs.
For models to calculate the similarity across different graphs, we use the pre-trained model for the graph classification task in our D-SLA.
For EdgePred, AttrMasking, ContextPred, Informax, and GraphCL baselines, we use the publicly available pre-trained models 5 . For JOAO and GraphLoG, we use the public source codes 6 , to obtain the pre-trained models. The WL algorithm in Figureof the main paper corresponds to a randomly initialized GIN model.
In other words, since the GIN is as powerful as the WL test, we denote it as the WL algorithm. We evaluate the above models on two different datasets: ZINC15 [29] and QM9 [21], where statistics of each dataset is provided in Table can measure generalization ability with it. Embedding Visualization To visualize the representation space of the original, perturbed, and negative graphs, we pre-train the models on the subset of the ZINC15 dataset [29] with the perturbation strategy in Section A.2 for obtaining perturbed graphs.
Then, after pre-training, we visualize the graph representations by PCA [15] and t-SNE [34] for Figure 1 and Figure 3 of the main paper, respectively.
[Figure]
In this section, we provide additional results with their corresponding discussions. To be specific, in Section B.1, we analyze the correlation between the characteristics of the dataset and self-supervised learning methods.
Then, we provide an in-depth discussion about our observations in the ablation study in Section B.2.
Additionally, we provide some guidelines for choosing our hyperparameters ( λ 1 , α , λ 2 , and the perturbation magnitude) in Section B.3, B.4, B.5, and B.6, respectively.
Futhermore, we provide an ablation study of attribute masking in Section B.7.
Finally, we compare our D-SLA with augmentation-free approaches in Section B.8. B.1 Dataset Analysis In this subsection, we further discuss the characteristics of graph self-supervised learning methods with respect to the characteristics of datasets. As shown in Section 4.1, we find that contrastive learning methods outperform predictive learning methods on BBBP and ClinTox.
Contrarily, predictive learning methods outperform contrastive learning methods on Tox21.
Therefore, we further analyze
BBBP, ClinTox, and Tox21 datasets to answer why such methods have counterfactual effects on different datasets.
In Figure 7, we visualize the structures of active/inactive molecules from the anchor molecule.
We observe that in BBBP and ClinTox datasets, the activities are highly correlated to the structural similarity, i.e., the structurally similar molecules show the same activities. Therefore, as contrastive learning aims to maximize the similarity between perturbed graphs from the original graph, it fits into the BBBP and ClinTox datasets, showing better performance than predictive learning methods. However, in the Tox21 dataset, we cannot observe any clues that the activities are correlated to the structural similarity. Therefore, capturing the structural similarity with contrastive learning seems to be useless in this dataset, resulting in the better performance of predictive learning methods.
However, our D-SLA can learn the discrete embedding space by learning the discrepancy even between similar graphs, thus obtaining a discriminative space that can further be utilized to distinguish between them for downstream tasks and outperforming all other baselines as shown in Section 4.1.
[Figure]
l a m bd a _0.
[Figure]
We conduct an ablation study on link prediction and graph classification tasks in Table 5 of the main paper. For link prediction, we observe that both two components, L GD and L edit , consistently improve the performance, thus verifying that our discrepancy-based learning allows the model to capture the local semantics of graphs. Also, for graph classification, we choose the most different two datasets in their properties – ClinTox and BACE datasets – to obviously see the contribution of each component in our D-SLA.
In particular, for the ClinTox dataset in which the biochemical activities of molecules are highly correlated to their structures, we observe that it is important to discriminate the negative graphs from the perturbed graphs with the triplet margin loss L margin , as the performance improvements on using it is significant compared to the other dataset: BACE. However, in the case of the BACE dataset, since the molecules are highly similar regardless of their biochemical activities, the graph edit distance loss L edit largely contributes to the performance gain, allowing the model to learn the exact discrepancy across similar graphs. B.3 Effect of L edit Coefficient ( λ 1 ) We demonstrate the effect of the coefficient λ 1 for L edit (Equation 8).
Specifically, we show its efficacy by measuring the rank correlation coefficient, and by visualizing the graph representation space. Firstly, as shown in Figure 8, the differences in rank correlation with varying scaling coefficient λ 1 are marginal. Also, as shown in Figure 9, for all models, the perturbed graphs are well embedded along their perturbation magnitudes regardless of λ 1 values. Therefore, we suggest that, fortunately, learning the accurate amount of discrepancy between graphs does not heavily depend on the scaling hyperparameter for L edit , namely λ 1 .
On the other hand, we observe that, if λ 1 is relatively small, some negative graphs are embedded closer to the perturbed ones (Figure 9 (a)). This result indicates that, the regularization effects of our objective L edit for learning the discrepancy between the original and perturbed graphs can also affect the boundary between perturbed and negative graphs, as shown in Figure 9 (b), (c). B.4 Effect of Margin ( α ) in L margin [Table]
To demonstrate the effect of the margin α in L margin (Equation 7), we pretrain the model with varying α values and fine-tune it on BACE dataset for graph classification.
As shown in Table 8, large value of α degenerates our discrepancy learning among similar graphs.
As described in Section 3.4, if the distance between the original and its negative graph ( d ′ j ) is larger than the distance between the original and perturbed graph ( d i ) plus α (i.e., α + d i < d ′ j ), the distance between the original and perturbed graph ( d i ) is preserved not losing the discrepancy learned by L edit (Equation 6).
However, too large α makes it hard to satisfy the condition (i.e., α + d i < d ′ j ) forcing the model to lose the discrepancy learned by L edit .
B.5 Effect of L margin Coefficient ( λ 2 )
[Table]
We demonstrate the effect of the coefficient λ 2 for L margin (Equation 3) by pre-training with various λ 2 values and fine-tuning on BACE dataset for graph classification.
As shown in Table 9, when λ 2 is large, the performance on
BACE downstream dataset is generated, indicating that the model cannot learn the discrepancy among similar graphs.
We suggest that this is because λcontrols the intensity of attracting the similar graphs of L margin and a large value of λ 2 which would strongly attract the similar graphs forces the model to lose the discrepancy among similar graphs learned by L edit (Equation 6).
[Table]
[Figure]
[Figure]
B.6 Effect of Perturbation Magnitude on Link Prediction
[Table]
We validate the effect of the perturbation magnitude on the COLLAB dataset for link prediction.
As shown in Table 10, we observe that the performance of link prediction is enhanced when only a small amount of edges are perturbed, demonstrating that weaker perturbation magnitude is better for capturing local semantics.
If the perturbation magnitude is weak, the perturbed graphs are slightly different from the original graph, thus the model could capture a subtle difference across original and perturbed graphs.
B.7 Ablation Study of Attribute Masking
[Table]
We conduct an additional ablation study for the attribute masking in our perturbation strategy on the COLLAB dataset for link prediction.
As shown in Table 11, the performance without attribute masking is significantly lower than the performance with attribute masking.
We suggest that, in the pre-training stage, attribute masking limits the information given to the model and forces the model to learn more transferable and fruitful representations, demonstrating that attribute masking in our perturbation is a key factor to learn the local semantics.
B.8 Comparison with Augmentation-Free Contrastive Learning Approaches
[Table]
Recently, augmentation-free contrastive learning methods have been proposed.
We validate the effectiveness of our discrepancy learning framework by comparing with augmentation-free approaches on graph classification and link prediction tasks.
We compare our D-SLA with SimGCL [49] and SimGRACE [40] that augment views of graphs by adding noise to graph embeddings or model parameters while preserving the graph structures.
As shown in Table 12 and Table 13, our discrepancy learning outperforms the augmentation-free contrastive learning approaches, demonstrating the effectiveness of our discrepancy learning framework in capturing both local and global semantics.
We further visualize the embedding space of similar and dissimilar graphs with different distance metrics such as
Graph Edit Distance (Figure 10) and Tanimoto similarity (Figure 11).
We observe that, in SimGCL and SimGRACE, the similar and dissimilar graphs are not distinguished and the augmentation-free approaches cannot capture the exact amount of discrepancy, since they cannot learn the difference between similar graphs.
Contrarily, by our discrepancy learning, the model can distinguish similar and dissimilar graphs and learn the exact amount of discrepancy both on Graph Edit Distance and
Tanimoto Similarity.