Heterogeneous Graph Neural Network Node Classification Method Based on Dual-View Paradigm of Network Mode and Meta-Path
By adopting the self-attention and attention mechanism of the two-view paradigm in the heterogeneous graph neural network, combined with GraphSAGE and layer attention mechanism, the semantic confusion problem in the heterogeneous graph model is solved, and more accurate node classification is achieved.
Patent Information
- Application Number
- CN202410295595.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-15
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2044-03-15
AI Technical Summary
Existing heterogeneous graph neural network models are prone to semantic confusion when processing high-dimensional node features and higher-order information, it is difficult to effectively distinguish multiple relationship types, and it is difficult to make full use of the structure and semantic information of the graph for node classification.
Using a dual-view paradigm based on network mode and metapath, through the aggregation of dynamic neighbor feature of self-attention mechanism and GraphSAGE, combining structural and semantic attention mechanisms, an automatic dual-view fusion mechanism is designed to capture the structural and semantic features of heterogeneous graphs and perform node classification.
It effectively avoids semantic confusion, improves the accuracy and availability of node classification, and can more comprehensively utilize the structure and semantic information of the graph for node classification.
Smart Images

Figure CN118228103B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the research field of node classification in user relationship networks, and specifically relates to a heterogeneous graph neural network node classification method based on a dual-view paradigm of network patterns and meta-paths. Background Art
[0002] In various research fields, graph structures are powerful models for solving real-world problems, such as knowledge graphs, social network analysis, and recommendation systems. Efficiently analyzing and mining information in graph data is crucial for improving the accuracy of downstream tasks, and thus has become a rapidly developing research field in academia and industry. However, the non-Euclidean nature of graphs poses challenges to traditional machine learning models.
[0003] Node classification aims to classify using node embeddings and graph topology, thus assigning labels to unknown nodes. The implementation of this task mainly relies on graph embedding techniques. Recent advances in deep learning have greatly improved the efficacy of graph embedding, enabling nodes to be represented as low-dimensional vectors in Euclidean space. This method has proven effective in various graph-based downstream tasks. Recently, graph neural networks (GNNs) have become important models for graph embedding. Representative methods in the GNN framework include graph convolutional networks (GCNs), graph attention networks (GATs), and their variants. These GNN-based methods can simultaneously consider the structural information and attribute information between nodes, thus improving the expressive power and generalization performance. The fusion of structural and attribute information enables GNNs to capture complex relationships in the graph, making them versatile and powerful tools for various applications in graph analysis. Graphs in the real world are often heterogeneous graphs composed of different types of nodes and edges, which provide rich semantic information and structural information. To effectively capture the complex structural and semantic information in heterogeneous information networks (HINs) or heterogeneous graphs, various heterogeneous graph neural network (HGNN) models have been proposed and achieved good performance in heterogeneous graph learning. Among them, the meta-path-based method captures the structural information for each meta-path and fuses the semantic information in different meta-paths to generate the final embedding vector. The network-pattern-based method does not rely on meta-paths and directly performs message passing on the heterogeneous graph. It uses node- and / or relationship-specific transformations to map different types of nodes and / or edges to the same semantic space and then aggregates them. For example, HAN improves the GAT model by using a hierarchical attention mechanism to describe the node-level and semantic-level structures to learn node representations. On this basis, MAGNN uses a special meta-path instance encoder to convert the features of all nodes in the meta-path into vectors, preserves the intermediate node features to improve HAN, and thus improves the node classification effect. CP-GNN uses context paths to capture the high-order relationships between nodes, uses the attention mechanism to distinguish the importance of different relationships, and then uses the HGNN model to encode the graph for node classification. NSHE improves the node classification effect by network pattern sampling and multi-task learning, retaining the network pattern structure and pairwise structure information of heterogeneous graph embeddings. Simple-HGN adopts an attention mechanism to simulate the importance of neighborhoods connected by different types of relationships to improve the node classification effect. HGSL constructs three types of graphs, namely, a feature graph (feature similarity), a semantic graph (heterogeneous meta-path), and a topological graph (topological relationship), to generate a heterogeneous graph structure suitable for node classification, which can capture the local information of nodes. Megnn adopts a message passing paradigm to simultaneously encode the topological structure, node attributes, and semantic relationships of the graph into node embeddings for node classification.However, the above methods are difficult to handle high-dimensional node features. High-order information must be captured by stacking network layers. However, stacking network layers will cause semantic confusion problems in current mainstream heterogeneous graph neural networks. Summary of the Invention
[0004] The main purpose of the present invention is to overcome the disadvantages and deficiencies of the prior art, and provide a node classification method for heterogeneous graph neural networks based on a dual-view paradigm of network mode and meta-path. The method of the present invention starts from the network structure and meta-path, can learn the local information and high-order information of nodes, effectively avoid semantic confusion, and can also distinguish multiple relationship types existing in the heterogeneous graph, improving the ability to learn structural information.
[0005] To achieve the above purpose, the present invention adopts the following technical solutions:
[0006] In the first aspect, the present invention provides a node classification method for heterogeneous graph neural networks based on a dual-view paradigm of network mode and meta-path, including the following steps:
[0007] S1. Collect social network data and construct graph sequence data of a heterogeneous graph social network. The graph sequence data includes a meta-path sequence, a node type sequence, a graph adjacency matrix, and node representation features;
[0008] S2. Construct a node classification model for heterogeneous graph neural networks based on a dual-view paradigm of network mode and meta-path. The node classification model for heterogeneous graph neural networks includes a network mode view processing branch, a meta-path view processing branch, and an automatic dual-view fusion mechanism. The network mode view processing branch and the meta-path view processing branch learn nodes from multiple dimensions to capture the structural information of the heterogeneous graph and the semantic information of nodes, and through the automatic dual-view fusion mechanism, unify the information from different views into the same feature space, enabling the dual views to jointly represent complex multi-type information in the heterogeneous graph, obtaining a more comprehensive and accurate node representation, and thus performing node classification;
[0009] S3. Input the heterogeneous graph data into the network mode view processing branch, perform intra-type aggregation using a dynamic neighbor feature aggregation method that combines the self-attention mechanism and the sampling strategy of GraphSAGE, and introduce a structure-level attention mechanism to learn the importance of node types for inter-type aggregation, thereby hierarchically capturing the structural features of the heterogeneous graph;
[0010] S4. Input the heterogeneous graph data into the meta-path view processing branch, perform sufficient semantic intra-aggregation of the node's own information and neighbor information, design a semantic-level attention mechanism to assign dynamic weights to the meta-path, and at the same time adaptively adjust the weights of each layer based on the layer attention mechanism for inter-meta-path aggregation to capture semantic features at different levels;
[0011] S5. Effectively fit the feature representations of the two views through the designed automatic dual-view fusion mechanism;
[0012] S6. Use the cross-entropy loss function for optimization and update the parameters to output the node classification results.
[0013] As a preferred technical solution, in step S1, the graph sequence data of the heterogeneous graph social network is represented as graph G = {V, E, A, R}, where V and E represent the node set and the edge set respectively, and each node v ∈ V and e ∈ E are respectively associated with their corresponding mapping functions and where A and R represent the node type and the edge type respectively. When |A| + |R| > 2, and |A| > 0 and |R| > 0, it indicates that there are multiple types of nodes and edges.
[0014] As a preferred technical solution, in step S3, the specific steps of the intra-type aggregation are as follows:
[0015] According to the network mode, assume that the target node i is connected to M types of nodes The type neighbors of the target node i are defined as GraphSAGE uses an aggregation function to update the feature representation of node i. When the aggregation function uses the self-attention mechanism, it is first necessary to calculate the attention coefficients, and then use these coefficients to obtain the weighted neighbor feature representation
[0016]
[0017]
[0018] where α is a learnable weight vector, W Q , W K and W V are learnable weight matrices, corresponding to the linear transformations of Query, Key, and Value respectively; the attention coefficient α ij represents the importance of the feature of node j to node i; d k is the dimension of the key vector, used to scale the result of the dot product;
[0019] Use the aggregated feature and the type feature of node i, as well as the neighbor feature, to update the feature of node i by concatenating and applying a linear transformation and a non-linear activation function;
[0020]
[0021] Among them represents the type embedding of node i in the k-th iteration; represents the type embedding of node i in the (k - 1)-th iteration; W k represents the weight parameter of the k-th iteration; σ represents the activation function; CONCAT is the fusion function; represents for the target node i all neighbor nodes j of the type, whose features are aggregated at the (k - 1)-th step;
[0022] As a preferred technical solution, in the step S3, the step of inter-type aggregation is specifically:
[0023] Let the embeddings of all types of the target node i be Using the structure-level attention mechanism, fuse the embeddings of all types of the target node i together to obtain the final embedding of node i
[0024] The calculation method of the weight of each node type is:
[0025]
[0026] where α sc is the structure-level attention vector, is the parameter vector that converts the output of the attention network into a single scalar score, is the trainable weight vector, V is the combination of the target node, is the embedding representation of node i in the relationship ; || represents the concatenation operation; W sc ∈ R d×d is the weight matrix and b sc ∈ R d×1 is the bias vector and both are learnable parameters and are shared for all types; tanh(·) is the non-linear activation function; in order to make the importance of each node type easy to compare, they are normalized among all types by using the softmax function, and acting on the formula (3) to obtain obtain the weight value of each node type:
[0027]
[0028] where: is the importance of the denotes a relation-specific layer normalization operation, and LeakyRelu denotes a non-linear activation function;
[0029] Finally, all relation representations are fused to obtain the final representation
[0030]
[0031] As a preferred technical solution, in step S4, the semantic intra-aggregation is specifically as follows:
[0032] Given a meta-path P s ∈ {P1, P2, …, P M}, the meta-path-based neighbors are obtained where each meta-path starts from the target node i;
[0033]
[0034] where, represents the node representation learned by node i through the k-th layer based on the meta-path P s , which represents the aggregation of the K-1 step of neighbor information of node i based on a specific meta-path type, capturing not only the local neighbor structure of node i, but also reflecting the more distant neighbor relationships through the global path dependence defined by P s ; where indicates the probability of directly transferring from node i to node j; this transition matrix is constructed by the product of a series of adjacency matrices corresponding to the meta-path P s , and each adjacency matrix represents a specific type of edge connection in the graph; β is a weight scalar, indicating the importance of the node's own information in the aggregation process; represents the input of node i based on the meta-path P s s ; represents the vector deviation under the type of P s ; is the mapping matrix under the type of P s ; σ(·) is the ReLU activation function.
[0035] As a preferred technical solution, in step S4, the inter-meta-path aggregation is specifically as follows:
[0036] {P1, P2, …, P M} The corresponding M groups of node representations are The importance of all meta-paths is normalized by learning the corresponding attention weights through semantic-level attention to obtain the weight S of the meta-path P Calculated as follows:
[0037]
[0038] The greater the weight, the more important the corresponding meta-path; among them, the meta-path P s importance is learned using the semantic-level attention vector γ:
[0039]
[0040] W sc is the weight matrix and b sc is the bias vector, which are shared for all meta-paths; finally, the P-group node representations are weighted and fused to obtain the final node representation The calculation is as follows:
[0041]
[0042] As a preferred technical solution, the layer attention mechanism is a mechanism for weighted merging of the outputs of different layers. Suppose the network has L layers, and the output of each layer is an N×D matrix, where N is the number of nodes and D is the dimension of the hidden layer. The formula of the layer attention mechanism is as follows:
[0043] W = softmax(LR(H (1) ))
[0044] H (1) is the output of the first layer, LR is a linear transformation with a shape of N×L, and the softmax function is applied to the last dimension to convert the attention scores into attention weights. The shape of W is N×L;
[0045] For each node i, calculate its weighted feature sum in all layers:
[0046]
[0047] For a given node i and each L, multiply W[i, l] by the corresponding H l [i, :], and then sum over all L. H[i, :] integrates the information of all layers, and the weighted node representation has a shape of N×D.
[0048] As a preferred technical solution, the specific step S5 is as follows:
[0049] First, calculate Z sc For Z mp attention score matrix att_sc_to_mp:
[0050]
[0051] where W sc→mp is the weight matrix, Zsc and Z mp are the feature representation matrices of two inputs respectively, · represents matrix multiplication operation, represents the transpose of Z mp ;
[0052] Calculate the attention score matrix att_mp_to_sc of Z mp for Z sc :
[0053]
[0054] According to the calculated attention score matrix, update the representations of Z mp and Z sc :
[0055] Z′ SC = att_sc_to_mp·Z mp
[0056] The updated Z′ SC indicates that each sample is weighted and averaged according to the attention scores of the samples and responses in Z mp ;
[0057] Z′ MP = att_mp_to_sc·Z sc
[0058] The updated Z′ MP indicates that each sample is weighted and averaged according to the attention scores of the samples and responses in Z sc ;
[0059] Z ac = Z′ SC + Z′ MP
[0060] Merge the updated two representations to obtain the final output. This bidirectional attention mechanism allows the representation of each view to be affected by the other view, promoting the interaction and information integration between features.
[0061] As a preferred technical solution, in step S6, the node classification result is calculated as follows:
[0062]
[0063] C is the projection matrix that maps the node representation to the label, y L is the node with a label, Y l and Z l are the label and the node embedding representation of node l respectively.
[0064] Second aspect, the present invention provides a heterogeneous graph neural network node classification system based on a dual-view paradigm of network patterns and meta-paths, which is applied to the heterogeneous graph neural network node classification method based on the dual-view paradigm of network patterns and meta-paths, and includes a graph sequence data construction module, a classification model construction module, a structural feature acquisition module, a semantic feature acquisition module, a feature fusion module, and a classification result output module;
[0065] The graph sequence data construction module is used to collect social network data and construct graph sequence data of a heterogeneous graph social network, where the graph sequence data includes a meta-path sequence, a node type sequence, a graph adjacency matrix, and node representation features;
[0066] The classification model construction module is used to construct a heterogeneous graph neural network node classification model based on a dual-view paradigm of network patterns and meta-paths. The heterogeneous graph neural network node classification model includes a network pattern view processing branch, a meta-path view processing branch, and an automatic dual-view fusion mechanism. The network pattern view processing branch and the meta-path view processing branch respectively learn nodes from multiple dimensions to capture the structural information of the heterogeneous graph and the semantic information of the nodes, and through the automatic dual-view fusion mechanism, unify the information from different views into the same feature space, enabling the dual views to collaboratively represent complex multi-type information in the heterogeneous graph, obtaining a more comprehensive and accurate node representation, and thus performing node classification;
[0067] The structural feature acquisition module is used to input the heterogeneous graph data into the network pattern view processing branch, perform intra-type aggregation using a dynamic neighbor feature aggregation method that combines the self-attention mechanism and the sampling strategy of GraphSAGE, and introduce a structure-level attention mechanism to learn the importance of node types for inter-type aggregation, thereby hierarchically capturing the structural features of the heterogeneous graph;
[0068] The semantic feature acquisition module is used to input the heterogeneous graph data into the meta-path view processing branch, perform sufficient semantic intra-aggregation of the node's own information and neighbor information, design a semantic-level attention mechanism to assign dynamic weights to the meta-paths, and at the same time adaptively adjust the weights of each layer based on the layer attention mechanism for inter-meta-path aggregation to capture semantic features at different levels;
[0069] The feature fusion module is used to effectively fit the feature representations of the two views through the designed automatic dual-view fusion mechanism;
[0070] The classification result output module optimizes and updates the parameters using the cross-entropy loss function and outputs the node classification result.
[0071] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0072] The present invention constructs a heterogeneous graph neural network node classification model based on a dual-view paradigm of network mode and meta-path. In the network mode view, a dynamic neighbor feature aggregation method that combines the self-attention mechanism and the sampling strategy of GraphSAGE is used for intra-type aggregation, and a structure-level attention mechanism is introduced to learn the importance of node types for inter-type aggregation, thereby hierarchically capturing the structural features of the heterogeneous graph. In the meta-path view, the node's own information and neighbor information are fully semantically aggregated internally, and a semantic-level attention mechanism is designed to assign dynamic weights to the meta-paths. At the same time, a layer attention mechanism is proposed to adaptively adjust the weights of each layer for inter-meta-path aggregation to capture semantic information at different levels. Through the designed automatic dual-view fusion mechanism, the feature representations of the two views are effectively fitted, strengthening the feature expressions of each view. The method described in the present invention uses a heterogeneous graph neural network method based on the dual-view paradigm, which can simultaneously extract graph structure information and semantic information, make full use of the mutual relationships between nodes, the rich information in the structure, and comprehensively consider diverse semantic information, and perform node classification more effectively, with high usability. Brief Description of the Drawings
[0073] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.
[0074] Figure 1 It is a flowchart of the method for classifying nodes of a heterogeneous graph neural network based on the dual-view paradigm of network mode and meta-path in the embodiments of the present invention;
[0075] Figure 2 It is a schematic diagram of the heterogeneous graph neural network node classification model based on the dual-view paradigm of network mode and meta-path in the embodiments of the present invention;
[0076] Figure 3 It is a schematic diagram of the structure of the heterogeneous graph neural network node classification system based on the dual-view paradigm of network mode and meta-path in the embodiments of the present invention. Detailed Embodiments
[0077] In order to enable those skilled in the art of the present technology to better understand the solutions of the present application, the following will clearly and completely describe the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts fall within the scope of protection of the present application.
[0078] As used herein, the term "embodiment" means that the specific features, structures, or characteristics described in connection with an embodiment may be included in at least one embodiment of the present application. The phrase may appear at various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described in the present application may be combined with other embodiments.
[0079] As Figure 1 shown, a method for classifying nodes of a heterogeneous graph neural network based on a dual-view paradigm of network mode and meta-path in this embodiment includes the following steps:
[0080] S1. Collect social network data and construct graph sequence data of a heterogeneous graph social network, where the graph sequence data includes a meta-path sequence, a node type sequence, a graph adjacency matrix, and node representation features.
[0081] Further, the heterogeneous graph social network data in step S1, "collect social network data and construct graph sequence data of a heterogeneous graph social network, including a meta-path sequence, a node type sequence, a graph adjacency matrix, and node representation features", can be represented as a graph G = {V, E, A, R}, where V and E represent the node set and the edge set, respectively. Each node v ∈ V and e ∈ E are respectively associated with their corresponding mapping functions and where A and R represent the node type and the edge type, respectively. When |A| + |R| > 2, and |A| > 0 and |R| > 0, it indicates that it contains multiple types of nodes and edges, where the meta-path (simplified to m = A1A2…A l+1 ), the node types A1A2…A l+1 ∈ A, and the edge types R1R2…R l+1 ∈ R.
[0082] S2. Construct a node classification model of a heterogeneous graph neural network based on a dual-view paradigm of network mode and meta-path.
[0083] Further, as Figure 2 shown, the node classification model of the heterogeneous graph neural network includes a network mode view processing branch, a meta-path view processing branch, and an automatic dual-view fusion mechanism. The network mode view processing branch and the meta-path view processing branch respectively learn nodes from multiple dimensions to capture the structural information of the heterogeneous graph and the semantic information of the nodes, and through the automatic dual-view fusion mechanism, unify the information from different views into the same feature space, enabling the dual views to jointly represent the complex multi-type information in the heterogeneous graph, obtaining a more comprehensive and accurate node representation, and thus performing node classification.
[0084] S3. Input the heterogeneous graph data into the network mode view processing branch. Use a dynamic neighbor feature aggregation method that combines the self-attention mechanism and the sampling strategy of GraphSAGE for intra-type aggregation, and introduce a structure-level attention mechanism to learn the importance of node types for inter-type aggregation, thereby hierarchically capturing the structural features of the heterogeneous graph.
[0085] Further, step S3 specifically includes the following content:
[0086] S31. Steps based on intra-type aggregation:
[0087] S311. Aggregation function:
[0088] According to the network mode, assume that the target node i is connected to nodes of M types The neighbors of the type of target node i are defined as GraphSAGE uses an aggregation function to update the feature representation of node i. When the aggregation function uses the self-attention mechanism, it is first necessary to calculate the attention coefficients, and then use these coefficients to obtain the weighted neighbor feature representation
[0089]
[0090]
[0091] where α is a learnable weight vector, W Q , W K and W V are learnable weight matrices, corresponding to the linear transformations of Query, Key, and Value respectively. The attention coefficient α ij represents the importance of the features of node j to node i. d k is the dimension of the key vector, used to scale the result of the dot product.
[0092] S312. Feature update rule:
[0093] Use the aggregated features and the type of node ii and the neighbor features to update the features of node i by concatenation and applying a linear transformation and a non-linear activation function.
[0094]
[0095] where represents the type embedding of node i in the k-th iteration; represents the type embedding of node i in the (k - 1)-th iterationType embedding; W k denotes the weight parameter of the k-th iteration; σ denotes the activation function; CONCAT is the fusion function. denotes for the target node i all neighbor nodes j of type aggregation at the k-1 step. Calculates the sum of all neighbor nodes, divides by the number of neighbors to obtain the average value, ensuring that the contribution of each neighbor node to the final aggregation result is equal.
[0096] S32. The aggregation step based on types is as follows:
[0097] Different from the encoder for in-type aggregation above, the encoder based on inter-type attention aims to handle the interaction between different types of nodes. The embeddings of all types of the target node i (i is a certain target node) are Using the encoder of the structure-level attention mechanism, i.e., inter-type attention, fuses the embeddings of all types of the target node i to obtain the final embedding of node i The calculation method of the weight for each node type is as follows:
[0098]
[0099] where α sc is the structure-level attention vector, is the parameter vector that converts the output of the attention network into a single scalar score, is the trainable weight vector, V is the combination of the target node, is the embedding representation of node i in the relationship , || represents the concatenation operation. W sc ∈R d×d is the weight matrix and b sc ∈R d×1 is the bias vector and both are learnable parameters and are shared for all types; tanh(·) is the non-linear activation function. To make it easy to compare the importance of each node type, they are normalized among all types by using the softmax function, acting on the formula (3) to obtain the weight value of each node type can be obtained:
[0100]
[0101] where: is the importance of type to the target node i. denotes the layer normalization operation specific to the relationship, LeakyRelu denotes the non-linear activation function. Finally, all relationship representations are fused to obtain the final representation
[0102]
[0103] S4. Input the heterogeneous graph data into the meta-path view, fully semantically aggregate the node's own information and neighbor information, design a semantic-level attention mechanism to assign dynamic weights to the meta-paths, and adaptively adjust the weights of each layer based on the layer attention mechanism to perform aggregation between meta-paths and capture semantic features at different levels.
[0104] Further, the step S4 specifically includes the following contents:
[0105] S41. Semantic intra-aggregation step;
[0106] The encoder based on the meta-path can deeply mine and encode the complex relationships defined by the meta-path between different types of nodes in the graph, thereby enriching the node representation and enhancing the understanding of the heterogeneous graph structure. Given a meta-path P s ∈{P1, P2, …, P M}, obtain the neighbors based on the meta-path where each meta-path starts from the target node i.
[0107]
[0108] Among them, represents the node representation learned by node i through the k-th layer based on the meta-path P s , represents the aggregation of the K - 1 step of neighbor information of node i based on a specific meta-path type, which not only captures the local neighbor structure of node i, but also reflects the farther neighbor relationship through the global path dependence defined by P s . Among them indicates the probability that node i directly transfers to node j. This transition matrix is constructed by the product of a series of adjacency matrices corresponding to the meta-path P s , and each adjacency matrix represents a specific type of edge connection in the graph. β is a weight scalar, which indicates the importance of the node's own information in the aggregation process. represents the input of node i based on the meta-path P s . represents the vector deviation under the type of P s ; is the mapping matrix under the type of P s ; σ(·) is the ReLU activation function.
[0109] S42. The steps for inter-meta-path aggregation are:
[0110] This application adopts a semantic-level attention mechanism based on an encoder between meta-paths, which integrates neighborhood aggregation information under multiple meta-paths to obtain a comprehensive description of the target node features. M The corresponding M group nodes are represented as The importance of all meta-paths is normalized by learning the corresponding attention weights through semantic-level attention, and the meta-path P is obtained. S Weight The calculation is as follows:
[0111]
[0112] The larger the weight, the more important the corresponding meta-path. s Importance Use the semantic level attention vector γ to learn:
[0113]
[0114] W sc is the weight matrix and b sc is the bias vector, which is shared by all meta-paths. Finally, the P groups of node representations are weighted fused to obtain the final node representation The calculation is as follows:
[0115]
[0116] S43, layer attention mechanism;
[0117] In order to enhance the model's ability to dynamically integrate multi-layer feature representations. This mechanism achieves weighted combination of feature information by assigning learnable weight coefficients to each layer of the network. The layer attention mechanism enables the model to adaptively focus on the most discriminative features for the current task, regardless of whether these features are shallow fine-grained information or deep high-level abstractions. It helps to improve the network's ability to model complex data structures and can more effectively capture semantics at different levels.
[0118] The layer attention mechanism is a mechanism for weighted merging of outputs from different layers. Assuming the network has L layers, the output of each layer is an N×D matrix, where N is the number of nodes and D is the dimension of the hidden layer. The layer attention mechanism formula is as follows:
[0119] W = softmax(LR(H (1) ))
[0120] H (1)is the output of the first layer. LR is a linear transformation with a shape of N×L. The softmax function is applied to the last dimension to convert the attention scores into attention weights. The shape of W is N×L.
[0121] For each node i, calculate its weighted feature sum across all layers:
[0122]
[0123] For a given node i and each L, multiply W[i, l] by the corresponding H l [i, :], and then sum over all L. H[i, :] combines the information from all layers. The weighted node representation has a shape of N×D.
[0124] S5. Effectively fit the feature representations of the two views through the designed automatic dual-view fusion mechanism.
[0125] Further, step S5 is specifically as follows:
[0126] Adopt the automatic dual-view fusion mechanism. By "caring" about different data representations with each other, it allows the view representations to learn and adapt to each other. This mechanism enhances the feature expressions of each view and dynamically weights the features through attention weights, thereby achieving effective fusion of the features.
[0127] First, calculate Z sc For Z mp calculate the attention score matrix att_sc_to_mp:
[0128]
[0129] where W sc→mp is the weight matrix, Z sc and Z mp are the feature representation matrices of the two inputs respectively, · represents the matrix multiplication operation, represents the transpose of Z mp
[0130] Calculate the attention score matrix att_mp_to_sc for Z mp For Z sc
[0131]
[0132] According to the calculated attention score matrices, update the representations of Z mp and Z sc :
[0133] Z′ SC = att_sc_to_mp·Z mp
[0134] Updated Z' SC indicates that each sample is weighted and averaged according to the attention scores of the samples and responses in Z mp .
[0135] Z' MP = att_mp_to_sc·Z sc
[0136] Updated Z' MP indicates that each sample is weighted and averaged according to the attention scores of the samples and responses in Z sc .
[0137] Z ac = Z' SC + Z' MP
[0138] The two updated representations are combined to obtain the final output. This bidirectional attention mechanism allows the representations of each view to be influenced by the other view, promoting the interaction and information integration between features.
[0139] S6. Optimize and update the parameters using the cross-entropy loss function, and output the node classification result.
[0140] The calculation of the output node classification result is as follows:
[0141]
[0142] C is the projection matrix that maps the node representation to the label, y L is the node with a label, Y l and Z l are the label and the node embedding representation of node l respectively.
[0143] This embodiment uses a heterogeneous graph neural network method based on the dual-view paradigm, which can simultaneously extract graph structure information and semantic information, make full use of the mutual relationships between nodes, the rich information in the structure, and comprehensively consider diverse semantic information, and perform node classification more effectively, with high usability.
[0144] In a specific embodiment, step S1, "heterogeneous graph social network data", is specifically shown in Table 1 as follows:
[0145] Table 1
[0146]
[0147] DBLP contains 4,328 papers (P), 2,957 authors (A), and 20 conferences (C). The authors are divided into four fields: databases, data mining, machine learning, and information retrieval. The node features are terms related to papers, authors, and conferences. In this embodiment, the meta-paths {APA, APCPA} are selected for node classification.
[0148] For this instance, the specific parameter settings of the heterogeneous graph neural network node classification model with a dual-view paradigm based on network patterns and meta-paths: For each dataset, this embodiment only uses the original attributes of the target nodes. For the random walk-based model, this embodiment sets the number of walks per node to 40, the walk length to 100, and the window size to 5. For the meta-path-based model, this embodiment selects the popular meta-paths adopted in the previous methods and reports the best results. For GCN, GAT, and GraphSAGE, the parameters are optimized through the validation set. For the HGEM-DV model proposed in this embodiment, the Glorot initialization method is used. Since the layer attention mechanism is used and the effect increases layer by layer, the number of layers is set to 2 in the following experiments. And for fair comparison, this embodiment sets the embedding dimension of all the above methods to 64, uses the Adam optimizer, and selects hyperparameters (such as learning rate, weight decay, etc.) through grid search, so that each benchmark model can achieve the best performance.
[0149] This embodiment adopts the Pytorch 1.12.1 deep learning framework, where the programming language is Python 3.7.11, and the GPU acceleration component is CUDA 10.2.
[0150] In another specific embodiment, the "heterogeneous graph social network data" in step S1 is specifically shown in Table 2 as follows:
[0151] Table 2
[0152]
[0153] ACM contains 3,025 papers (P), 5,912 authors (A), and 57 conference topics (S). The papers are labeled according to their conferences. The features of the paper nodes are their bag-of-words features of keywords. The papers are divided into three categories: databases, wireless communication, and data mining. In this embodiment, the meta-paths {PAP, PSP, PSPAP} are used for node classification.
[0154] For this example, the specific parameter settings of the heterogeneous graph neural network node classification model based on the dual-view paradigm of network mode and metapath: For each dataset, this embodiment only uses the original attributes of the target nodes. For the random walk-based model, this embodiment sets the number of walks per node to 40, the walk length to 100, and the window size to 5. For the metapath-based model, this embodiment selects the popular metapaths adopted in the previous methods and reports the best results. For GCN, GAT, and GraphSAGE, the parameters are optimized through the validation set. For the HGEM-DV model proposed in this embodiment, the Glorot initialization method is used. Since the layer attention mechanism is used and the effect increases layer by layer, the number of layers is set to 2 in the following experiments. For fair comparison, this embodiment sets the embedding dimension of all the above methods to 64, uses the Adam optimizer, and selects hyperparameters (such as learning rate, weight decay, etc.) through grid search respectively, so that each benchmark model can achieve the best performance.
[0155] This embodiment uses the Pytorch 1.12.1 deep learning framework, where the programming language is Python 3.7.11 and the GPU acceleration component is CUDA 10.2.
[0156] Based on the same idea as the heterogeneous graph neural network node classification method based on the dual-view paradigm of network mode and metapath in the above embodiment, the present invention also provides a heterogeneous graph neural network node classification system based on the dual-view paradigm of network mode and metapath. This system can be used to execute the above heterogeneous graph neural network node classification method based on the dual-view paradigm of network mode and metapath. For the convenience of description, in the structural schematic diagram of the embodiment of the heterogeneous graph neural network node classification system based on the dual-view paradigm of network mode and metapath, only the parts related to the embodiment of the present invention are shown. Those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and it may include more or fewer components than those illustrated, or combine some components, or arrange different components.
[0157] Please refer to Figure 3 , in another embodiment of the present application, a heterogeneous graph neural network node classification system 100 based on the dual-view paradigm of network mode and metapath is provided. This system includes a graph sequence data construction module 101, a classification model construction module 102, a structural feature acquisition module 103, a semantic feature acquisition module 104, a feature fusion module 105, and a classification result output module 106;
[0158] The graph sequence data construction module 101 is used to collect social network data and construct the graph sequence data of the heterogeneous graph social network. The graph sequence data includes a metapath sequence, a node type sequence, a graph adjacency matrix, and node representation features;
[0159] The classification model construction module 102 is used to construct a heterogeneous graph neural network node classification model based on the dual-view paradigm of network patterns and meta-paths. The heterogeneous graph neural network node classification model includes a network pattern view processing branch, a meta-path view processing branch, and an automatic dual-view fusion mechanism. The network pattern view processing branch and the meta-path view processing branch learn nodes from multiple dimensions to capture the structural information of the heterogeneous graph and the semantic information of the nodes, and through the automatic dual-view fusion mechanism, unify the information from different views into the same feature space, enabling the dual views to jointly represent complex multi-type information in the heterogeneous graph, obtaining a more comprehensive and accurate node representation, and thus performing node classification;
[0160] The structural feature acquisition module 103 is used to input the heterogeneous graph data into the network pattern view processing branch, perform intra-type aggregation using a dynamic neighbor feature aggregation method that combines the self-attention mechanism and the sampling strategy of GraphSAGE, and introduce a structure-level attention mechanism to learn the importance of node types for inter-type aggregation, thereby hierarchically capturing the structural features of the heterogeneous graph;
[0161] The semantic feature acquisition module 104 is used to input the heterogeneous graph data into the meta-path view, perform sufficient semantic intra-aggregation of the node's own information and neighbor information, design a semantic-level attention mechanism to assign dynamic weights to the meta-paths, and at the same time adaptively adjust the weights of each layer based on the layer attention mechanism for inter-meta-path aggregation to capture semantic features at different levels;
[0162] The feature fusion module 105 is used to effectively fit the feature representations of the two views through the designed automatic dual-view fusion mechanism;
[0163] The classification result output module 106 optimizes and updates the parameters using the cross-entropy loss function and outputs the node classification result.
[0164] It should be noted that the heterogeneous graph neural network node classification system based on the dual-view paradigm of network patterns and meta-paths of the present invention corresponds one-to-one with the heterogeneous graph neural network node classification method based on the dual-view paradigm of network patterns and meta-paths of the present invention. The technical features and their beneficial effects described in the embodiments of the above-mentioned heterogeneous graph neural network node classification method based on the dual-view paradigm of network patterns and meta-paths are applicable to the embodiments of the heterogeneous graph neural network node classification based on the dual-view paradigm of network patterns and meta-paths. For specific content, reference can be made to the description in the method embodiments of the present invention, which will not be elaborated here. This is hereby declared.
[0165] In addition, in the implementation of the heterogeneous graph neural network node classification system with a dual-view paradigm based on network patterns and meta-paths in the above embodiments, the logical division of each program module is only for illustration. In actual applications, according to needs, for example, considering the configuration requirements of the corresponding hardware or the convenience of software implementation, the above functions can be assigned to different program modules to complete. That is, the internal structure of the heterogeneous graph neural network node classification system with a dual-view paradigm based on network patterns and meta-paths is divided into different program modules to complete all or part of the functions described above.
[0166] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0167] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications made without departing from the spirit and principle of the present invention shall be equivalent replacement methods and are all included in the protection scope of the present invention.
Claims
1. A method for node classification of heterogeneous graph neural network based on a dual-view paradigm of network mode and meta-path, characterized in that, It includes the following steps: S1. Collect social network data, construct graph sequence data of a heterogeneous graph social network, where the graph sequence data includes a meta-path sequence, a node type sequence, a graph adjacency matrix, and node representation features; the social network data includes papers, authors, and conferences; the node representation features are terms related to papers, authors, and conferences; S2. Construct a node classification model for a heterogeneous graph neural network based on a dual-view paradigm of network patterns and meta-paths. The heterogeneous graph neural network node classification model includes a network pattern view processing branch, a meta-path view processing branch, and an automatic dual-view fusion mechanism. The network pattern view processing branch and the meta-path view processing branch learn nodes from multiple dimensions to capture the structural information of the heterogeneous graph and the semantic information of the nodes, and through the automatic dual-view fusion mechanism, unify the information from different views into the same feature space, enabling the dual views to jointly represent complex multi-type information in the heterogeneous graph, obtaining a more comprehensive and accurate node representation, and thus performing node classification; S3. Input the heterogeneous graph data into the network pattern view processing branch, use a dynamic neighbor feature aggregation method that combines the self-attention mechanism and the sampling strategy of GraphSAGE for intra-type aggregation, and introduce a structure-level attention mechanism to learn the importance of node types for inter-type aggregation, and then hierarchically capture the structural features of the heterogeneous graph; S4. Input the heterogeneous graph data into the meta-path view processing branch, fully perform semantic intra-aggregation on the node's own information and neighbor information, design a semantic-level attention mechanism to assign dynamic weights to the meta-paths, and at the same time adaptively adjust the weights of each layer based on the layer attention mechanism for inter-meta-path aggregation to capture semantic features at different levels; S5. Effectively fit the feature representations of the two views through the designed automatic dual-view fusion mechanism; S6. Use the cross-entropy loss function for optimization and update the parameters, and output the node classification result.
2. The method for classifying nodes of a heterogeneous graph neural network based on the dual-view paradigm of network patterns and meta-paths according to claim 1, wherein, In step S1, the graph sequence data of the heterogeneous graph social network is represented as graph G = {V, E, A, R}, where V and E represent the node set and the edge set respectively, and each node v ∈ V and e ∈ E are respectively associated with their corresponding mapping functions and where A and R represent the node type and the edge type respectively. When |A| + |R| > 2, and |A| > 0 and |R| > 0, it indicates that there are multiple types of nodes and edges.
3. The method for classifying nodes of a heterogeneous graph neural network based on a dual-view paradigm of network patterns and meta-paths according to claim 1, characterized in that, In step S3, the specific steps of the intra-type aggregation are as follows: According to the network mode, assume that the target node i is connected to M types of nodes The type of neighbors of the target node i is defined as GraphSAGE uses an aggregation function to update the feature representation of node i. When the aggregation function uses the self-attention mechanism, it is first necessary to calculate the attention coefficients, and then use these coefficients to obtain the weighted neighbor feature representation where α is a learnable weight vector, W Q , W K and W V are learnable weight matrices corresponding to the linear transformations of Query, Key, and Value respectively; the attention coefficient α ij represents the importance of the feature of node j to node i; d k is the dimension of the key vector, used to scale the result of the dot product; Features obtained using aggregation and the type feature of node i, as well as the neighbor features, are used to update the feature of node i by concatenating and applying a linear transformation and a non-linear activation function; Among them represents the type embedding of node i in the k-th iteration; represents the type embedding of node i in the (k - 1)-th iteration; W k represents the weight parameter of the k-th iteration; σ represents the activation function; The CONCAT is the fusion function; It represents for all neighbor nodes j of type for the target node i, Its features Aggregation at the (k - 1)-th step; The sum of all neighbor nodes is calculated, and the average value is obtained by dividing by the number of neighbors, ensuring that the contribution of each neighbor node to the final aggregation result is equal.
4. The method for classifying nodes of a heterogeneous graph neural network based on the dual-view paradigm of network patterns and meta-paths according to claim 1, characterized in that In step S3, the specific steps of the inter-type aggregation are as follows: Let the embeddings of all types of the target node i be Using the structure-level attention mechanism, fuse the embeddings of all types of the target node i together to obtain the final embedding of node i The calculation method of the weight for each node type is: where α sc is the attention vector at the structural level, is the parameter vector that converts the output of the attention network into a single scalar score, is the trainable weight vector, and V is the combination of target nodes, is the embedding representation of node i in the relationship , || represents the concatenation operation; W sc ∈ R d×d is the weight matrix and b sc ∈ R d×1 is the bias vector, both of which are learnable parameters and are shared for all types; tanh(·) is the non - linear activation function; to make it easy to compare the importance of each node type, they are normalized among all types by using the softmax function, which is applied to the result of formula (3) to obtain the weight value of each node type: Wherein: is the importance of the type to the target node i, represents a relationship-specific layer normalization operation, and LeakyRelu represents a non-linear activation function; Finally, all relationship representations are fused to obtain the final representation 5. The method for classifying heterogeneous graph neural network nodes based on the dual-view paradigm of network mode and meta-path according to claim 1, wherein In step S4, the semantic intra-aggregation is specifically: Given a meta-path P s ∈ {P1, P2, …, P M}, obtain the meta-path-based neighbors where each meta-path starts from the target node i; Among them, represents the node representation learned by node i through the k-th layer based on the meta-path P s . It represents the aggregation of the K-1 step of neighbor information of node i based on a specific meta-path type, which not only captures the local neighbor structure of node i, but also reflects the more distant neighbor relationship through the global path dependence defined by P ; where s represents the probability that node i directly transfers to node j; this transition matrix is constructed by the product of a series of adjacency matrices corresponding to the meta-path P , and each adjacency matrix represents a specific type of edge connection in the graph; β is a weight scalar, which indicates the importance of the node's own information in the aggregation process s ; represents the input of node i based on the meta-path P s ; represents the vector deviation under the type of P s ; is the mapping matrix under the type of P s ; σ(·) is the ReLU activation function.
6. The method for classifying nodes of a heterogeneous graph neural network based on a dual-view paradigm of network patterns and meta-paths according to claim 1, wherein In step S4, the inter-meta-path aggregation is specifically: {P1, P2, …, P M} are represented by M groups of nodes corresponding to Normalize the importance of all meta-paths by learning the corresponding attention weights through semantic-level attention to obtain the weight of meta-path P S as follows: The calculation is as follows: The greater the weight, the more important the corresponding meta-path; among them, for the meta-path P s importance is learned using the semantic-level attention vector γ: W sc is the weight matrix and b sc is the bias vector, which is shared for all meta-paths; finally, the P-group node representations are weighted and fused to obtain the final node representation The calculation is as follows:
7. The method for classifying nodes of a heterogeneous graph neural network based on the dual-view paradigm of network patterns and meta-paths according to claim 6, characterized in that, The layer attention mechanism is a mechanism for weighted combination of the outputs of different layers. Suppose the network has L layers, and the output of each layer is an N×D matrix, where N is the number of nodes and D is the dimension of the hidden layer. The formula of the layer attention mechanism is as follows: W = softmax(LR(H (1) )) H (1) is the output of the first layer. LR is a linear transformation with shape N×L. The softmax function is applied to the last dimension to convert the attention scores into attention weights. The shape of W is N×L; For each node i, calculate its weighted feature sum in all layers: For a given node i and each L, multiply W[i, l] by the corresponding H l [i, :], and then sum over all L. H[i, :] combines the information of all layers, and the weighted node representation has the shape N×D.
8. The method for classifying nodes of a heterogeneous graph neural network based on the dual-view paradigm of network patterns and meta-paths according to claim 1, wherein The specific content of step S5 is: First, calculate Z sc For Z mp the attention score matrix att_sc_to_mp: Among them, W sc→mp is the weight matrix, Z sc and Z mp are the feature representation matrices of the two inputs respectively, · represents the matrix multiplication operation, represents the transpose of Z mp ; Calculate Z mp For Z sc The attention score matrix att_mp_to_sc of: Update Z according to the calculated attention score matrix mp and Z sc representation: Z S ′ C = att_sc_to_mp·Z mp Updated Z S ′ C indicates that each sample is weighted and averaged according to the attention scores of the samples and responses in Z mp ; Z′ MP = att_mp_to_sc·Z sc Updated Z' MP indicates that each sample is weighted and averaged according to the attention scores of the samples and responses in Z sc ; Z ac = Z S ′ C + Z′ MP Merge the updated two representations to obtain the final output. This bidirectional attention mechanism allows the representation of each view to be affected by the other view, promoting the interaction and information integration between features.
9. The method for classifying heterogeneous graph neural network nodes based on the dual-view paradigm of network patterns and meta-paths according to claim 1, wherein In step S6, the node classification result is calculated as follows: $C$ is the projection matrix that maps the node representation to the label, $y$ L is the node with a label, $Y$ l and $Z$ l are the label of node $l$ and the node embedding representation, respectively.
10. A heterogeneous graph neural network node classification system based on a dual-view paradigm of network mode and meta-path, characterized in that An heterogeneous graph neural network node classification method applied to the dual-view paradigm based on network patterns and metapaths according to any one of claims 1-9, comprising a graph sequence data construction module, a classification model construction module, a structural feature acquisition module, a semantic feature acquisition module, a feature fusion module, and a classification result output module; The graph sequence data construction module is used to collect social network data and construct graph sequence data of an heterogeneous graph social network, where the graph sequence data includes a metapath sequence, a node type sequence, a graph adjacency matrix, and node representation features; the social network data includes papers, authors, and conferences; the node representation features are terms related to papers, authors, and conferences; The classification model construction module is used to construct an heterogeneous graph neural network node classification model based on the dual-view paradigm of network patterns and metapaths. The heterogeneous graph neural network node classification model includes a network pattern view processing branch, a metapath view processing branch, and an automatic dual-view fusion mechanism. The network pattern view processing branch and the metapath view processing branch respectively learn nodes from multiple dimensions to capture the structural information of the heterogeneous graph and the semantic information of the nodes, and through the automatic dual-view fusion mechanism, unify the information from different views into the same feature space, enabling the dual views to collaboratively represent the complex multi-type information in the heterogeneous graph, obtaining a more comprehensive and accurate node representation, and thus performing node classification; The structural feature acquisition module is used to input the heterogeneous graph data into the network pattern view processing branch, perform intra-type aggregation using a dynamic neighbor feature aggregation method that combines the self-attention mechanism and the sampling strategy of GraphSAGE, and introduce a structure-level attention mechanism to learn the importance of node types for inter-type aggregation, thereby hierarchically capturing the structural features of the heterogeneous graph; The semantic feature acquisition module is used to input the heterogeneous graph data into the metapath view processing branch, perform sufficient semantic intra-aggregation of the node's own information and neighbor information, design a semantic-level attention mechanism to assign dynamic weights to metapaths, and at the same time adaptively adjust the weights of each layer based on the layer attention mechanism for inter-metapath aggregation to capture semantic features at different levels; The feature fusion module is used to effectively fit the feature representations of the two views through the designed automatic dual-view fusion mechanism; The classification result output module optimizes and updates the parameters using the cross-entropy loss function and outputs the node classification result.
Citation Information
Patent Citations
Financial transaction anomaly detection method and cross-regional sustainable training method thereof
CN115660688A
Malicious domain name detection method and device based on heterogeneous graph robust adversarial learning
CN116668076A