A Graph Neural Network Explanation Method for Preserving Prediction Order and Structural Dependencies
By optimizing the mask generator in the graph neural network interpretation method to ensure the sequential consistency of predicted results and the retention of structural dependencies, the problem of incomplete interpretation results in the existing methods is solved, and more accurate and reliable interpretation results are achieved.
Patent Information
- Application Number
- CN202210884170.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-25
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-07-25
AI Technical Summary
The existing graph neural network interpretation methods fail to effectively maintain the sequential consistency of the predicted results and consider the structural dependencies in the graph data, resulting in incomplete interpretation results.
By designing a new graph neural network interpretation method, masking the original graph data is masked using a mask generator, and the mask generator is optimized to ensure the sequential consistency of the prediction results and the retention of structural dependencies.
The accurate interpretation of the prediction results of graph neural networks is achieved, ensuring the completeness and reliability of the interpretation results, and improving the accuracy and credibility of the interpretation results.
Smart Images

Figure CN115169521B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of neural network interpretation, and particularly relates to a graph neural network interpretation method that preserves prediction order and structural dependency relationships. Background Art
[0002] In real life, there are many graph data, including social networks, knowledge graphs, and protein interaction networks, etc. Graph neural networks (GNNs) generalize deep neural networks to graphs and learn the representation of graphs in a continuous embedding space for downstream tasks. Due to the excellent ability of GNNs in representing graph data, it has shown excellent performance in tasks such as link prediction, graph classification, and node classification.
[0003] As a generalization of deep neural networks, GNNs are stacked in multiple layers and use non-linear activation functions to construct models. Although the complex design architecture ensures its powerful graph representation ability, it also has the problem of being unexplainable. The GNN model does not design a clear objective function for explaining its prediction behavior and only optimizes parameters in an end-to-end manner. Therefore, GNNs often act as a black box. Due to its unexplainable patterns, the fairness and credibility of the GNN model cannot be guaranteed, thus affecting the wide application of GNNs in key applications.
[0004] For this reason, many scholars have begun to study the interpretability of graph neural networks. These methods explain a given specific instance by determining the subgraph (subset of features / structures) that contributes the most to the prediction of the GNN. Existing perturbation-based graph neural network interpretation methods use a mask generator to generate explanations in the form of edge subsets. Among them, when the original graph and the generated subgraph are input into the model to be explained, the optimization of the mask generator is guided by the difference in the results. The key to this type of method lies in two points: the first is to design an objective function for evaluating the difference in prediction results when using the original graph and the generated graph as inputs. The second is to design a powerful mask generator that can determine which edges should be masked or retained. However, the existing research methods do not consider the order consistency problem of prediction results when designing the objective function, and do not consider the key feature of structural dependency existing in graph data when designing the mask generator, so the interpretation results cannot form a complete subgraph. Summary of the Invention
[0005] Aiming at the deficiencies of the existing technology, the present invention proposes a graph neural network interpretation method that preserves prediction order and structural dependency relationships, and the method includes:
[0006] S1: Obtain the original graph data, input the original graph data into the graph neural network model to be explained, and obtain the original prediction result; wherein, the original graph data is a graph classification data for sentiment analysis, each graph is a sentence, each node in the graph is a word, and the edge is the relationship between words;
[0007] S2: Use a mask generator to mask the original graph data to obtain a masked subgraph;
[0008] S3: Input the masked subgraph into the graph neural network model to be explained to obtain a masked prediction result;
[0009] S4: Calculate the total loss according to the original prediction result and the masked prediction result;
[0010] S5: Optimize the mask generator according to the total loss, and repeat steps S2 - S4 until the optimal mask generator is obtained;
[0011] S6: Use the optimal mask generator to mask the original graph data to obtain a masked subgraph, which is the explanation of the original prediction result.
[0012] Preferably, the process of using a mask generator to mask the original graph data includes:
[0013] S21: Convert the nodes of the original graph into the edges of the new graph, convert the edges of the original graph into the nodes of the new graph, and establish edges between the nodes with data flow in the new graph;
[0014] S22: Input the new graph into the graph attention network model for processing to obtain a latent variable;
[0015] S23: According to the latent variable, use the reparameterization trick of the discrete distribution to calculate the importance score of each edge, and mask the edges of the original graph according to the importance score of the edge to obtain a masked subgraph.
[0016] Preferably, the formula for obtaining the latent variable is:
[0017]
[0018] wherein, Ω represents the set of latent variables, represents the mask generator network model, represents the adjacency matrix of the new graph; represents the node features of the new graph, represents the parameters of the mask generator.
[0019] Furthermore, the formula for calculating the importance score of each edge is:
[0020] m pq = C(ω i, ∈, τ2) = σ((log ∈ - log(1 - ∈) + ω i ) / τ2)
[0021] Where m pq represents the importance score of the edge e connected by the masked node p and the node q i , ω i represents the i-th latent variable in the set of latent variables, ∈ represents the first parameter, and τ2 represents the second hyperparameter.
[0022] Preferably, the process of calculating the total loss includes:
[0023] S41: Calculate the inverse sorting matrix of the predicted result after masking, and adjust the order of the original predicted result according to the inverse sorting matrix;
[0024] S42: Input the result of the adjusted original prediction into the Plackett-Luce model to calculate the sorting loss;
[0025] S43: Calculate the value difference loss between the original predicted result and the predicted result after masking;
[0026] S44: Obtain the masking matrix according to the importance score of each edge, and calculate the first-order norm of the masking matrix;
[0027] S45: Calculate the total loss according to the sorting loss, the value difference loss, and the first-order norm of the masking matrix.
[0028] Furthermore, the formula for calculating the inverse sorting matrix is:
[0029]
[0030] Where represents the i-th row of the inverse sorting matrix, softmax() represents the normalized exponential function, represents the predicted result after masking, represents the predicted result is the absolute value of the difference between pairwise probability values in the prediction result, i represents the i-th row of the matrix, 1 is a column vector of all 1s, τ1 is the temperature parameter, and n represents the number of nodes in a graph.
[0031] Furthermore, the formula for adjusting the order of the original predicted result is:
[0032]
[0033] Where represents the result of the adjusted original prediction Y, represents the inverse sorting matrix, and Y represents the original predicted result.
[0034] Furthermore, the formula for calculating the ranking loss is:
[0035]
[0036] where L PL represents the ranking loss, represents the value at the i-th position of the result after reordering the original prediction Y. of the i-th position.
[0037] Furthermore, the formula for calculating the value difference loss is:
[0038] L diff = ||f(A, X, W) - f(M⊙A, X, W)||1
[0039] where L diff represents the value difference loss, f(A, X, W) represents the prediction result obtained by inputting the original graph data into the graph neural network model, and f(M⊙A, X, W) represents the prediction result obtained by inputting the masked original graph data into the graph neural network model.
[0040] Furthermore, the formula for calculating the total loss is:
[0041]
[0042] where represents the total loss, L PL represents the ranking loss, L diff represents the value difference loss, L M represents the first-order norm of the mask matrix.
[0043] The beneficial effects of the present invention are as follows: By optimizing the mask generator, the present invention processes the original graph data with the optimized mask generator to obtain the interpretation result of the original graph data; compared with the prior art, the present invention considers the order consistency between the original prediction result and the prediction result after masking, as well as the dependency relationship between the edges in the original graph data, can accurately extract the input subgraph that is important for the classification result, has a high accuracy and good reliability for the interpretation result of the original graph data; solves the problem that the current perturbation-based graph neural network interpretation method does not consider the order consistency between the original prediction result and the prediction result after masking, and does not explicitly consider the dependency relationship between the edges, and has high practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is the flowchart of the graph neural network interpretation method for maintaining prediction order and structural dependency relationship in the present invention;
[0045] Figure 2 is the framework diagram of the graph neural network interpretation method for maintaining prediction order and structural dependency relationship in the present invention;
[0046] Figure 3 Schematic diagram of the original graph data of a sentence in the present invention;
[0047] Figure 4 Schematic diagram of the process of converting the original graph to a new graph in the present invention;
[0048] Figure 5 Schematic diagram of the process of calculating the sorting loss in the present invention. Detailed implementation manners
[0049] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0050] The present invention proposes a graph neural network interpretation method that maintains prediction order and structural dependencies, as Figure 1 , Figure 2 shown, the method includes:
[0051] S1: Obtain the original graph data, input the original graph data into the graph neural network model to be explained, and obtain the original prediction result.
[0052] Obtain the original graph data. The original graph data is a graph classification data for sentiment analysis. Each graph is a sentence. Each node in the graph is a word, and the edge is the relationship between words; input the original graph data into the graph neural network to be explained, and the original prediction result can be obtained. The original prediction result is the probability that the current graph is classified into each category, that is, which sentiment the sentence belongs to. For example Figure 3 shown, Figure 3 is the original graph data of the sentence "they're translating sarah palin's book to cruderepresentations of totalitarianism with Marmaduke as a protagonist.RESPRCT!".
[0053] S2: Use a mask generator to mask the original graph data to obtain the masked subgraph.
[0054] S21: Convert the nodes of the original graph into the edges of the new graph, convert the edges of the original graph into the nodes of the new graph, and establish edges between the nodes with data flow in the new graph.
[0055] As Figure 4As shown, the original graph is on the far left and the converted new graph is on the far right. First, convert the edges e0, e1, e2, and e3 in the original graph into nodes in the new graph. Second, the edges e2 and e0 in the original graph share the node v1, and the edges e2 and e0 form a chained structure with data flow. Therefore, an edge v1 is established between e2 and e0 in the new graph. Conversely, the edges e1 and e2 in the original graph share the node v2, but they form a non-data-flow branching structure. Therefore, no edge is established between e1 and e2 in the new graph.
[0056] S22: Input the new graph into the Graph Attention Network (GAT) model to obtain the latent variable Ω.
[0057] Input the converted new graph into the Graph Attention Network (GAT) model. After passing through the Relu activation function and the Softmax layer, the latent variable Ω can be obtained. The formula for calculating the latent variable is:
[0058]
[0059] where Ω represents the set of latent variables, represents the mask generator network model, represents the adjacency matrix of the new graph; represents the node features of the new graph, represents the parameters of the mask generator.
[0060] S23: According to the latent variable, use the reparameterization trick of the discrete distribution to calculate the importance score of each edge. Mask the edges of the original graph according to the importance score of the edge to obtain the masked subgraph.
[0061] The formula for calculating the importance score of each edge is:
[0062] m pq = C(ω i , ∈, τ2) = σ((log ∈ - log(1 - ∈) + ω i ) / τ2)
[0063] where m pq represents the importance score of the edge e i connected by the mask nodes p and q, ω i ∈Ω represents the output value of the i-th latent variable in the set of latent variables, that is, the output value of the mask generator; ∈ represents the first hyperparameter, τ2 represents the second hyperparameter, and ∈~Uniform(0,1), τ2 ∈ [0,2].
[0064] According to the importance score of the edge, the mask matrix M can be obtained. m pq is the element in the p-th row and q-th column of the mask matrix M. Mask the edges of the original graph through the mask matrix to obtain the masked subgraph.
[0065] S3: Input the masked sub-graph into the graph neural network model to be explained to obtain the masked prediction result.
[0066] S4: Calculate the total loss based on the original prediction result and the masked prediction result.
[0067] S41: Calculate the inverse sorting matrix of the masked prediction result, and adjust the order of the original prediction result according to the inverse sorting matrix.
[0068] As Figure 5 shown, use the Neuralsort (neural network sorting) algorithm to calculate the inverse sorting matrix of the masked prediction result. The formula is:
[0069]
[0070] where represents the i-th row of the inverse sorting matrix, softmax() represents the normalized exponential function, represents the masked prediction result, represents the prediction result is the absolute value of the difference between pairwise probability values in i represents the i-th row of the matrix, 1 is a column vector of all 1s, τ1 is the temperature parameter, and n represents the number of nodes in a graph.
[0071] When τ1 → 0 + ,
[0072]
[0073] where represents the position index sorted in reverse order, is the value at the i-th position.
[0074] The formula for adjusting the order of the original prediction result using the sorting matrix is:
[0075]
[0076] where represents the result after adjusting the order of the original prediction Y, represents the inverse sorting matrix, and Y represents the original prediction result.
[0077] S42: Input the result after adjusting the order of the original prediction Y into the Plackett-Luce model to calculate the sorting loss.
[0078] The Plackett-Luce model is a probability distribution model that describes the ranking probability distribution. The Plackett-Luce model divides the process of solving the ranking probability into multiple stages. In each stage, the probability that each model parameter is the best in the current stage ranking is solved, and the best model parameter in the current stage is selected according to the probability. Then it enters the next stage to continue the selection until all stages are completed, and each stage is independent of each other and does not affect each other.
[0079] The formula for calculating the ranking loss is:
[0080]
[0081] where L PL represents the ranking loss, represents the value of the i-th position after the original prediction Y is reordered. of the result.
[0082] S43: Calculate the value difference loss between the original prediction result and the masked prediction result.
[0083] The formula for calculating the value difference loss is:
[0084] L diff = ||f(A, X, W) - f(M⊙A, X, W)||1
[0085] where L diff represents the value difference loss, f(A, X, W) represents the prediction result obtained by inputting the original graph data into the graph neural network model, and f(M⊙A, X, W) represents the prediction result obtained by inputting the masked original graph data into the graph neural network model.
[0086] S44: Obtain the mask matrix according to the importance score of each edge, that is, the importance score matrix of the edges. In order to use as few important edges as possible as the explanation result, the mask matrix must be as sparse as possible. Therefore, calculate the first-order norm of the mask matrix and use it as the constraint condition for the mask sparsity; the formula for calculating the first-order norm of the mask matrix is:
[0087] L M = ||M||1
[0088] where L M represents the first-order norm of the mask matrix M, M represents the mask matrix, and the element in its p-th row and q-th column is the importance score m pq .
[0089] S45: Calculate the total loss according to the ranking loss, the value difference loss, and the first-order norm of the mask matrix.
[0090] The total loss can be obtained by summing the ranking loss, the value difference loss, and the first norm of the mask matrix. The calculation formula is as follows:
[0091]
[0092] Among them, represents the total loss, L PL represents the ranking loss, L diff represents the value difference loss, L M represents the first norm of the mask matrix.
[0093] The ranking loss adopted in the present invention can ensure that the order of the original prediction result Y (including the probability of each category predicted for the input graph) and the masked prediction result (including the probability of each category predicted for the masked input graph) remains consistent. The value difference loss can ensure that the probabilities of the corresponding categories of the two prediction results are the same, so that the prediction probabilities of each category in the prediction results before and after masking can be ensured to be the same. The prior art can only ensure that the original prediction probability of the input graph being predicted to the correct category and the masked prediction probability are the same, that is, only the prediction probability of one of the categories in the prediction result can be ensured to be the same, and the other categories are not necessarily the same. Therefore, using the loss function of the present invention to optimize the mask generator to interpret the original graph data can ensure the consistency of the prediction probabilities of each category in the prediction results before and after masking, so as to more accurately simulate the prediction behavior of the original model and make the interpretation result more accurate.
[0094] S5: Optimize the mask generator according to the total loss, and repeat steps S2 to S4 until the optimal mask generator is obtained.
[0095] Set the number of iterations T, repeat steps S2 to S4, and backpropagate the total loss. Update the mask generator parameters according to the total loss to optimize the mask generator. When the number of iterations reaches T, stop the execution. At this time, the optimal mask generator is obtained.
[0096] S6: Mask the original graph data using the optimal mask generator to obtain the masked subgraph, which is the interpretation of the original prediction result.
[0097] For example, as Figure 3 shown, the darker part "translating palin's book to crude representations" in the figure is the masked subgraph. That is to say, it is considered that this part of the content is an important reason for classifying this sentence as a negative sentiment category, which is the interpretation of the classification result of the graph neural network model; for sentiment analysis, the present invention can analyze the performance of the sentiment classification model by obtaining the interpretation result of the sentiment analysis model, which is beneficial to adjusting the model parameters to obtain a more accurate sentiment analysis result.
[0098] It should be noted that those of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.
[0099] The above embodiments further elaborate on the purpose, technical solutions, and advantages of the present invention. It should be understood that the above embodiments are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made to the present invention within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for interpreting a graph neural network that preserves prediction order and structural dependencies, characterized in that Including: S1: Obtain the original graph data, input the original graph data into the graph neural network model to be explained, and obtain the original prediction result; wherein, the original graph data is a graph classification data for sentiment analysis, each graph is a sentence, each node in the graph is a word, and the edge is the relationship between words. S2: Use a mask generator to mask the original graph data to obtain a masked subgraph. S3: Input the masked subgraph into the graph neural network model to be explained to obtain the masked prediction result. S4: Calculate the total loss according to the original prediction result and the masked prediction result; the process of calculating the total loss includes: S41: Calculate the inverse sorting matrix of the masked prediction result, and adjust the order of the original prediction result according to the inverse sorting matrix. S42: Input the result of the adjusted original prediction order into the Plackett-Luce model to calculate the sorting loss. S43: Calculate the value difference loss between the original prediction result and the masked prediction result. S44: Obtain a mask matrix according to the importance score of each edge, and calculate the first-order norm of the mask matrix. S45: Calculate the total loss according to the sorting loss, the value difference loss, and the first-order norm of the mask matrix. S5: Optimize the mask generator according to the total loss, and repeat steps S2 to S4 until the optimal mask generator is obtained. S6: Use the optimal mask generator to mask the original graph data to obtain the masked subgraph, which is the explanation of the original prediction result.
2. The method for interpreting a graph neural network that maintains prediction order and structural dependency relationships according to claim 1, wherein The process of using a mask generator to mask the original graph data includes: S21: Convert the nodes of the original graph into the edges of the new graph, convert the edges of the original graph into the nodes of the new graph, and establish edges between the nodes with data flow in the new graph. S22: Input the new graph into the graph attention network model for processing to obtain the latent variable. S23: According to the latent variable, use the reparameterization trick of the discrete distribution to calculate the importance score of each edge, and mask the edges of the original graph according to the importance score of the edge to obtain the masked subgraph.
3. The method for interpreting a graph neural network that maintains prediction order and structural dependency relationships according to claim 2, wherein The formula for obtaining the latent variable is: where, Ω represents the set of latent variables, represents the mask generator network model, represents the adjacency matrix of the new graph; represents the node features of the new graph, represents the parameters of the mask generator.
4. The method for interpreting a graph neural network that maintains prediction order and structural dependencies according to claim 2, wherein The formula for calculating the importance score of each edge is: m pq = C(ω i , ∈, τ2) = σ((log ∈ - log(1 - ∈) + ω i ) / τ2) where m pq represents the importance score of the edge e i connected by the masked nodes p and q, ω i represents the i-th latent variable in the set of latent variables, ∈ represents the first parameter, and τ2 represents the second hyperparameter.
5. A method for interpreting a graph neural network that maintains prediction order and structural dependencies according to claim 1, characterized in that The formula for calculating the inverse sorting matrix is: Among them, represents the i-th row of the inverse sorting matrix, and softmax() represents the normalized exponential function. represents the predicted result after masking. represents the predicted result. represents the absolute value of the difference between pairwise probability values in , i represents the i-th row of the matrix, 1 is a column vector of all 1s, τ1 is the temperature parameter, and n represents the number of nodes in a graph.
6. The method for interpreting a graph neural network that maintains prediction order and structural dependency relationships according to claim 1, wherein The formula for adjusting the order of the original prediction result is: Among them, represents the result after adjusting the order of the original prediction Y, represents the inverse sorting matrix, and Y represents the original prediction result.
7. A method for interpreting a graph neural network that maintains prediction order and structural dependencies according to claim 1, characterized in that The formula for calculating the sorting loss: Among them, L PL represents the sorting loss, represents the result after adjusting the order of the original prediction Y at the i-th position.
8. A method for interpreting a graph neural network that maintains prediction order and structural dependencies according to claim 1, characterized in that The formula for calculating the value difference loss is: L diff = ||f(A, X, W) - f(M ⊙ A, X, W)||1 Among them, L diff represents the value difference loss, f(A, X, W) represents the prediction result obtained by inputting the original graph data into the graph neural network model, and f(M⊙A, X, W) represents the prediction result obtained by inputting the masked original graph data into the graph neural network model.
9. The method for interpreting a graph neural network that maintains prediction order and structural dependencies according to claim 1, wherein The formula for calculating the total loss is: Among them, represents the total loss, L PL represents the sorting loss, L diff represents the value difference loss, L M represents the first-order norm of the mask matrix.