Graph learning method and system with self-interpretation
By constructing sufficient and necessary interpreted subgraphs and using graph data enhancement methods, the problem of performance loss of self-interpretation graph learning methods in the prior art is solved, and the effect of improving prediction performance and self-interpretation is achieved.
Patent Information
- Application Number
- CN202311341509.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-16
- Publication Date
- 2025-04-18
AI Technical Summary
The existing self-interpreting graph learning methods that improve model prediction performance will often lead to performance losses and cannot effectively retain the key information in the original input graph.
By constructing sufficient and necessary interpretation subgraphs, using graph data enhancement methods to perturb the explanation, construct positive and negative sample pairs, and optimize the model through supervision losses and comparison losses to ensure that the model can obtain key information for learning.
It realizes the prediction performance and self-interpretation of the graph learning model while retaining key information, avoiding the problem of performance loss.
Smart Images

Figure CN119849586A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graph learning and interpretability, and in particular, to a graph learning method and system with self-explanatory capabilities. Background Art
[0002] Graph learning and graph neural network. Graph learning is a machine learning method that studies graph-structured data. In many practical applications, the relationship between data is often represented in the form of a graph, such as social networks, protein interaction networks, user-item relationships in recommendation systems, etc. Graph learning aims to use the structure of the graph and the relationship between nodes to infer the attributes of the nodes or perform prediction tasks. The graph learning task targeted by the present invention is node classification, that is, predicting the category of a node in the graph data. Graph neural network (GNN) is a type of neural network model for graph learning. It learns the representation of nodes by propagating and aggregating information on the graph through the graph convolution layer. Each node interacts its own features with the features of its neighboring nodes, and uses the aggregated information as the new representation of the node. Finally, the learned representation is mapped to the label space through a linear neural network (MLP) for prediction. By stacking multiple graph convolutional layers and introducing nonlinear activation functions, message passing and aggregation are iteratively performed to learn higher-order node representations. But at the same time, such stacking amplifies the black box properties of the graph neural network, and the mechanism behind its prediction is often unknown. The lack of interpretability greatly hinders the application of the graph neural network model in scenarios that require credibility and transparency.
[0003] Interpretability of graph neural networks. Interpretability methods of graph neural networks are committed to providing reasonable explanations for the predictions of graph neural networks. The explanations can be in the form of subgraphs, edge sets, node sets, or prototypes that contain important information about the original input graph. According to the time when the explanations are generated, they can be divided into post-explanation methods and self-explanation methods. Post-explanation methods provide explanations for a trained graph neural network model to help people understand the mechanism behind the model making a certain prediction or a certain type of prediction. However, since post-explanations are not directly generated by the graph neural network during training, they inevitably show bias and inconsistency. Therefore, self-explanation methods that can provide built-in explanations while outputting graph neural network predictions are gradually gaining more and more attention. A self-explanatory graph learning framework consists of an explanation generator and a graph neural network encoder. The explanation generator extracts important explanations based on the original input graph, while the graph neural network encoder converts this explanation into a representation and makes a prediction.
[0004] However, self-explanatory graph learning methods often suffer from performance loss problems. Since self-explanatory graph learning models make predictions based on explanations, the quality of the explanations has a huge impact on the model's prediction performance. A sufficient explanation hopes that the retained explanations will enable the graph neural network to make correct predictions, but it tends to retain the original input graph more completely, which may introduce potential noise; a necessary explanation hopes that the retained explanations are important enough that if it is missing a part, it will lead to prediction errors. It tends to retain a smaller part of the original input graph, resulting in the loss of key information. Therefore, an explanation that only meets sufficiency or necessity often hinders the model from making correct predictions, resulting in prediction performance loss. Summary of the invention
[0005] In view of the defects in the prior art, the purpose of the present invention is to provide a self-explanatory graph learning method, which ensures that the graph neural network model obtains key information for learning and makes correct predictions by constructing sufficient and necessary explanations.
[0006] A self-explanatory graph learning method provided by the present invention includes:
[0007] Step S1: Explanation subgraph generation: extract substructures from the original input graph as explanations;
[0008] Step S2: explanation enhancement: perturb the extracted explanations to construct positive and negative sample pairs;
[0009] Step S3: Prediction and optimization of the self-explanatory graph learning model: Take the explanation as the input of the graph neural network and make predictions, calculate the supervision loss and contrast loss, and use the two losses to optimize the model.
[0010] Preferably, in step S1:
[0011] The explanation generator h takes the original graph G as input and extracts the computational subgraph G that requires the target node v C , the L-layer graph neural network computation subgraph is a directed tree consisting of the L-hop neighbors of the target node; through the encoder Calculate G C Representation of all edges in Z; through the linear network h θ Map the representation to the importance score M of all edges on the prediction results. If the representation dimensions of each layer of the graph neural network are different, additional mapping functions are learned to map all representations to the same dimension and then calculate M;
[0012] During training, it is interpreted as In the form of M, a weight is assigned to each edge, and weighted aggregation is performed according to the weight of the edge during message transmission; after the training is completed, the subgraph G corresponding to the preset number of edges with the highest importance scores is sampled according to M S , which serves as an explanation.
[0013] Preferably, in step S2:
[0014] For the explanation subgraph G S , respectively, along the sufficient and necessary directions to enhance the data, and the enhanced contrast interpretations are positive samples and negative samples, respectively, with G S For anchor samples, the data enhancement process is as follows:
[0015] Positive Sample where n + is the number of positive samples, from G C \G S Sample edges inside and add them to G S Construct each positive sample on G S The sufficiency is less than the preset standard, close to G S The distance between each positive sample is within the preset standard, and the positive sample in Indicates adding the edge (c,v) to the explanation subgraph G S middle;
[0016] Negative samples where n - is the number of negative samples, from G S Sample edges from G S Internal deletion constructs each negative sample, if G S Necessity is less than the preset standard, pull away G S The distance between each negative sample is the preset standard, and the negative sample in Indicates that the edge (a, b) is interpreted as the subgraph G S Deleted;
[0017] G S It is in the form of discrete subgraphs. During the training process, As an explanation, right Performing data enhancement is equivalent to performing data enhancement on M; enhancing the importance score of the selected edge in the positive sample and adding the edge to G S In the process, we reduce the importance scores of the selected edges in the negative samples to the preset standard, and then S Deleted.
[0018] Preferably, additional coefficients are introduced for positive and negative samples:
[0019] Distance factor: G C It is a hierarchical tree structure centered on the target node v. The perturbation of the graph is based on the importance score M. The distance coefficient is calculated as follows:
[0020] δ + =1-α·exp(d)
[0021] δ - =α·exp(d)
[0022] where α is a positive coefficient and d is a vector where each value d (i,j) = l represents that it takes l steps for the starting point i of edge (i, j) to reach the target node v; when sampling, the distance coefficient is considered and M⊙δ is used + Or M⊙δ - Sample positive samples or negative samples respectively;
[0023] Confidence coefficient: Calculated as follows:
[0024]
[0025]
[0026] in Represents the positive sample When is the input, the predicted probability of the target node v and its true label t obtained by the predictor is the confidence of the model in correctly predicting the input sample; when using the contrast sample, it is screened according to the confidence coefficient, and η is used to represent each positive sample or negative sample in the calculation of the contrast loss. + or η - Weighted.
[0027] Preferably, in step S3:
[0028] A self-explanatory graph learning framework makes predictions based on the explanation subgraph. Given an explanation G S , the prediction output by the graph learning model is
[0029] Among them, g φ is a graph neural network encoder used to map node features of the explanation subgraph into representations, f π It is a linear neural network predictor used to map the representation of the target node to the corresponding category probability distribution;
[0030] Using loss function End-to-end training is performed for each learnable module h, g, and f, and the loss function Where γ is a manually set hyperparameter, It is the loss of supervision, is the contrast loss;
[0031] The specific calculation method is as follows:
[0032] Supervision loss:
[0033]
[0034] Where N is the number of all labeled nodes, is the model output on the tth class at node v, is the corresponding true label;
[0035] Contrastive loss of node v:
[0036]
[0037] in, To take the mean of all positive samples, g φ It is a graph neural network encoder used to map node features of the explanation subgraph into representations;
[0038] z S =f ψ (g φ (G S ))、 and They are respectively passed through the linear network f ψ After mapping G S , and characterization; τ is an adjustable positive temperature coefficient, and the contrast loss on all labeled nodes is calculated as:
[0039] A self-explanatory graph learning system provided by the present invention includes:
[0040] Module M1: Explanation subgraph generation: extracting substructures from the original input graph as explanations;
[0041] Module M2: Explanation enhancement: perturb the extracted explanations to construct positive and negative sample pairs;
[0042] Module M3: Prediction and Optimization of Self-Explanatory Graph Learning Models: Use explanations as input to graph neural networks and make predictions, calculate supervised loss and contrastive loss, and use the two losses to optimize the model.
[0043] Preferably, in the module M1:
[0044] The explanation generator h takes the original graph G as input and extracts the computational subgraph G that requires the target node v C, the L-layer graph neural network computation subgraph is a directed tree consisting of the L-hop neighbors of the target node; through the encoder Calculate G C Representation of all edges in Z; through the linear network h θ Map the representation to the importance score M of all edges on the prediction results. If the representation dimensions of each layer of the graph neural network are different, additional mapping functions are learned to map all representations to the same dimension and then calculate M;
[0045] During training, it is interpreted as In the form of m, a weight is assigned to each edge, and weighted aggregation is performed according to the weight of the edge during message transmission; after the training is completed, the subgraph G corresponding to the preset number of edges with the highest importance score is sampled according to m S , which serves as an explanation.
[0046] Preferably, in the module M2:
[0047] For the explanation subgraph G S , respectively, along the sufficient and necessary directions to enhance the data, and the enhanced contrast interpretations are positive samples and negative samples, respectively, with G S For anchor samples, the data enhancement process is as follows:
[0048] Positive Sample where n + is the number of positive samples, from G C \G S Sample edges inside and add them to G S Construct each positive sample on G S The sufficiency is less than the preset standard, close to G S The distance between each positive sample is within the preset standard, and the positive sample in Indicates adding the edge (c,v) to the explanation subgraph G S middle;
[0049] Negative samples where n - is the number of negative samples, from G S Sample edges from G S Internal deletion constructs each negative sample, if G S Necessity is less than the preset standard, pull away G S The distance between each negative sample is the preset standard, and the negative sample in Indicates that the edge (a, b) is interpreted as the subgraph G S Deleted;
[0050] G SIt is in the form of discrete subgraphs. During the training process, As an explanation, right Performing data enhancement is equivalent to performing data enhancement on M; enhancing the importance score of the selected edge in the positive sample and adding the edge to G S In the process, we reduce the importance scores of the selected edges in the negative samples to the preset standard, and then S Deleted.
[0051] Preferably, additional coefficients are introduced for positive and negative samples:
[0052] Distance factor: G C It is a hierarchical tree structure centered on the target node v. The perturbation of the graph is based on the importance score M. The distance coefficient is calculated as follows:
[0053] δ + =1-α·exp(d)
[0054] δ - =α·exp(d)
[0055] where α is a positive coefficient and d is a vector where each value d (i,j) = l represents that it takes l steps for the starting point i of edge (i, j) to reach the target node v; when sampling, the distance coefficient is considered and M⊙δ is used + Or M⊙δ - Sample positive samples or negative samples respectively;
[0056] Confidence coefficient: Calculated as follows:
[0057]
[0058]
[0059] in Represents the positive sample When is the input, the predicted probability of the target node v and its true label t obtained by the predictor is the confidence of the model in correctly predicting the input sample; when using the contrast sample, it is screened according to the confidence coefficient, and η is used to represent each positive sample or negative sample in the calculation of the contrast loss. + or η - Weighted.
[0060] Preferably, in the module M3:
[0061] A self-explanatory graph learning framework makes predictions based on the explanation subgraph. Given an explanation G S , the prediction output by the graph learning model is
[0062] Among them, g φ is a graph neural network encoder used to map node features of the explanation subgraph into representations, f π It is a linear neural network predictor used to map the representation of the target node to the corresponding category probability distribution;
[0063] Using loss function End-to-end training is performed for each learnable module h, g, and f, and the loss function Where γ is a manually set hyperparameter, It is the loss of supervision, is the contrast loss;
[0064] The specific calculation method is as follows:
[0065] Supervision loss:
[0066]
[0067] Where N is the number of all labeled nodes, is the model output on the tth class at node v, is the corresponding true label;
[0068] Contrastive loss of node v:
[0069]
[0070] in, To take the mean of all positive samples, g φ It is a graph neural network encoder used to map node features of the explanation subgraph into representations;
[0071] and They are respectively passed through the linear network f ψ After mapping G S , and characterization; τ is an adjustable positive temperature coefficient, and the contrast loss on all labeled nodes is calculated as:
[0072] Compared with the prior art, the present invention has the following beneficial effects:
[0073] 1. This invention is aimed at a general graph learning method and proposes to help improve the predictive performance and self-explanatory nature of graph learning models by learning sufficient and necessary explanations;
[0074] 2. The present invention proposes a graph data enhancement method to perturb the explanation subgraph to construct comparison samples, and uses contrast loss to help generate sufficient and necessary explanations; at the same time, it proposes a distance coefficient and a confidence coefficient to help construct a more efficient contrast learning task. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0076] Figure 1 The overall flow chart of the framework proposed for the present invention includes three steps: explanation subgraph generation, prediction, and explanation enhancement;
[0077] Figure 2 As an example of data augmentation, take an input graph G with a target node v as an example, first extract its computational subgraph G C , and then calculate the explanation subgraph G based on it S , in G S Positive and negative samples are obtained by adding or deleting edges. DETAILED DESCRIPTION
[0078] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0079] Embodiment 1:
[0080] The present invention is a general self-explanatory graph learning method that can be applied to any graph learning model based on deep learning.
[0081] The present invention proposes a new self-explanatory graph learning method. The self-explanatory graph learning method can screen out key substructures from the input graph as explanations and make predictions based on the explanations. Although the existing work of this type of method can provide explanations for the graph learning model, it has caused a certain loss in the prediction performance of the model. Because the impact of the quality of the explanation itself on the prediction performance of the model is ignored, the explanations they generate often do not meet the sufficiency or necessity, and cannot find the substructure in the original input that is most beneficial to the prediction task as an explanation. In response to these problems, the present invention proposes to construct sufficient and necessary explanations, and using such explanations as input can significantly improve the prediction performance and interpretability of the graph learning model. The present invention perturbs any explanation through graph data augmentation, uses the perturbed explanation as a positive and negative sample pair, and constructs a contrast loss based on it to guide the generated explanation to optimize in the sufficient and necessary direction; at the same time, under the guidance of the supervised loss, such a sufficient and necessary explanation can help the model make correct predictions. The method proposed by the present invention can be applied to any graph neural network encoder. It includes the following three steps: (1) explanation subgraph generation: extracting a substructure as an explanation from the original input graph; (2) explanation enhancement: perturbing the extracted explanation to construct positive and negative sample pairs; (3) prediction and optimization of the self-explanatory graph learning model: taking the explanation as the input of the graph neural network and making predictions, calculating the supervision loss and contrast loss, and using the two losses to optimize the model.
[0082] like Figure 1 As shown in the figure, the original input obtains a subgraph of the original input as an explanation through the explanation generator. This explanation subgraph is used as the input of the graph neural network model to obtain the corresponding prediction and calculate the supervision loss. At the same time, the explanation subgraph is enhanced on the graph structure and the contrast loss is calculated. Finally, the supervision loss and contrast loss are used to jointly train the entire framework. Figure 2 An example of explanation enhancement is given. The present invention adds edges to construct positive samples and trims edges to construct negative samples based on the original explanation.
[0083] A self-explanatory graph learning method provided by the present invention includes:
[0084] Step S1: Explanation subgraph generation: extract substructures from the original input graph as explanations;
[0085] Specifically, in step S1:
[0086] The explanation generator h takes the original graph G as input and extracts the computational subgraph G that requires the target node v C , the L-layer graph neural network computation subgraph is a directed tree consisting of the L-hop neighbors of the target node; through the encoder Calculate G CRepresentation of all edges in Z; through the linear network h θ Map the representation to the importance score M of all edges on the prediction results. If the representation dimensions of each layer of the graph neural network are different, additional mapping functions are learned to map all representations to the same dimension and then calculate M;
[0087] During training, it is interpreted as In the form of M, a weight is assigned to each edge, and weighted aggregation is performed according to the weight of the edge during message transmission; after the training is completed, the subgraph G corresponding to the preset number of edges with the highest importance scores is sampled according to M S , which serves as an explanation.
[0088] Step S2: explanation enhancement: perturb the extracted explanations to construct positive and negative sample pairs;
[0089] Specifically, in step S2:
[0090] For the explanation subgraph G S , respectively, along the sufficient and necessary directions to enhance the data, and the enhanced contrast interpretations are positive samples and negative samples, respectively, with G S For anchor samples, the data enhancement process is as follows:
[0091] Positive Sample where n + is the number of positive samples, from G C \G S Sample edges inside and add them to G S Construct each positive sample on G S The sufficiency is less than the preset standard, close to G S The distance between each positive sample is within the preset standard, and the positive sample in Indicates adding the edge (c,v) to the explanation subgraph G S middle;
[0092] Negative samples where n - is the number of negative samples, from G S Sample edges from G S Internal deletion constructs each negative sample, if G S Necessity is less than the preset standard, pull away G S The distance between each negative sample is the preset standard, and the negative sample in Indicates that the edge (a, b) is interpreted as the subgraph G S Deleted;
[0093] G S It is in the form of discrete subgraphs. During the training process, As an explanation, right Performing data enhancement is equivalent to performing data enhancement on M; enhancing the importance score of the selected edge in the positive sample and adding the edge to G S In the process, we reduce the importance scores of the selected edges in the negative samples to the preset standard, and then S Deleted.
[0094] Specifically, additional coefficients are introduced for positive and negative samples:
[0095] Distance factor: G C It is a hierarchical tree structure centered on the target node v. The perturbation of the graph is based on the importance score M. The distance coefficient is calculated as follows:
[0096] δ + =1-α·exp(d)
[0097] δ - =α·exp(d)
[0098] where α is a positive coefficient and d is a vector where each value d (i,j) = l represents that it takes l steps for the starting point i of edge (i, j) to reach the target node v; when sampling, the distance coefficient is considered and M⊙δ is used + Or M⊙δ - Sample positive samples or negative samples respectively;
[0099] Confidence coefficient: Calculated as follows:
[0100]
[0101]
[0102] in Represents the positive sample When is the input, the predicted probability of the target node v and its true label t obtained by the predictor is the confidence of the model in correctly predicting the input sample; when using the contrast sample, it is screened according to the confidence coefficient, and η is used to represent each positive sample or negative sample in the calculation of the contrast loss. + or η - Weighted.
[0103] Step S3: Prediction and optimization of the self-explanatory graph learning model: Take the explanation as the input of the graph neural network and make predictions, calculate the supervision loss and contrast loss, and use the two losses to optimize the model.
[0104] Specifically, in step S3:
[0105] A self-explanatory graph learning framework makes predictions based on the explanation subgraph. Given an explanation G S , the prediction output by the graph learning model is
[0106] Among them, g φ is a graph neural network encoder used to map node features of the explanation subgraph into representations, f π It is a linear neural network predictor used to map the representation of the target node to the corresponding category probability distribution;
[0107] Use the loss function L to train each learnable module h, g and f end-to-end. The loss function Where γ is a manually set hyperparameter, It is the loss of supervision, is the contrast loss;
[0108] The specific calculation method is as follows:
[0109] Supervision loss:
[0110]
[0111] Where N is the number of all labeled nodes, is the model output on the tth class at node v, is the corresponding true label;
[0112] Contrastive loss of node v:
[0113]
[0114] in, To take the mean of all positive samples, g φ It is a graph neural network encoder used to map node features of the explanation subgraph into representations;
[0115] and They are respectively passed through the linear network f ψ After mapping G S , and characterization; τ is an adjustable positive temperature coefficient, and the contrast loss on all labeled nodes is calculated as:
[0116] Embodiment 2:
[0117] Embodiment 2 is a preferred example of Embodiment 1, and is used to illustrate the present invention in more detail.
[0118] The present invention also provides a self-explanatory graph learning system, which can be implemented by executing the process steps of the self-explanatory graph learning method, that is, those skilled in the art can understand the self-explanatory graph learning method as a preferred implementation of the self-explanatory graph learning system.
[0119] The self-explanatory graph learning system provided by the present invention includes:
[0120] 1) Module M1: A learnable explanation generator, which consists of a graph neural network encoder and a linear neural network decoder to learn a subgraph from the input graph as an explanation;
[0121] 2) Module M2: Explanation Enhancer, which consists of a series of independently designed graph perturbation rules, used to perturb the graph structure of the explanation subgraph to construct positive and negative sample pairs and calculate the contrast loss;
[0122] 3) Module M3: Predictor, which consists of a graph neural network encoder and a linear neural network predictor, which is used to encode the explanation subgraph into representations and make predictions, and calculate the supervision loss.
[0123] The parameters of modules M1 and M2 are jointly updated by the supervised loss and the contrastive loss.
[0124] Specifically, in the module M1:
[0125] The explanation generator h takes the original graph G as input and extracts the computational subgraph G that requires the target node v C , the L-layer graph neural network computation subgraph is a directed tree consisting of the L-hop neighbors of the target node; through the encoder Calculate G C Representation of all edges in Z; through the linear network h θ Map the representation to the importance score M of all edges on the prediction results. If the representation dimensions of each layer of the graph neural network are different, additional mapping functions are learned to map all representations to the same dimension and then calculate M;
[0126] During training, it is interpreted as In the form of M, a weight is assigned to each edge, and weighted aggregation is performed according to the weight of the edge during message transmission; after the training is completed, the subgraph G corresponding to the preset number of edges with the highest importance scores is sampled according to M S , which serves as an explanation.
[0127] Specifically, in the module M2:
[0128] For the explanation subgraph G S, respectively, along the sufficient and necessary directions to enhance the data, and the enhanced contrast interpretations are positive samples and negative samples, respectively, with G S For anchor samples, the data enhancement process is as follows:
[0129] Positive Sample where n + is the number of positive samples, from G C \G S Sample edges inside and add them to G S Construct each positive sample on G S The sufficiency is less than the preset standard, close to G S The distance between each positive sample is within the preset standard, and the positive sample in Indicates adding the edge (c,v) to the explanation subgraph G S middle;
[0130] Negative samples where n - is the number of negative samples, from G S Sample edges from G S Internal deletion constructs each negative sample, if G S Necessity is less than the preset standard, pull away G S The distance between each negative sample is the preset standard, and the negative sample in Indicates that the edge (a, b) is interpreted as the subgraph G S Deleted in;
[0131] G S It is in the form of discrete subgraphs. During the training process, G Satt As an explanation, right Performing data enhancement is equivalent to performing data enhancement on M; enhancing the importance score of the selected edge in the positive sample and adding the edge to G S In the process, we reduce the importance scores of the selected edges in the negative samples to the preset standard, and then S Deleted.
[0132] Specifically, additional coefficients are introduced for positive and negative samples:
[0133] Distance factor: G C It is a hierarchical tree structure centered on the target node v. The perturbation of the graph is based on the importance score M. The distance coefficient is calculated as follows:
[0134] δ + =1-α·exp(d)
[0135] δ - =α·exp(d)
[0136] where α is a positive coefficient and d is a vector where each value d (i,j) = l represents that it takes l steps for the starting point i of edge (i, j) to reach the target node v; when sampling, the distance coefficient is considered and M⊙δ is used + Or M⊙δ - Sample positive samples or negative samples respectively;
[0137] Confidence coefficient: Calculated as follows:
[0138]
[0139]
[0140] in Represents the positive sample When is the input, the predicted probability of the target node v and its true label t obtained by the predictor is the confidence of the model in correctly predicting the input sample; when using the contrast sample, it is screened according to the confidence coefficient, and η is used to represent each positive sample or negative sample in the calculation of the contrast loss. + or η - Weighted.
[0141] Specifically, in the module M3:
[0142] A self-explanatory graph learning framework makes predictions based on the explanation subgraph. Given an explanation G S , the prediction output by the graph learning model is
[0143] Among them, g φ is a graph neural network encoder used to map node features of the explanation subgraph into representations, f π It is a linear neural network predictor used to map the representation of the target node to the corresponding category probability distribution;
[0144] Using loss function End-to-end training is performed for each learnable module h, g, and f, and the loss function Where γ is a manually set hyperparameter, It is the loss of supervision, is the contrast loss;
[0145] The specific calculation method is as follows:
[0146] Supervision loss:
[0147]
[0148] Where N is the number of all labeled nodes, is the model output on the tth class at node v, is the corresponding true label;
[0149] Contrastive loss of node v:
[0150]
[0151] in, To take the mean of all positive samples, g φ It is a graph neural network encoder used to map node features of the explanation subgraph into representations;
[0152] and They are respectively passed through the linear network f ψ After mapping G S , and characterization; τ is an adjustable positive temperature coefficient, and the contrast loss on all labeled nodes is calculated as:
[0153] Embodiment 3:
[0154] Embodiment 3 is a preferred example of Embodiment 1, and is used to illustrate the present invention in more detail.
[0155] Problems solved by the technology of the present invention: The purpose of the present invention is to solve the performance loss problem of a self-explanatory graph learning framework by constructing a better explanation to ensure that the graph neural network model obtains key information for learning and thus makes correct predictions.
[0156] The framework proposed by the present invention is characterized by:
[0157] (1) Mining necessary and sufficient subgraphs from the graph as explanations. The present invention points out that the explanations extracted by existing self-explanatory graph learning methods are often biased. They usually can only meet one of the sufficiency or necessity, and often lead to a decrease in model prediction performance. The present invention can extract explanations that are beneficial to the model, which meet both sufficiency and necessity, and can filter out noise information while retaining enough key information to ensure that the model makes correct predictions.
[0158] (2) Use efficient contrastive learning methods to guide the generation of sufficient and necessary explanation subgraphs. The present invention constructs positive samples by adding edges to existing explanations and constructs negative samples by deleting edges from existing explanations. The contrast loss is calculated and optimized based on the positive and negative samples, thereby guiding the generated explanations to move in a sufficient and necessary direction. Combined with the supervised loss, such sufficient and necessary explanations can ensure that the model makes correct predictions. At the same time, the present invention proposes a distance coefficient and a confidence coefficient to achieve efficient contrast tasks. The distance coefficient is used to construct more difficult positive and negative samples, thereby enhancing the contrast signal, and the confidence coefficient is used to filter out unreliable positive and negative samples, thereby ensuring the correctness of the contrastive learning task.
[0159] The present invention solves the performance loss problem of the self-explanatory graph learning framework by guiding the explanation generator to generate sufficient and necessary explanations to retain the most critical information in the original input graph. The present invention designs a data augmentation method to extract any explanation subgraph G from the original input graph G. S For example, the present invention is G S Add additional edges and use the new explanations obtained as positive samples, from G S Some edges are deleted from the image and the new explanation is used as a negative sample. The present invention calculates the contrast loss based on the representation of positive and negative samples, and uses it to guide the optimization of the explanation generator and prompt it to generate sufficient and necessary explanations. The contrast loss can bring the anchor sample G closer to the original image. S The distance between the representation and the positive sample representation, while pushing G S The distance between the representation and the negative sample representation. If G S If it does not meet the sufficiency requirement, it means that it cannot provide enough key information to make correct predictions. Then, adding positive samples constructed by edges can make up for this defect. Minimizing the contrast loss can bring G closer. S and the distance between the positive samples, so that the generated explanation is optimized in the sufficient direction. S If the necessity is not met, then the negative samples constructed by deleting the edges will not significantly change the final prediction, so G S The representation of G is very close to that of negative samples. Minimizing the contrast loss can pull G S The distance between positive and negative samples is calculated, so that the generated explanation is optimized in the necessary direction. Therefore, under the guidance of the contrast loss, the explanation generator can ensure that sufficient and necessary explanations are generated, while the supervision loss ensures that the generated explanations are beneficial to model prediction. In order to construct a more efficient contrast task, the present invention proposes a distance coefficient to construct more difficult positive and negative samples to enhance the contrast signal, and a confidence coefficient to help filter out unreliable positive and negative samples.
[0160] The solution of the present invention: Based on the idea of contrastive learning, the present invention designs a novel graph data enhancement method. The framework designed by the present invention includes the following three steps:
[0161] (1) Learnable explanation subgraph generation: The learnable explanation generator h obtains the explanation G from the input graph G S ;
[0162] (2) Contrastive explanation generation based on graph data enhancement: S Perform perturbation to obtain a set of positive and negative sample pairs and
[0163] (3) Prediction and optimization based on explanation subgraph: The graph neural network encoder g is the explanation Generate the corresponding representation and is determined by the predictor f based on Z S Output the final prediction And calculate the supervision loss Based on and Computing contrast loss Finally combined and Optimize the parameters of h, g, and f.
[0164] 1. Learnable Explanation Subgraph Generation
[0165] The explanation generator h takes the original graph G as input and first extracts the computational subgraph G that requires the target node v C (For an L-layer graph neural network, the computational subgraph is a directed tree consisting of the L-hop neighbors of the target node, such as Figure 2 G C Then through the encoder Calculate G C The representation of all edges in Z; finally through a linear network h θ The representation is mapped to the importance score M of all edges on the prediction results. Specifically, let's assume L = 2, then for G C For any directed edge (i, j) from node i to node j, its corresponding importance score m ij The calculation process is as follows:
[0166] (1) If node i is on layer 0 and node j is on layer 1, then For example Figure 2 The directed edge (e,c) in ;
[0167] (2) If node i is on the first layer and node j is on the second layer, then For example Figure 2The directed edge (c,v) in ;
[0168] in represents the representation of node i at layer 0, and || is the concatenation operation of the representations. If the representation dimensions of each layer of the graph neural network are different (for example, d (0) ≠d (1) ≠d (2) , where d (0) represents the dimension of the representation of the 0th layer node), it is necessary to additionally learn a mapping function to map all representations to the same dimension and then calculate M.
[0169] It should be noted that in order to ensure the derivability of back propagation during the training process, the present invention defines the interpretation as In the form of M, a weight is assigned to each edge, and then weighted aggregation is performed according to the weight of the edge during message transmission; after the training is completed, in order to obtain an explanation that can be understood by humans, the present invention samples the subgraphs G corresponding to the edges with the highest importance scores according to M. S , as an explanation.
[0170] 2. Comparative explanation generation based on graph data enhancement
[0171] For an explanation subgraph G S For example, the present invention performs data enhancement along the two directions of sufficiency and necessity, and regards the enhanced comparative interpretation as positive samples and negative samples respectively. S For anchor samples, the data enhancement process is as follows:
[0172] (1) Positive Sample where n + is the number of positive samples. C \G S Sample several edges and add them to G S To construct each positive sample. S Not enough, then bring G closer S The distance between and each positive sample can guide the explanation generator to produce more adequate explanations. An example of a positive sample is Figure 2 In in Indicates adding the edge (c,v) to the explanation subgraph G S middle;
[0173] (2) Negative samples where n - is the number of negative samples. S Sample several edges from G S To construct each negative sample, we delete the inner SNot necessary, then move away G S The distance between and each negative sample can guide the explanation generator to produce more necessary explanations. An example of a negative sample is Figure 2 In in Indicates that the edge (a, b) is interpreted as the subgraph G S Deleted.
[0174] It should be noted that the G mentioned here S is a discrete subgraph, and in the training process, the present invention uses As an explanation, Therefore, Performing data augmentation is equivalent to performing data augmentation on M. Enhancing the importance scores of the selected edges in the positive samples is equivalent to adding these edges to G. S In the negative sample, the importance scores of the selected edges are reduced, which is equivalent to G S Deleted.
[0175] In order to achieve more efficient comparison sample generation, the present invention introduces two additional coefficients for positive and negative samples:
[0176] (1) Distance coefficient: Constructing more difficult samples can help enhance contrast signals and thus benefit contrastive learning. C is a hierarchical tree structure centered on the target node v, and the perturbations of the graph in the present invention are all based on the importance score M. Therefore, the impact of perturbing an edge close to v on v is greater than perturbing an edge far from v. Therefore, for positive samples, if a closer edge directly related to v is added, more information is added, making it more difficult for the contrast loss to pull G closer S and the distance between the positive sample, so it is a more difficult positive sample; similarly, for the negative sample, if a farther edge is deleted, it will bring less information loss, making it more difficult to pull the contrast loss apart G S The distance between and negative samples is therefore a more difficult negative sample. Therefore, the distance coefficient is calculated as follows:
[0177] δ + =1-α·exp(d),δ - =α·exp(d)
[0178] where α is a positive coefficient and d is a vector, where each value d (i,j) = l represents that it takes l steps for the starting point i of edge (i, j) to reach the target node v. The distance coefficient needs to be considered when sampling, that is, using M⊙δ + Or M⊙δ - Sample positive samples or negative samples respectively.
[0179] (2) Confidence coefficient: Since the construction of positive and negative samples cannot be separated from edge sampling, it is inevitable that samples that do not meet expectations will be constructed, such as adding noise information as positive samples or deleting some irrelevant edges as negative samples. This will cause contrastive learning to move in the wrong direction and make the final explanation learned not meet the necessary and sufficient requirements. Therefore, the present invention combines label information with model output to filter out these unreliable samples. Specifically, the confidence coefficient is calculated as follows:
[0180]
[0181] in Represents the positive sample When is the input, the predicted probability of the target node v and its true label t obtained by the predictor represents the confidence of the model in correctly predicting the input sample. When using contrast samples, they need to be screened according to the confidence coefficient, that is, η is used to represent each positive sample or negative sample in the calculation of contrast loss. + or η - Weighted.
[0182] 3. Prediction and training loss design based on explanation subgraph
[0183] The self-explanatory graph learning framework makes predictions based on the explanation subgraph. In particular, given an explanation G S , the prediction output by the graph learning model is
[0184] This framework uses the loss function Each learnable module (i.e. h, g and f) is trained end-to-end. Loss function Where γ is a manually set hyperparameter, It is the loss of supervision, is the contrast loss. The specific calculation method is as follows:
[0185] (1) Prediction loss: The present invention uses cross entropy to calculate the prediction loss on all labeled nodes, namely: Where N is the number of all labeled nodes, is the model output on the tth class at node v, is the corresponding true label;
[0186] (2) Contrastive loss: The contrastive loss of node v is: where z S =f ψ (g φ (G S ))、 and They are respectively passed through the linear network f ψ After mapping G S , and τ is an adjustable positive temperature coefficient. Then the contrast loss on all labeled nodes can be calculated as:
[0187] Those skilled in the art know that, in addition to realizing the system and its various devices, modules, and units provided by the present invention in a purely computer-readable program code, it is entirely possible to realize the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered as a hardware component, and the devices, modules, and units included therein for realizing various functions can also be regarded as structures within the hardware component; the devices, modules, and units for realizing various functions can also be regarded as both software modules for realizing the method and structures within the hardware component.
[0188] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A self-explanatory graph learning method, characterized in that: include: Step S1: Explanation subgraph generation: extract substructures from the original input graph as explanations; Step S2: explanation enhancement: perturb the extracted explanations to construct positive and negative sample pairs; Step S3: Prediction and optimization of the self-explanatory graph learning model: Take the explanation as the input of the graph neural network and make predictions, calculate the supervision loss and contrast loss, and use the two losses to optimize the model.
2. The self-explanatory graph learning method according to claim 1, characterized in that: In step S1: The explanation generator h takes the original graph G as input and extracts the computational subgraph G that requires the target node v C , the L-layer graph neural network computation subgraph is a directed tree consisting of the L-hop neighbors of the target node; through the encoder Calculate G C The representation of all edges in Z; through the linear network h θ Map the representation to the importance score M of all edges on the prediction results. If the representation dimensions of each layer of the graph neural network are different, additional mapping functions are learned to map all representations to the same dimension and then calculate M; During training, it is interpreted as In the form of M, a weight is assigned to each edge, and weighted aggregation is performed according to the weight of the edge during message transmission; after the training is completed, the subgraph G corresponding to the preset number of edges with the highest importance scores is sampled according to M S , which serves as an explanation.
3. The self-explanatory graph learning method according to claim 1, characterized in that: In step S2: For the explanation subgraph G S , respectively, along the sufficient and necessary directions to enhance the data, and the enhanced contrast interpretations are positive samples and negative samples, respectively, with G S For anchor samples, the data enhancement process is as follows: Positive Sample where n + is the number of positive samples, from G C \G S Sample edges inside and add them to G S Construct each positive sample on G S The sufficiency is less than the preset standard, close to G S The distance between each positive sample is within the preset standard, and the positive sample in Indicates adding the edge (c,v) to the explanation subgraph G S middle; Negative samples Where n - is the number of negative samples, from G S Sample edges from G S Internal deletion constructs each negative sample, if G S Necessity is less than the preset standard, pull away G S The distance between each negative sample is the preset standard, and the negative sample in Indicates that the edge (a, b) is interpreted as the subgraph G S Deleted in; G S It is in the form of discrete subgraphs. During the training process, As an explanation, right Performing data enhancement is equivalent to performing data enhancement on M; enhancing the importance score of the selected edge in the positive sample and adding the edge to G S In the process, we reduce the importance scores of the selected edges in the negative samples to the preset standard, and then S Deleted.
4. The self-explanatory graph learning method according to claim 3, characterized in that: Additional coefficients are introduced for positive and negative samples: Distance factor: G C It is a hierarchical tree structure centered on the target node v. The perturbation of the graph is based on the importance score M. The distance coefficient is calculated as follows: d + =1-α·exp(d) d - =α·exp(d) where α is a positive coefficient and d is a vector where each value d (i,j) = l represents that it takes l steps for the starting point i of edge (i, j) to reach the target node v; when sampling, the distance coefficient is considered and M⊙δ is used + Or M⊙δ - Sample positive samples or negative samples respectively; Confidence coefficient: Calculated as follows: in Represents the positive sample When is the input, the predicted probability of the target node v and its true label t obtained by the predictor is the confidence of the model in correctly predicting the input sample; when using the contrast sample, it is screened according to the confidence coefficient, and η is used to represent each positive sample or negative sample in the calculation of the contrast loss. + or η - Weighted.
5. The self-explanatory graph learning method according to claim 1, characterized in that: In step S3: A self-explanatory graph learning framework makes predictions based on the explanation subgraph. Given an explanation G S , the prediction output by the graph learning model is Among them, g φ is a graph neural network encoder used to map node features of the explanation subgraph into representations, f π It is a linear neural network predictor used to map the representation of the target node to the corresponding category probability distribution; Using loss function End-to-end training is performed for each learnable module h, g, and f, and the loss function Where γ is a manually set hyperparameter, It is the loss of supervision, is the contrast loss; The specific calculation method is as follows: Supervision loss: Where N is the number of all labeled nodes, is the model output on the tth class at node v, is the corresponding true label; Contrastive loss of node v: in, To take the mean of all positive samples, g φ It is a graph neural network encoder used to map node features of the explanation subgraph into representations; z S =f ψ (g φ (G S ))、 and They are respectively passed through the linear network f ψ After mapping G S , and characterization; τ is an adjustable positive temperature coefficient, and the contrast loss on all labeled nodes is calculated as:
6. A self-explanatory graph learning system, characterized in that: include: Module M1: Explanation subgraph generation: extracting substructures from the original input graph as explanations; Module M2: Explanation enhancement: perturb the extracted explanations to construct positive and negative sample pairs; Module M3: Prediction and Optimization of Self-Explanatory Graph Learning Models: Use explanations as input to graph neural networks and make predictions, calculate supervised loss and contrastive loss, and use the two losses to optimize the model.
7. The self-explanatory graph learning system according to claim 6, characterized in that: In the module M1: Explanation generator h takes the original graph G as input and extracts the computational subgraph G that requires the target node v C , the L-layer graph neural network computation subgraph is a directed tree consisting of the L-hop neighbors of the target node; through the encoder Calculate G C Representation of all edges in Z; through the linear network h θ Map the representation to the importance score M of all edges on the prediction results. If the representation dimensions of each layer of the graph neural network are different, additional mapping functions are learned to map all representations to the same dimension and then calculate M; During training, it is interpreted as In the form of M, a weight is assigned to each edge, and weighted aggregation is performed according to the weight of the edge during message transmission; after the training is completed, the subgraph G corresponding to the preset number of edges with the highest importance scores is sampled according to M S , which serves as an explanation.
8. The self-explanatory graph learning system according to claim 6, characterized in that: In the module M2: For the explanation subgraph G S , respectively, along the sufficient and necessary directions to enhance the data, and the enhanced contrast interpretations are positive samples and negative samples, respectively, with G S For anchor samples, the data enhancement process is as follows: Positive Sample where n + is the number of positive samples, from G C \G S Sample edges inside and add them to G S Construct each positive sample on G S The sufficiency is less than the preset standard, close to G S The distance between each positive sample is within the preset standard, and the positive sample in Indicates adding the edge (c,v) to the explanation subgraph G S middle; Negative samples Where n - is the number of negative samples, from G S Sample edges from G S Internal deletion constructs each negative sample, if G S Necessity is less than the preset standard, pull away G S The distance between each negative sample is the preset standard, and the negative sample in Indicates that the edge (a, b) is interpreted as the subgraph G S Deleted in; G S It is in the form of discrete subgraphs. During the training process, As an explanation, right Performing data enhancement is equivalent to performing data enhancement on M; enhancing the importance score of the selected edge in the positive sample and adding the edge to G S In the process, we reduce the importance scores of the selected edges in the negative samples to the preset standard, and then S Deleted.
9. The self-explanatory graph learning system according to claim 8, characterized in that: Additional coefficients are introduced for positive and negative samples: Distance factor: G C It is a hierarchical tree structure centered on the target node v. The perturbation of the graph is based on the importance score M. The distance coefficient is calculated as follows: d + =1-α·exp(d) d - =α·exp(d) where α is a positive coefficient and d is a vector where each value d (i,j) = l represents that it takes l steps for the starting point i of edge (i, j) to reach the target node v; when sampling, the distance coefficient is considered and M⊙δ is used + Or M⊙δ - Sample positive samples or negative samples respectively; Confidence coefficient: Calculated as follows: in Represents the positive sample When is the input, the predicted probability of the target node v and its true label t obtained by the predictor is the confidence of the model in correctly predicting the input sample; when using the contrast sample, it is screened according to the confidence coefficient, and η is used to represent each positive sample or negative sample in the calculation of the contrast loss. + or η - Weighted.
10. The self-explanatory graph learning system according to claim 6, characterized in that: In the module M3: A self-explanatory graph learning framework makes predictions based on the explanation subgraph. Given an explanation G S , the prediction output by the graph learning model is Among them, g φ is a graph neural network encoder used to map node features of the explanation subgraph into representations, f π It is a linear neural network predictor used to map the representation of the target node to the corresponding category probability distribution; Use the loss function L to train each learnable module h, g and f end-to-end. The loss function Where γ is a manually set hyperparameter, It is the loss of supervision, is the contrast loss; The specific calculation method is as follows: Supervision loss: Where N is the number of all labeled nodes, is the model output on the tth class at node v, is the corresponding true label; Contrastive loss of node v: in, To take the mean of all positive samples, g φ It is a graph neural network encoder used to map node features of the explanation subgraph into representations; z S =f ψ (g φ (G S ))、 and They are respectively passed through the linear network f ψ After mapping G S , and characterization; τ is an adjustable positive temperature coefficient, and the contrast loss on all labeled nodes is calculated as:
Citation Information
Patent Citations
Graph classification training method based on supervised comparative learning and structure inference
CN115481682A