Towards Debiased Learning and Out-of-Distribution Detection for Graph Data
Anonymous Author(s)
AffiliationAddress email
Abstract
Despite the remarkable success of graph neural networks (GNNs) for graph representation learning, they are generally built on the (unreliable) i.i.d.
assumptionacross training and testing data.
However, real-world graph data are universallycomprised of outliers in training set and out-of-distribution (OOD) testing samplesfrom unseen domains, which solicits effective models for i) debiased learning andii)
OOD detection, towards trustworthy general purpose.
In this paper, we firstmathematically formulate the two challenging problems for graph data and takean initiative on tackling them under a unified probabilistic model.
Specifically,we model the graph generative process to characterize the distribution shifts ofgraph data together with an additionally introduced latent environment variable asan indicator.
We then define a variational distribution, i.e., a recognition model,to infer the environment during training of GNN.
By instantiating the generativemodels as two-component mixtures, we derive a tractable learning objective andtheoretically justify that the model can i) automatically identify and down-weightoutliers in the training procedure, and ii) induce an effective OOD detector fromthe recognition model.
Experiments on diverse datasets with different types of
OOD data prove that our model consistently outperforms strong baselines for bothdebiasing and OOD detection tasks.
Our code will be made public when published.
Introduction
For processing ubiquitous graph data, graph neural networks (GNNs) [18, 41] have emerged aseffective approaches for graph representation learning [12], which in turn has spanned a wide rangeof applications, from drug discovery [23] to image classification [4].
Despite their success, existing GNNs are generally built on the assumption that both training andtesting data are independently sampled from the identical distribution (i.i d.), which often doesnot hold [43, 44].
Real-world training data is often shown universally mixed with outliers [29, 7] which specifically may incur large gradient steps in the wrong direction [36], or be overfitted by themodel [3], thereby hurting models’ performance.
Besides, testing samples from unseen domainsare also unavoidable when the model is deployed in the wild [2, 20], which may easily be classifiedinto a wrong class with a high probability [13].
Inevitably, graph data also involve these twocommon problems.
As illustrated in Fig.
1, we indeed find that vanilla GNNs perform poorly whenencountering large portion of outliers and out-of-distribution (OOD) testing samples, which solicitseffective models for i) debiased learning and ii)
OOD detection, towards general trustworthy purpose.
However, these two problems still remain largely unexplored for graph data.
Generally, identifyinggraph outliers (or OOD samples) is inherently hard as the non-Euclidean graph data can own a largenumber of node features and additional structural knowledge.
The bias may exist in certain nodefeatures, local and global graph structures, as well as the underlying relations between features,
[Figure]
F r e qu e n c y F r e qu e n c y
[Figure]
We argue that training outliers and OOD testing samples can be conceptually unified as they bothrepresent data drawn from distributions other than the major in-distribution (ID) part of training data.
However, they are inherently different as the training outliers also catch label-related distributionshifts, e.g. noisy labels [1], while OOD testing samples are solely determined by their features [14].
This fundamental difference is also the reason why most of existing works tend to tackle these twoproblems independently.
In light of the intrinsic connection between these two types of data, we present GraphDE, a probabilistic generative framework for Graph DE biased learning and OOD DE tection.
Specifically,we model the generative process to characterize the distribution shifts of graph data, along withan environment variable as an indicator.
Utilizing variational inference [47], we propose to inferthe environment variable during the training procedure of GNN.
Our framework consists of threemodules: the recognition model that infers the environment variable based on the input graph data; thestructure estimation model by which we extract an OOD detector on testing dataset; the classificationmodel which is our target GNN.
Following the idea of data resampling [36, 35], we model the lattertwo modules by two-component mixtures, with one component for ID data, and the other componentrobustifying the model by isolating outliers.
Based on this, we derive a tractable learning objectivefor our model and theoretically justify our model’s effectiveness for the target tasks.
The main contributions of this paper are as follows:
• We focus on two critical but largely unexplored problems for graph data: debiased learning andOOD detection, find their fundamental correlations and define them under a probabilistic framework.
• We propose GraphDE with a novel learning objective and theoretically justify that: 1) it canidentify and down-weight outliers during training; 2) it can provide an OOD detector on the testingset; 3) its constituent modules are optimized in a mutually-promoting manner.• We evaluate GraphDE with different GNN backbones on diverse datasets of different OOD types,where GraphDE achieves consistent performance improvements over the baselines.
Specifically, asshown in Fig.
1, for the debiasing task, it yields up to 14.6% accuracy improvement on SPMotif; forthe OOD detection task, it outperforms the strongest baseline by 18.4% on MNIST-75sp.
Problem Formulation and Related Works
In typical graph learning problems, given a set of labeled graphs D tr = { ( G i , y i ) } N tr i =1 , we need totrain a model f θ : G → ˆ y to predict the labels on the testing dataset D te = { G i } N te i =1 .
Specifically, aninput graph G =
( A, X ) contains two-fold information: an adjacency matrix A
= { a vu | v, u ∈ V }and node features X
= { x v | v ∈ V } where V denotes the node set.
We define G as a random variableof input graphs and y as a random variable of graph labels. Then the data-generating process can becharacterized as p ( G , y | e )
= p ( G | e ) p ( y | G , e ) where we introduce a latent variable of environmente as a potential unknown indicator for data from particular distributions.
The biased data (we use the form interchangeable to outliers) in the training set and out-of-distribution(OOD) data in the testing set can both be treated as data drawn from different distributions to thedistribution generating the majority of the training set and testing data of our interests, i.e., thein-distribution (ID) data so-called.
Hence, we can model them by a binary environment variable e ,with e = 1 denoting the ID portion and e = 0 for the biased/OOD portion.
Then the training andtesting datasets can be split into D tr = D trin ∪ D trout and D te =
D tein ∪ D teout accordingly.
Note thati) the partitions of training/testing data are only for illustration purpose and are strictly unknown inpractice; ii) the testing data and distribution are also strictly unknown during the training process; iii)here e is mainly used for distinguishing the ID part with the OOD counterpart of datasets.
In fact, the
OOD part ( e = 0 ) may consist of data from multiple distributions.
Denote the loss on sample ( G, y ) by L ( y, f θ ( G )) , e.g., cross-entropy loss for classification problems.
Then the standard empirical risk minimization (ERM) objective can be written as
[Equation]
This objective works based on the i.i.d.
assumption across training and testing data.
As we aim atpromoting the ID test accuracy (i.e. the performance on D tein ), however, the updating gradient bytraining data drawn from p ( G , y | e = 0) will hurt model performance drastically [3].
On the otherhand, for testing data from unseen distributions D teout , the model would incline to produce impreciseresults as p tr ( e ) ̸
= p te out ( e ) , which is undesired and should be avoided for the trustworthy purpose.
We next formulate the two problems of our interests.
Task I: Debiased learning from training data.
The target is to mitigate outliers’ negative effectsduring training, thereby enhancing the performance on ID testing data.
We modify the ERM objective:
[Equation]
where L ( y, f θ ( G ) | e ) = (cid:26) L ( y, f θ ( G )) , if e = 1 ,
L 0 , if e = 0 .
[Equation]
2) where the loss function for biased training data is fixed as L 0 , so the debiasing objective is equivalentto minimize E ( G,y ) ∼ p ( G , y | e =1)
[ L ( y, f θ ( G ))] , i.e., the training loss for the ID portion D trin .
Task II: OOD detection for testing data.
We aim to obtain an OOD detector g composed of atrained model f
θ : G → ˆ y , a scoring function s and a threshold τ :
[Equation]
As we are willing to induce an OOD detector during the training procedure of GraphDE, we leveragethe trained model f θ from task
I and what we need is to find the optimal score function s ∗ that canbest separate out ID and OOD data (e.g. maximize the AUROC).
Related works on debiased learning.
A series of strategies have been proposed to debias the trainingdataset in general machine learning [36, 5] and computer vision [29, 7].
Many works propose topreprocess the dataset by filtering out the outliers [5, 25].
However, these methods cannot capturelabel-related distribution variations such as noisy labels [1] and also cannot be easily adapted to dealwith graph data.
Another popular strategy is data resampling [36, 35], which relies on the trainingloss to identify and down-weight outliers in the training set.
However, these methods only capturebias in the mapping from features to labels, but ignore the variation in feature space.
For the firsttime to our best knowledge, we formally define and deal with the graph debiased learning problem.
Related works on OOD detection.
A trustworthy learning system should not only produce accuratepredictions for ID data, but also distinguish and reject OOD examples without further prediction.
Deep learning based OOD detection has achieved promising progress in vision [27, 13].
Besides,node and edge-level anomaly detection on graphs are also widely studied, some of which are based onclassical network science [26], while others utilize the power of GNNs [34, 9].
In comparison, only limited works [49] attempt to solve graph-level OOD detection.
Specifically, OCGIN [49] designsa one-class GNN objective to distinguish between ID and OOD data.
However, OCGIN needs to be trained individually for the detection task.
In this paper, we extract an OOD detector during thetraining procedure of the target GNN, while outperforming OCGIN on 7 out of 9 benchmarks.
[Figure]
OOD: inferred e
[Figure]
mutually
[Figure]
Generative Models infer infer
ID:
OOD:
ID:
OOD: computed = + +
Recognition Model 𝑝 - (𝑦|𝐴,𝑋) 𝑝 - (𝑒|𝐴,𝑋)
[Figure]
Stage
[Figure]
Methodology
3.1 Probabilistic Generative Learning for Debiased Learning and OOD Detection
To improve the ID test accuracy, we want to make the model more robust by automatically identifyingpotential outliers during training.
Thus, we take a generative perspective on the graph data and adoptvariational inference to infer the environment variable during training.
Generative process.
We model the joint distribution p ( X , y , A , e ) to capture graph-level distributionshifts.
In line with the homophily principle from random graph theory [31], i.e., linking probabilitydepends on some inherent properties of nodes, we assume that the graph structure is generatedbased on the node features and the environment variable.
The graph labels are then generated basedon the graph structure, node features, and the environment.
We also assume p ( e ) and p ( X ) to beindependent distributions for environments and node features, respectively.
We do not specify theform of p ( X ) , since everything will be conditioned on X in this paper, similar to [28, 42].
We have:
[Equation]
where the generative models p ( A | X , e ) and p ( y | X , A , e ) could be modeled by some flexible parametric distributions p θ ( A | X , e ) and p θ ( y | X , A , e ) with parameter θ .
These two distributions willlater be instantiated as the structure estimation model and classification model, respectively.
Wedefine the generative models with two-component mixtures.
For example, p θ ( X | A , e ) is composedof an ID component p θ ( A | X ) , and an OOD component p
( A | X ) (the subscript 0 implies a fixeddistribution).
The environment variable e ∈ { 0 , 1 } indicates whether the graph should be modeled bythe ID ( e = 1 ) or the OOD ( e = 0 ) component.
Specifically, these two terms are decomposed as:
[Equation]
Recognition Model.
As the variables X , A and y are all observed during training, what we need isto infer the sample-wise environment variable e conditional on these observed variables.
Thus, weresort to variational inference [47] and introduce a recognition model q ϕ ( e | A , X , y ) parameterizedwith ϕ to approximate the true posterior p θ ( e | A , X , y ) .
Learning Objective.
We train the model parameters θ and ϕ by optimizing the Evidence Lower
BOund (ELBO) of the observed data tuple ( A, X, y ) :
[Equation]
Eq.
6 shows that by maximizing the ELBO, we are maximizing the log-likelihood of observed datalog p θ ( A, y | X ) while minimizing the KL divergence between the recognition model and the true posterior p θ ( e | A, X, y ) .
Finally, the learning objective for the training dataset can be written as:
[Equation]
[Figure]
[Equation]
Justification of GraphDE.
We provide theoretical analysis here to reveal the rationale of GraphDE.
Without loss of generality, we do not take account into the KL loss here for simplicity.
The proofs ofthe propositions are postponed to Appendix A.
Proposition 1. 1)
The learning objective for GraphDE is in a re-weighted form when q ϕ ( e | A , X , y )is instantiated as a Bernoulli distribution, with q ϕ ( e i
= 1 | A
i , X i , y i ) acting as a weight for the i -thsample; 2) Given the ideal recognition model q ∗ ϕ ( e | A , X , y ) that predicts ID data with probability 1and outliers as 0, the generative models can learn to best fit the ID data.
Prop. 1 reveals how the inferred posterior takes effect on the learning objective.
Typically, ifq ϕ ( e | A , X , y ) can assign a higher probability to ID data, our model can thereby learn to ignore thenegative effects of biased training data and better fit the target distribution (i.e. ID).
Proposition 2. 1)
Assuming the generative models p θ ( A | X ) and p θ ( y | A , X ) can better predict
ID data than the outliers, i.e. assign higher loss to outliers, the recognition model q ϕ ( e | A , X , y )can learn to assign higher probability for ID data;
2) Given optimal generative models that bestfit ID data, assuming p ∗ θ ( y | A , X ) and p ∗ θ ( A | X ) perform randomly on the outliers, there exists arecognition model that achieves the minimal objective while ideally predict the environment variable.
Prop. 2 proves GraphDE’s effectiveness from the recognition model’s perspective.
To summarize, theabove two propositions show that q ϕ ( e | A , X , y ) , p θ ( y | A , X ) and p θ ( A | X ) can mutually promoteeach other during training.
As deep networks tend to learn simple shared (i.e. ID) patterns first [3],this positive feedback can guide GraphDE to identify outliers in early epochs and thereby learn betterrepresentations of ID data.
Besides, the propositions also suggest that given either of the recognitionmodel or the generative model optimal, the other can be trained to be optimal, which suggests theexistence of the global optimum.
Based on these, we can further understand the implications of thethree loss terms in Eq.
7: i) L cl is the re-weighted version of the original classification loss; ii) L regacts as graph regularization and will impact the gradient of q ϕ ( e | A , X , y ) , weighting ID data higherthan the outliers; iii) the third term L kl is the KL divergence between the learned posterior and thefixed prior distribution, ensuring the posterior not go too complex.
Inference on testing dataset.
For new data, we need to infer the posterior marginal distribution of eand y given ( A , X ) , i.e. p θ ( e | A , X ) and p θ ( y | A , X ) , respectively.
To compute p θ ( e | A , X ) is justto
do OOD detection .
For binary e , we can compute its posterior analytically:
[Equation]
The posterior can be used as the score function s for the OOD detector, once we have the well-trainedp
θ ( A | X , e ) .
Subsequently, we can calculate p θ ( y | A , X ) by the total probability theorem:
[Equation]
where p θ ( y | A , X , e ) can also be obtained after training.
3.2 GraphDE Instantiations
We proceed to specify the distributions p θ ( A | X , e ) , p θ ( y | X , A , e ) , p ( e ) and q ϕ ( e | A , X , y ) .
Weassume p ( e ) =
α ∈ [0 , 1] represents our prior belief about the cleanliness of the training dataset,while a higher α implies a larger portion of ID data in D tr .
It is fixed as a scalar during training.
3.2.1 Instantiations of the Recognition Model
We propose two variants for the recognition model q ϕ ( e | A , X , y ) .
In the first way, we directly assigna learnable scalar for each sample in the training dataset, i.e., q ϕ ( e i | A i , X i , y i )
= α i ∈ [0 , 1] , whereα i is a trainable parameter jointly optimized with the generative models through the ELBO in Eq.
We call this variant GraphDE-v(ariational) as we optimize directly over α i .
In the second way, noticethat e is a binary variable by definition, we can compute the posterior analytically by
[Equation]
[Equation] We call this variant GraphDE-a(nalytical) and the optimization procedure in this setting is essentiallyan EM algorithm [30]: in the E-step, we evaluate the posterior distribution of the latent variable e by
Eq. 10; in the M-step, we optimize the model parameters θ using gradient descent w.r.t.
the objectivein Eq.
In comparison to GraphDE-v, the KL-divergence between q ϕ ( e | A , X , y ) and p θ ( e | A , X , y )is minimized to zero in the E-step, thus it can give a tight approximation log p θ ( A, y | X ) =
L ELBO .
3.2.2 Instantiations of the Structure Estimation Model
Recall that p θ ( A | X , e ) is defined by a two-component mixture (Eq. 5), we need to specify p θ ( A | X )and p
( A | X ) separately for the structure estimation model.
We follow the common practice andassume that the edges are conditionally independent [28].
Then the conditional probability of A canbe further factorized as p θ ( A | X ) =
(cid:81) v,u ∈ V p
θ ( a vu | X ) .
We next consider two versions for p θ ( a vu | X ) .
First, we adopt the latent space models (LSM)
[15]where the probability of a vu only depends on the representations of nodes v and u :
[Equation]
Eq.
11 can be viewed as a logistic regression model where σ ( · ) denotes the Sigmoid function, U is alinear transformation matrix, and w is a learnable vector.
Second, we propose a variant of LSM referred as CosLSM which utilizes the cosine similarityfunction to measure the similarity between the node representation pair ( x v , x u ) :
[Equation]
where we harness multi-head [40] linear transformations { U i } mi =1 for better capacity.
Note that if wetrain the structure estimation model completely based on the observed edges, the model will yieldtrivial solutions which predict all edges’ probabilities as 1.
To avoid this issue, we randomly sampleone disconnected node pair labeled as a vu = 0 for each existing edge during training.
Finally, for p 0 ( a | X ) , we simply fix it as p 0 ( a vu = 1 | X ) = 1 / 2 .
Although more complex distributionscan be used for improving the capacity, our experiment results empirically show that this simpledistribution is enough for a wide range of debiasing and detection tasks on graphs.
3.2.3 Instantiations of the Classification Model
We next specify p θ ( y | A , X ) and p 0 ( y | A , X ) for the classification model.
Similar to the structureestimation model, we fix p
( y | A , X ) =
K − 1 where K denotes the total number of classes.
Typically,a GNN takes ( A , X ) as input and outputs the probability of y .
So for p θ ( y | A , X ) , we adopt twotypes of GNN models: the global pooling models [18, 41] and hierarchical pooling models [21, 19].
Denote node v ’s neighborhoods by N v , specifically, common GNN convolutional layers executerecursive feature propagation along G :
[Equation]
13) where W ( l ) denotes weight matrix in the l -th layer and AGG ( l ) is a permutation-invariant functionthat aggregates node representations.
In hierarchical pooling GNNs, each convolutional layer isfollowed by a pooling layer to filter out nodes for the next convolution operation:
[Equation]
where idx is the selected node indices obtained by operations such as selecting the top- k score(calculated by a learnable function) nodes.
Finally, for both types of GNNs, a global pooling layer(e.g.
max or mean operation over node features) is adopted to extract a graph-level representation hto be fed into the classifier Φ whose probability is obtained by an output softmax layer:p
θ ( y | A , X ) =
Softmax (Φ( h )) , h = GlobalPool ( X ( n ) ) , (15) where n denotes the total number of convolutional layers.
Experiments
In this section, we conduct extensive experiments to answer the following questions:
• Q1:
How effective is GraphDE in debiased learning and OOD detection?
• Q2:
How do the composed modules and hyperparameters impact GraphDE’s performance?
Besides,how does GraphDE take effect during the training procedure?
4.1 Experiment Setup
Datasets.
One synthetic and three real-world datasets of different OOD types are used for debiasingand OOD detection tasks.
Here we briefly introduce them, leaving details of statistics to Appendix E
• Spurious-Motif [46] (SPMotif) is a synthetic dataset in which each graph is composed of one base(denoted by S ) and one motif (denoted by C ).
The graph label y is solely determined by the motifC .
To simulate distribution shifts, we manually construct spurious correlations between S and y .We use two datasets with different spurious correlations to denote ID and OOD data, respectively.
This dataset is unsuitable for typical OOD detection task, as the distribution shift is dominated bylabel information, opposed to that the OOD detectors focus on detecting input graphs with abnormalstructures or node features.
• MNIST-75sp [19] converts the MNIST images into super-pixelgraphs with at most 75 nodes.
For OOD data, we add Gaussian noise to node features to simulatedistribution shift.
• Collab [45] is a social network derived from 3 public collaboration datasets.
Weuse the graph size to simulate distribution shift, with graphs of no more
than 45 nodes denoted as IDwhile those of more than 90 nodes are treated as OOD data.
• DrugOOD [16] aims to benchmarkthe OOD generalization performance in the field of AI-aided drug discovery.
We use the provideddataset curator to generate a dataset with different scaffolds , and treat the largest 6000 molecules as
ID data, the smallest 5000 molecules as OOD data.
GNN backbones.
We adopt two types of GNN backbones for debiasing and OOD detection tasks.•
Global pooling backbones.
We adopt two popular GNNs: GCN [18] and GAT [41].
To extractthe global graph representation for graph classification, we use a global mean pooling or globalmax pooling layer after the GNNs to summarize the node representations.
• Hierarchical poolingbackbones.
This architecture is comprised of blocks each of which consists of a graph convolutionallayer and a pooling layer.
Typically, TopKPool [19] selects local parts of input graph for propagationby a learnable score function; SAGPool [21] uses the self-attention mechanism to calculate attentionscores, and retain important nodes for propagation.
Debiasing settings.
For the debiasing task, we mix the training set with certain ratio of outliers andcompare models’ performance on ID testing data.
We evaluate GraphDE’s debiasing performance onthe four datasets.
Besides, As far as we know, there are little existing studies concerning debiasedlearning on graph data.
For demonstrating the empirical superiority of our approach, we adopttwo recently proposed methods that claim to enhance the general-purpose robustness of GNNs ascompetitors: 2 : DropEdge [37] randomly removes a number of edges from the input graph in eachtraining epoch, and GRAND [11] uses a random propagation strategy to perform graph augmentation.
We study the negative effect of outliers by varying the biased ratio ( |D trout | / |D tr | ) of training data.
OOD detection settings.
We evaluate GraphDE’s OOD detection performance on three real-worlddatasets (with equal number of ID and OOD testing samples), using three widely used metrics [14]:area under the receiver operating characteristic curve ( AUROC ), area under the precision-recall curve( AUPR ), and the false positive rate at 95% true positive rate ( FPR95 ).
Besides, we consider threetypes of baselines: first, we use the backbones’ max softmax score (MSP) [13] as a vanilla baseline;second, we adopt two-stage graph kernel baselines in [49] (specifically, we adopt WL [38] and
PK [32] kernels, LOF [5] and OCSVM [6] detectors); finally, we use OCGIN [49] as a deep learningbased detection baseline.
[Figure]
[Table]
We report the mean and standard deviation for all the detectors, except the two-stage models, which are invariant to different random seeds.
We use the GraphDE-a variant as the OOD detector
[Table]
4.2 Main Results (Q1)
We train and evaluate each model under the settings as described in the last section (more hyperparameter and training/testing details in Appendix D)
[Table]
All the experiments are run over 5 different randomseeds.
More experimental results can be found in Appendix F.
We make the following observations:
Debiasing results.
Tab. 1 reports GraphDE’s debiasing performance on SPMotif.
In this setting, wetreat the robust GNN baselines and two variants of our GraphDE as plug-in modules and apply themto all the four backbones for comparison.
The results show that GraphDE consistently (for all thebackbones) outperforms the baselines by a large margin along with low variance.
Specifically, forthe TopKPool backbone, GraphDE-a surpasses the backbone by 10.11% and the strongest baseline(GRAND) by 5.29%.
Such improvements strongly suggest that GraphDE can achieve better debiasingperformance for various backbones.
Besides, the results also show that the GraphDE-a generallyoutperforms GraphDE-v, as the EM algorithm can give a tight approximation for the log-likelihood.
Fig.
3 illustrates GraphDE’s performance on three real-world datasets.
In this setting, we mainly studythe debiasing performance w.r.t.
different biased ratios, so the backbone for robust GNN baselines and
GraphDE are all fixed as GAT.
As shown in the figure, GraphDE consistently outperforms baselineson the three datasets for all the biased ratios.
The backbones’ performance drops drastically as thebiased ratio gets higher, and the robust GNN baselines can mitigate this effect to some extend.
Incomparison, GraphDE performs much more stable.
This advantage is more pronounced when thebiased ratio is large, e.g. GraphDE surpasses all the other baselines by nearly 5% on Collab when thebiased ratio is 0.2.
An interesting observation is that GraphDE can also achieve a better test accuracywhen the biased ratio is 0, implying that the pure training set also violates the i.i.d.
assumption.
Detection results.
Tab. 2 reports GraphDE’s detection performance on three real-world datasets.
Ascan be seen from the table, the max softmax score (MSP) achieves low detection performance.
Itsuggests that vanilla GNNs are poorly calibrated [33] and it is of critical need to develop new graphlevel OOD detectors.
The results show that GraphDE performs the best on 7 out of 9 benchmarks.
Specifically, on MNIST-75sp, GraphDE surpasses the strongest baseline by approximately 20% for
AUROC and AUPR, while also pulls down the false positive rate (FPR95).
[Figure] [Figure]
4.3 Further Study (Q2)
Impact of prior ratio.
We select different prior ratios 1 − p ( e ) to study its impact on debiasingperformance.
As shown in the Fig. 4(a), the ID test accuracy doesn’t fluctuate much from 0.05 to 0.7,but drops drastically when prior ratio goes higher than 0.7.
Besides, we also find that the test accuracypeaks at prior ratio 0.1 for biased ratio 0.
[Figure]
and 0.2 for biased ratio 0.2, exactly when L kl becomes 0.
Ablation on L reg .
We remove L reg in the objective to study the structure estimation model’s impacton debiasing performance.
As illustrated in Fig. 4(b), we can find that the test accuracy dropsobviously at all biased ratios.
Specifically, The test accuracy drops over 6% at biased ratio 0.25.
Theresults prove the structure estimation model’s capability of down-weighting outliers in training data.
Ablation on L cls .
We remove L cls to study the influence of the classification model on the OODdetection performance.
As shown in Fig. 4(c), we plot the detection AUROC on the testing datasetw.r.t.
different biased ratios.
The figure illustrates that the AUROC generally drops as the biasedratio gets higher, since the outliers will hurt the fitting performance of the structure estimation model.
Typically, we can see that the blue line (without L cls ) is consistently lower than the red line, with thegap getting larger as the biased ratio goes higher.
Specifically, the performance gap is approximately3% when biased ratio is 0.3.
The results prove that the classification model can help down-weighttraining outliers, thereby promoting the detection performance of the structure estimation model.
Training procedure.
We plot GraphDE’s test accuracy after every training epoch on ID and OOD(i.i.d.
to training outliers) datasets.
As shown in Fig.
5(a), the ID test accuracy simply fluctuates, rises,and converges.
In comparison, the trend of OOD test accuracy can be divided into two phases.
Asseparated by the green dashed line, we can see the red line first increases then decreases.
Generally,in the increasing phase, GraphDE is optimized to better fit the outliers in the training data.
However,in the decreasing phase, as the outliers are down-weighted by a large extend, GraphDE focuses onfitting ID data.
This transition prevents overfitting of outliers and promotes the ID test accuracy.
Visualization of inferred probability.
We visualize the recognition model’s inferred probabilityq ϕ
( e = 1 | A, X, y ) on the training dataset.
As shown in Fig.
5(b), ID data is assigned with a higherprobability on both datasets.
In particular, most outliers are assigned with probability at around 0 on
SPMotif.
This directly indicates that the outliers are down-weighted during the training procedure.
Conclusion and Outlook
We focus on debiased learning and OOD detection over graph data.
Specifically, we model thegenerative process to capture distribution shifts of graph data.
Through introducing a variationalrecognition model to infer the environment variable and two-component mixed generative models,we derive the learning objective for GraphDE, which can identify and down-weight outliers duringtraining, as well as inducing an effective OOD detector on new data.
While our framework is mainlydesigned for graph data where both the debiased learning and OOD detection remain under-explored,it can be generalized to other data formats like images or texts, which we leave for future studies.
Checklist
For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s
contributions and scope?
[Yes]
(b) Did you describe the limitations of your work?
[Yes] See Appendix G.
(c) Did you discuss any potential negative societal impacts of your work?
[Yes] SeeAppendix H.
(d) Have you read the ethics review guidelines and ensured that your paper conforms to
them?
[Yes]
If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results?
[Yes]
(b) Did you include complete proofs of all theoretical results?
[Yes] See Appendix A.
If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experi-
mental results (either in the supplemental material or as a URL)?
[Yes] See Appendix Efor dataset information.
See the supplementary for the codes.
They will be released
public upon publication.
(b) Did you specify all the training details (e
g., data splits, hyperparameters,
how they
were chosen)?
[Yes] See Appendix D and Appendix E.
(c) Did you report error bars (e
g., with respect to the random seed after running experi-
ments multiple times)?
[Yes] See experiment section.
(d) Did you include the total amount of compute and the type of resources used (e
g., type
of GPUs, internal cluster, or cloud provider)?
[Yes] See Appendix D.
If you are using existing assets (e
g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators?
[Yes] See Appendix E.
(b) Did you mention the license of the assets?
[N/A]
(c) Did you include any new assets either in the supplemental material or as a URL?
[N/A]
) Did you discuss whether and how consent was obtained from people whose data you’re
using/curating?
[N/A]
(e) Did you discuss whether the data you are using/curating contains personally identifiable
information or offensive content?
[N/A]
If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if
applicable?
[N/A]
Did you describe any potential participant risks, with links to Institutional Review
Board (IRB) approvals, if applicable?
[N/A]
) Did you include the estimated hourly wage paid to participants and the total amount
spent on participant compensation?
[N/A]
A Proof for Technical Results
A.1 Derivation of the Learning Objective
Since Eq.
7 is just the unfolding form of Eq.
6, we will give the derivation of Eq.
6 in this section.
Consider the KL divergence between q ϕ ( e | A, X, y ) and p θ ( e | A, X, y ) :
[Equation]
KL
[Equation]
ϕ
[Equation]
e
[Equation]
A, X, y
[Equation]
|
[Equation]
, X, y )]
[Equation] [Equation]
Simply move the terms and we can yield:
[Equation]
which is consistent with Eq. 6.
A.2 Proof for Proposition 1
We prove the two sub-propositions separately.
Proof for 1).
For one Bernoulli distribution p ( x ) =
Bernoulli ( x | α ) , we have E p ( x ) [ x ] = α .
Thus,when q ϕ ( e | A , X , y ) is instantiated as a Bernoulli distribution, we have:
[Equation]
We can tell that L cl is just in the re-weighted form, with q ϕ ( e i =
| A
i , X i , y i ) acting as a weight forthe i -th sample.
The deduction is also suitable for L reg .
Proof for 2).
Suppose we know the ground truth environments e i for each training sample, as we aregiven the ideal recognition model, Eq.
18 can be further written as:
[Equation]
For the optimization objective, we can ignore the second term as p 0 ( y | X , A ) is a fixed distribution,thus we have:
[Equation]
where G i =
( A i , X i ) .
As we can see, optimizing over Eq.
20 is just to minimize the empirical loss 506 E ( G,y ) ∼ p
( G , y | e =1) [ L ( y, f θ ( G ))] , which is consistent with the debiased learning objective in Eq. 2.
As the objective gives full weight to ID data while isolating the outliers (which bring wrong gradients),the classification model can learn to best fit the ID data.
The proof for the structure estimation modelis just the same.
A.3 Proof for Proposition
We prove the two sub-propositions separately.
Proof for 1).
Using L cl as an example, following Eq.
18, we can calculate its gradient on the i -thsample:
[Equation]
We optimize on ϕ to minimize L cl , i.e. maximize −L cl .
As we have assumed that the classificationmodel p θ ( y | A , X ) will assign higher loss to outliers, we have:
[Equation]
e i = 1 , e j =
[Equation]
22) so we can yield that:
[Equation] [Equation]
To maximize −L cl , in this sense, the recognition model will generally learn to assign higher weightfor ID data ( e i = 1 ) than the outliers ( e j = 0 ).
The proof for the structure estimation model is justthe same.
Proof for 2).
Suppose we are given the optimal generative models p ∗ θ ( y | A , X ) and p ∗ θ ( A | X ) thatbest fit ID data while performing randomly on the outliers, using p ∗ θ ( y | A , X ) as an example, wehave:
[Equation]
where K is the number of target classes.
As we have instantiated in Sec. 3.2 that p 0 ( y | A , X ) =
K − 1 ,we have:
[Equation]
so the recognition model can assign probability 0 to all outliers as they don’t impact the return loss.
In comparison, for the ID data, we have:
[Equation]
the inequality is induced based on that the ideal classification model must predict better than random.
Thus, the objective is minimized when the recognition model predicts with probability 1 for all IDdata.
In conclusion, there exists a recognition model that achieves the minimal objective while ideallypredict the environment variable.
B More Related Works
Graph neural networks.
GNNs [18, 41] are increasingly attracting attention in recent years becauseof their notable success in graph representation learning [12].
They generally utilize a messagepassing paradigm, which combines node features and graph structure to update node embeddings.
Aseries of GNNs have been proposed to achieve state-of-the-art performance on various graph tasks,including node classification [18], link prediction [24], and graph classification [48, 10].
Despitetheir great success, existing works usually pose the i.i.d.
assumption across training and testing data.
Therefore, GNNs’ performance may degenerate by a large extend when the training dataset is mixedwith outliers drawn from other distributions [3].
Besides, incorrect predictions can also be madebecause of distribution shifts on testing dataset.
Thus, it’s critical to develop methods to boost GNNs’robustness to outliers as well as detect OOD samples on testing dataset.
Trustworthy GNNs.
With widespread utilization of GNNs, their trustwothiness has raised publicconcern these days.
Previous works have shown that GNNs are vulnerable to simple perturbations [50,
39] on graph structures and node attributes.
Therefore, a series of works are proposed to promote
GNNs’ robustness to adversarial attacks through methods like data augmentation [11] and structurelearning [17, 8].
Besides, the OOD generalization capability of GNNs, either at node-level [43] orgraph-level [22, 44], are increasingly drawing attention recently.
We emphasize that our work isorthogonal to them for that: first, we are not focusing on the adversarial robustness, but robustness tooutliers, which are drawn from other distributions and should be filtered out during training; second,we are trying to detect and reject OOD samples rather than promote GNNs’ generalization capability.
C GraphDE Training Procedure
Using GraphDE-a as an example, its training procedure is summarized in Alg. 1.
Algorithm 1: The training procedure of GraphDE-a.
D Implementation Details
We present our implementation details here for reproducibility.
Our model and all the baselines areimplemented with Python3.8, PyTorch 1.8 and PyTorch Geometric 2.0.
All experiments are run on a
Tesla V100.
We choose GCN [18], GAT [41], TopKPool [19] and SAGPool [21] as our backbone models, whoseimplementation is provided by the original papers.
For robust GNN baselines DropEdge [37] and
GRAND [11], we also refer to their official implementations.
Specifically, we use GAT as thebackbone for our model and baselines, except on SPMotif, which we have tried all the backbones.
D.1 Details for Debiasing Experiments
Classification model architectures.
For debiased learning experiments, the baseline models GCN,
GAT, TopKPool, SAGPool are implemented in the following manner:
• For GCN and GAT, we use two GNN layers with hidden size 64 by default.
TopKPool and SAGPool
are comprised of two blocks, each of which consists of one GIN layer and one pooling layer.
• For DrugOOD and MNIST, we use the global mean pool to extract the graph-level representation,while on Collab and SPMotif, the global max pool is adopted.
• We use two MLP layers with hidden size 64 after the global pooling layer for graph classification.•
The activation function is ReLU.
Structure estimation model architectures
• For SPMotif and Collab, we use LSM as the structure estimation model.
The transformation matrixU ’s output size is 64.
• For MNIST-75sp and DrugOOD, we utilize CosLSM as the structure estimation model.
Thetransformation matrix U
i ’s output size is 64.
We use 4 heads by default.
• The activation function is ReLU.
Training Details.
We use mini-batch gradient descent to optimize our model and the baselines.
Moreconcretely, we use the cross entropy loss (or negative log likelihood) and the Adam optimizer isadopted for optimization.
The total training epoch number is fixed at 400.
We use early stopping of20 epochs.
Testing Details.
We report the ID test accuracy achieved by the epoch that gives the highest accuracyon validation dataset.
Hyperparameters.
We adopt grid search to tune the hyperparameters.
The learning rate is searchedwithin { 0 . 1 , 0 . 01 , 0 .
001 , 0 . 0001 } , dropout is searched within { 0 . 0 , 0 . 1 , 0 . 5 } .
Specifically, the hyperparameters are set as follows.
• For GCN and GAT, the learning rate is 0.01 and the batch size is 64.
No dropout is used.
For
dataset MNIST and DrugOOD, batchnorm is used.
• For SAGPool and TopKPool, the min score is set to 0.001, i.e. nodes with scores higher than 0.001will be selected for propagation.
• The dropedge rate is chosen within { 0 . 1 , 0 . 2 , 0 . 3 , 0 . 4 , 0 . 5 } .
• For GRAND, the propagation order is chosen within { 1 , 2 , 3 , 4 , 5 } , while the dropnode rate is
chosen within { 0 . 05 , 0 . 1 , 0 . 3 , 0 . 5 } .•
For our model, the hyperparameters are set as default.
D.2 Details for Detection Experiments
Architectures.
For detection experiments, our model GraphDE is implemented in the same manneras in the debiasing setting.
Training Details.
For MSP and our model GraphDE, the OOD detector is extracted from the trainedmodel, i.e. the training paradigm is the same as in the debiasing setting.
The two-stage graph kernelbaselines don’t require training.
For OCGIN, we adopt its modified one-class objective and train for60 epochs with Adam optimizer.
Testing Details We feed equal amounts of ID and OOD data into the trained model and calculatethe three metrics: AUROC, AUPR, and FPR95 to evaluate the OOD detection performance of ourmodel.
Area under the receiver operating characteristic curve(AUROC) can be considered as theprobability that an outlier is assigned a higher OOD score than an ID sample, so a higher AUROCscore is better.
Area under the precision-recall curve(AUPR) is a useful performance metric forimbalanced data, which takes into account the base rate of outliers.
FPR95 is the false positive rate of
OOD examples when the true positive rate for ID examples is 95%, which represents performance atone strict threshold.
Hyperparameters.
The biased ratio is set as 30% for fair comparison.
For the two-stage graphkernel baselines, the kernel is chosen within {PK [32], WL [38]}, while the detector is chosen within{OCSVM [6], LOF [5]}.
• For OCGIN, we adopt 3 GIN layers with hidden size 64.
The learning rate is set as 0.001.
We donot use weight decay or dropout.
• For graph kernels, the WL iteration number is set as 5, the bin width of PK is set as 0.1.• For LOF, the leaf number and the number of neighbors is set as 30 and 20.•
For our model, the hyperparameters are set as default.
E Dataset Information
We present detailed information for our used datasets concerning the data collection, preprocessing,and statistic information.
An overview of the datasets is represented in Tab. 3.
[Table]
E.1 Dataset Information
[Table]
Synthetic dataset.
SPMotif is a synthetic dataset in which each graph is composed of one base(denoted by S = 0 , 1 , 2 ) and one motif (denoted by C = 0 , 1 , 2 ).
The graph label y is solelydetermined by the motif C .
We manually construct spurious correlations between the base S andlabel y to simulate distribution shifts.
Concretely, we sample each motif from a uniform distribution,while the distribution of its base is determined by:
[Equation]
if
[Equation]
C, (
[Equation]
b ) / 2 , otherwise.
We change the mapping relationship to create different spurious correlations to simulate distributionshift, namely, the distribution of S in OOD dataset is:
P ( S ) = (cid:26) b, if S ≡ C + 1( mod 3) , (1 − b ) / 2 , otherwise.
The ratio b is set as 0.9 for both ID and OOD datasets.
We employ 9000 training graphs, 3000validation graphs, and 6000 ID and OOD testing graphs.
Real-world datasets.
We adopt three real-world datasets MNIST-75sp, Collab and DrugOOD toevaluate our model.
• MNIST-75sp is converted from the original dataset MNIST, each image of which depicts a handwritten digit from 0 to 9.
The converted super-pixel graphs have at most 75 nodes, with nodefeatures set as super-pixel coordinates and intensity, while edges are the spatial distance betweenthe nodes.
We add Gaussian noise N (0 , 0 . 45) to node features to simulate distribution shifts in theOOD dataset.
The number of graphs used in the training and validation datasets are 3000 and 1000,and we use 2000 ID and OOD testing datasets.•
Collab is a scientific-collaboration dataset consisting of 5000 researchers’ ego network.
Each noderepresents a researcher, and the edge represents the collaboration.
We use the graph size to simulatedistribution shift, with graphs of no more than 45 nodes denoted as ID while those of more than 90nodes are treated as OOD data.
Specifically, We use 1000 samples for training, 300 samples forvalidation, and 500 ID graphs and 500 OOD graphs as testing samples.• DrugOOD is a systematic OOD dataset curator and benchmark for drug discovery, providinglarge-scale, realistic, and diverse datasets for graph OOD learning problems.
The OOD propertylies in the scaffold difference.
Specifically, we utilize the provided built-in configuration file,namely, lbap_general_ic50_scaffold.py to generate the dataset.
The number of graphs used intraining and validation are 1000 and 500.
Besides, 500 ID and 500 out-of-distribution graphs areused in testing.
To maximize the OOD effect, we choose graphs of largest scaffolds in the IDdataset, while OOD dataset consists of graphs with smallest scaffolds.
E.2 Dataset Preprocessing
All the datasets we use in the experiment are directly collected from the source except DrugOOD,which is generated by ourselves with the help of the provided dataset curator.
Besides, the nodefeatures of SPMotif are set as 4-dimensional uniform random features.
As Collab is originallycomprised of plain graphs without node features,
we
[Table]
F More Experiment Results
[Figure]
F.1 Detection Results
[Figure]
Tab. 4 reports GraphDE’s detection performance on the synthetic dataset SPMotif.
As is presented inthe table, all the models, including the max softmax score(MSP), two-stage kernel methods, OCGIN,and GraphDE, have a poor performance.
Despite the fact that GraphDE performs the best on 2 out of3 benchmarks, it only provides a slight improvement, which is due to the properties of the dataset.
More concretely, this dataset is unsuitable for OOD detection since the distribution shift is dominatedby the label information, opposed to that the OOD detectors focus on detecting input graphs withabnormal structures or node features.
Fig.6 demonstrates the detection performance of GraphDE-a. As is shown in the figure, the ID data isassigned with a higher score on Collab and DrugOOD, while OOD data tends to get a relatively lowscore.
However, the OOD score distributions of ID and OOD data are almost the same on SPMotif,which is consistent with the results in Tab. 4.
F.2 Further Study
We supplement extra experimental results on DrugOOD to support GraphDE’s effectiveness.
Impact of prior ratio.
Like that in Sec.
4.3, we tune and study the impact of prior ratio p ( e ) in the
KL loss L kl .
As can be seen from Fig 7(a) , the debiasing performance doesn’t fluctuate much from0.05 to 0.8, while it drops dramatically when the prior ratio goes higher than 0.8.
In addition, the test
AUROC peaks at 0.1 for biased ratio 0.1, and 0.2 for biased ratio 0.2, exactly when L kl becomes 0,proving the validity of the KL loss.
Ablation study.
To study the effect of the structure regularization loss L reg , we remove L reg in theobjective and plot Fig 7(b).
The figure clearly shows the sharp decline in all biased ratios.
Especially,the test AUROC undergoes a descent by nearly 5% when the biased ratio is 15%.
All of these verify
[Figure]
Prior [Figure] UR O C
[Figure]
Biased Ratio
[Figure]
UR
O C
[Figure]
the feasibility of structure estimation model to help discriminate and down-weight outliers in
G Limitations
Currently, our framework cannot readily incorporate vectorized data like images or texts.
Besides,more complex model instantiations may be developed to achieve better debiasing and OOD detectionperformance on graph data, which we leave for future work.
H Potential Negative Impacts
As far as we are concerned, we have not identified any negative social impact of this work.