Model construction method, device and equipment for generating positive and negative sample nodes
By designing a non-enhanced graph comparison learning model with multi-task constraints, the problem of graph data information loss in the prior art is solved, and more accurate and robust node representation is achieved, which improves the performance of graph data tasks.
Patent Information
- Application Number
- CN202411645927.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-03-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing non-enhanced methods easily lead to loss of graph data information when building positive and negative sample nodes, and rely on artificial settings of hyperparameters.
A non-enhanced graph comparison learning model with multi-task constraints is designed, including encoder, positive and negative sample node generation branches, global information completion branches, and node self-information completion branches. By iteratively training the neural network, the gap between the generated positive and negative sample node matrix, global feature matrix, and reconstructed graph data and the input graph data is minimized.
It effectively reduces the loss of graph data information, avoids human intervention, improves the performance of graph data tasks, and the generated node representation is more accurate and robust.
Smart Images

Figure CN119578454A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graph data processing technology, and in particular to a model building method, device and equipment for generating positive and negative sample nodes. Background Art
[0002] With the development of deep learning, graph data (graph data is a data structure composed of nodes and edges, where nodes represent entities or objects such as people, places or products, and edges represent relationships between entities such as social relationships, route connections or commodity transactions) processing has become an important branch of data science and deep learning, just like image processing and text processing. Among them, graph contrastive learning is a method of learning node feature representation by comparing the similarities between nodes in graph data. The goal of graph contrastive learning is to train a deep learning model (such as graph neural network GNN) to distinguish between positive sample pairs (nodes with similar attributes) and negative sample pairs (nodes without similar attributes). This is usually achieved by optimizing a contrastive loss function, which aims to maximize the similarity between positive sample pairs while minimizing the similarity between negative sample pairs, so that the deep learning model can learn effective feature representations of nodes. These learned representations can be used in various downstream tasks such as node classification, graph classification, link prediction, etc. However, in practical applications, it is time-consuming and limited to obtain graph data for training, so it is necessary to transform the existing graph data to generate more positive and negative samples for training.
[0003] At present, some works attempt to construct positive and negative samples using non-enhancement methods. Compared with the enhancement mode of constructing positive and negative samples based on randomly perturbed node attributes and edge attributes in graph data, the non-enhancement method hopes to avoid changing the original graph data structure and semantic information to reduce information loss.
[0004] However, existing non-enhanced methods rely more on manually setting hyperparameters to filter graph data information, such as manually setting the number of similar nodes, which weakens its "non-enhanced" characteristics to a certain extent and still leads to information loss in the process of constructing positive and negative samples. Summary of the invention
[0005] Based on this, in order to solve the technical problem of graph data information loss in the non-enhancement mode in the prior art, the present invention provides a model construction method, device and equipment for generating positive and negative sample nodes.
[0006] The present invention provides a model construction method for generating positive and negative sample nodes, which is used to generate positive and negative sample nodes of target nodes set in graph data, including:
[0007] Constructing a neural network including an encoder, a positive and negative sample node generation branch, a global information completion branch, and a node self-information completion branch, wherein the positive and negative sample node generation branch, the global information completion branch, and the node self-information completion branch are connected in parallel to the output end of the encoder;
[0008] The encoder is used to encode the input graph data to obtain a node feature matrix;
[0009] The positive and negative sample node generation branch is used to enhance the node feature matrix through the first multi-layer perceptron to obtain the positive and negative sample node matrix, and take the first-order neighbor nodes directly connected to the target node in the positive and negative sample node matrix as positive sample nodes and other nodes as negative sample nodes;
[0010] The global information completion branch is used to calculate the similarity between nodes according to the node feature matrix, so as to introduce the high-order non-neighbor node information that is not directly connected to the target node, and obtain the node global propagation matrix; and the node global propagation matrix is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information;
[0011] The node self-information completion branch is used to decode the node feature matrix to map the node feature matrix into an input graph data form to obtain reconstructed graph data;
[0012] A data set is constructed and the neural network is trained using the data set. During the training process, by iterating the weight parameters in the neural network, the ratio of the distance between the positive sample node and the target node output by the positive and negative sample node generation branch and the distance between the negative sample node and the target node, the gap between the global feature matrix output by the global information completion branch and the node feature matrix, and the gap between the reconstructed graph data output by the node self-information completion branch and the input graph data are minimized to obtain a model of positive and negative sample nodes for generating the target node set in the graph data.
[0013] Furthermore, encoding the input graph data to obtain a node feature matrix specifically includes:
[0014] Z=g φ (X, A)
[0015] Among them, Z is the node feature matrix; g φ (·) is an encoder composed of two layers of GCN; X is the feature matrix of the input graph data, and A is the adjacency matrix of the input graph data.
[0016] Furthermore, the node feature matrix is enhanced by the first multilayer perceptron to obtain a positive and negative sample node matrix, specifically including:
[0017] H base =f α(Z)
[0018] Among them, H base The node feature matrix Z passes through the first multi-layer perceptron f α (·) The positive and negative sample node matrix obtained after enhancement, H base The i-th row of the matrix H i base is the learned representation vector of node i.
[0019] Further, the similarity between nodes is calculated according to the node feature matrix to introduce high-order non-neighbor node information that is not directly connected to the target node to obtain the node global propagation matrix; and the node global propagation matrix is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information, specifically including:
[0020] The node feature matrix is used to calculate the similarity between nodes to construct the node global propagation matrix:
[0021]
[0022] In the formula, A ij GP is the node global propagation matrix A GP The value at position (i, j) in z i ∈Z and z j ∈Z, is the representation vector of nodes i and j in the node feature matrix Z; sim(·) is the cosine similarity function; γ is a parameter used to control the sensitivity of the function;
[0023] The global propagation matrix of the nodes is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information:
[0024] Z PPG =A GP ·f β (Z)
[0025] In the formula, Z PPG is the global feature matrix; f β (·) is the second multilayer perceptron.
[0026] Furthermore, the decoding of the node feature matrix to map the node feature matrix into the input graph data form to obtain the reconstructed graph data specifically includes:
[0027]
[0028] In the formula, is the reconstructed image data; g θ (·) is a decoder consisting of a two-layer GCN.
[0029] Furthermore, the method of minimizing the ratio of the distance between the positive sample node and the target node output by the positive and negative sample node generation branch and the distance between the negative sample node and the target node, the gap between the global feature matrix output by the global information completion branch and the node feature matrix, and the gap between the reconstructed graph data output by the node self-information completion branch and the input graph data is based on a loss function, wherein the loss function for:
[0030]
[0031] in, Generate loss function for positive and negative sample nodes, N is the number of nodes, v i is the i-th node; InfoNCE() is the information noise contrast estimation objective function, which is used to calculate the ratio of the distance between the target node and the positive sample node and the distance between the target node and the negative sample node output by the first multilayer perceptron, sim(·) is the cosine similarity function, N(v) represents the first-order neighbors of the target node v, V represents all nodes, and H base is the positive and negative sample node matrix output by the first multilayer perceptron, and They are respectively the nodes v in the positive and negative sample node matrices 、 Characterization of nodes u and k, τ is the temperature parameter;
[0032] is the global information completion loss function, z i is the representation of node i in the node feature matrix Z, z i ppg The global feature matrix Z output by the second multilayer perceptron PPG The new representation corresponding to the middle node i;
[0033] is the node self-information completion task loss function, x i is the characterization vector of node i in the input graph data, is the representation vector of the reconstructed node i in the reconstructed graph data output by the decoder; ij is the jth element of the vector representing node i, Reconstruct the jth element of the representation vector of node i, where d is the dimension of the node representation vector.
[0034] The present invention provides a model building device for generating positive and negative sample nodes, comprising:
[0035] A model construction module, used to construct a neural network including an encoder, a positive and negative sample node generation branch, a global information completion branch, and a node self-information completion branch, wherein the positive and negative sample node generation branch, the global information completion branch, and the node self-information completion branch are connected in parallel to the output end of the encoder;
[0036] The encoder is used to encode the input graph data to obtain a node feature matrix;
[0037] The positive and negative sample node generation branch is used to enhance the node feature matrix through the first multi-layer perceptron to obtain the positive and negative sample node matrix, and take the first-order neighbor nodes directly connected to the target node in the positive and negative sample node matrix as positive sample nodes and other nodes as negative sample nodes;
[0038] The global information completion branch is used to calculate the similarity between nodes according to the node feature matrix, so as to introduce the high-order non-neighbor node information that is not directly connected to the target node, and obtain the node global propagation matrix; and the node global propagation matrix is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information;
[0039] The node self-information completion branch is used to decode the node feature matrix to map the node feature matrix into an input graph data form to obtain reconstructed graph data;
[0040] The model training module is used to construct a data set and use the data set to train the neural network. During the training process, by iterating the weight parameters in the neural network, the ratio of the distance between the positive sample node and the target node output by the positive and negative sample node generation branch and the distance between the negative sample node and the target node, the gap between the global feature matrix output by the global information completion branch and the node feature matrix, and the gap between the reconstructed graph data output by the node self-information completion branch and the input graph data are minimized to obtain a model of positive and negative sample nodes for generating target nodes set in the graph data.
[0041] The present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned model building method for generating positive and negative sample nodes when executing the program.
[0042] At least one of the above technical solutions adopted by the present invention can achieve the following beneficial effects:
[0043] In the model construction method for generating positive and negative sample nodes provided by the present invention, the node feature matrix generated by the encoder is constrained by setting additional global information completion branches and node self-information completion branches to obtain a node feature matrix that minimizes the loss of global information of the graph data and the node's own information, and then based on the node feature matrix, the representation of the positive and negative sample nodes with the minimum information loss can be obtained. Specifically: based on the homogeneity assumption (i.e., the connected nodes often have similar attributes or belong to the same class), the present invention uses the first-order neighbors of the target node as positive samples and other nodes as negative samples without human intervention; in order to avoid the loss of high-order node information caused by retaining only the first-order node samples, the present invention designs a global information completion branch to complete the global information of the graph data, and ensures that the global structural information of the graph data is effectively encoded into the node feature matrix by focusing on high-order nodes; and in order to compensate for the information lost by the node itself in the process of obtaining global information, a node self-information completion branch is designed, that is, through the attribute reconstruction process, the characteristics of the node itself are kept from being excessively diluted or lost in the process of generating the node feature matrix. The design of three branches ensures that the generated node feature matrix can comprehensively reflect the global information and the node's own information, so that the model can learn more accurate and robust node representation, thereby improving the performance of graph data tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0045] Figure 1 A schematic diagram of a flow chart of a model construction method for generating positive and negative sample nodes provided by the present invention;
[0046] Figure 2 A schematic diagram of a model building framework for generating positive and negative sample nodes provided by the present invention. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in combination with the specific embodiments of the present invention and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] In order to solve the information loss problem in the non-enhanced mode, the present invention proposes a non-enhanced graph contrastive learning framework with multi-task constraints. The powerful performance of GNN (Graph Neural Networks) is based on the homogeneity assumption, that is, the connected nodes often have similar attributes or belong to the same class. Based on the homogeneity assumption, the present invention directly generates positive samples and negative samples through the network structure without additional enhancement. Therefore, the present invention proposes a new non-enhanced contrastive learning model with multi-task constraints, which retains local, global and node information through multi-task constraints. Specifically, the present invention uses the first-order neighbors of the target node as positive samples and other nodes as negative samples, which does not require any human intervention. However, some high-order nodes can still provide meaningful information for the target node. The first-order samples constructed based on the strong homogeneity assumption will lead to the loss of high-order information. Therefore, the present invention designs a global information completion branch to complete the global information. In addition, the above two branches use instance discriminant loss functions (InfoNCE, etc.), which is expected to make the target node and its neighbors (first-order and high-order neighbors) similar, which leads to the loss of information of the node itself. Therefore, the present invention proposes a node self-information completion branch, that is, to reduce the loss of node information itself through the attribute reconstruction process. The proposed model constructs positive and negative samples through a non-enhancement process and alleviates the information loss problem.
[0049] Example 1
[0050] Figure 1 The flow chart of the model building method for generating positive and negative sample nodes in this embodiment is shown. Figure 1 The method is described in detail and specifically comprises the following steps:
[0051] S1: Construct a neural network including an encoder, a positive and negative sample node generation branch, a global information completion branch and a node self-information completion branch. The positive and negative sample node generation branch, the global information completion branch and the node self-information completion branch are connected in parallel to the output end of the encoder; the encoder is used to encode the input graph data to obtain the node feature matrix; the positive and negative sample node generation branch is used to enhance the node feature matrix through the first multi-layer perceptron to obtain the positive and negative sample node matrix, and the first-order neighbor nodes directly connected to the target node in the positive and negative sample node matrix are used as positive sample nodes, and other nodes are used as negative sample nodes; the global information completion branch is used to calculate the similarity between nodes according to the node feature matrix to introduce high-order non-neighbor node information that is not directly connected to the target node to obtain the node global propagation matrix; and the node global propagation matrix is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information; the node self-information completion branch is used to decode the node feature matrix to map the node feature matrix to the input graph data form to obtain the reconstructed graph data. The constructed neural network structure is as follows Figure 2 As shown, specifically:
[0052] S101: Use the encoder to simultaneously process the topological and semantic information to obtain the node feature matrix, and further process the node representation using an MLP layer (Multi-Layer Perceptron) with two hidden layers and a ReLU (Rectified Linear Unit) activation function.
[0053] First, the present invention uses an encoder composed of a two-layer GCN to simultaneously process topological and semantic information to obtain a node feature matrix, which is performed by the following formula:
[0054] Z=g φ (X, A)
[0055] Where Z is the node feature matrix; g φ (·) is an encoder composed of two layers of GCN; X is the feature matrix of the input graph data, and A is the adjacency matrix of the input graph data.
[0056] S102: Enhance the node feature matrix through the first multi-layer perceptron to obtain the positive and negative sample node matrix:
[0057] H base =f α (Z)
[0058] Among them, H base The node feature matrix Z passes through the first multi-layer perceptron f α (·) The positive and negative sample node matrix obtained after enhancement, H base The i-th row of the matrix Hi base is the learned representation vector of node i.
[0059] S103: Design a global propagation matrix for information propagation and aggregation, search for global similar nodes and complete global information completion. Including:
[0060] (1) Using the node feature matrix to calculate the similarity between nodes to construct the node global propagation matrix;
[0061] High-order similar nodes regarded as negative samples can also provide meaningful information for the target node, so the present invention designs a global information completion branch. First, the node global propagation matrix is constructed by calculating the similarity between nodes, which is obtained by the following formula:
[0062]
[0063] In the formula, A ij GP is the node global propagation matrix A GP The value at position (i, j) in z i ∈Z and z j ∈Z, is the representation vector of nodes i and j in the node feature matrix Z; sim(·) is the cosine similarity function; γ is a parameter used to control the sensitivity of the function.
[0064] (2) Using the node global propagation matrix as a new graph structure, a global feature matrix with global information is obtained through weighted propagation and aggregation; using this matrix A GP As a new graph structure, the global feature matrix Z with global information is obtained through weighted propagation and aggregation. PPG .
[0065] Z PPG =A GP ·f β (Z)
[0066] In the formula, Z PPG is the global feature matrix; f β (·) is the second multilayer perceptron.
[0067] S104: Based on the generative model, a self-information completion branch is designed to reconstruct node attributes, thereby constraining the encoder to complete the node's self-information and alleviating the problem of node self-information loss caused by extensive information sharing between samples. A decoder composed of a two-layer GCN is used to reconstruct node attributes;
[0068]
[0069] In the formula, is the reconstructed image data; g θ(·) is a decoder consisting of a two-layer GCN.
[0070] S2: Construct a data set and use the data set to train the neural network. During the training process, by iterating the weight parameters in the neural network, the ratio of the distance between the positive sample node and the target node output by the positive and negative sample node generation branch and the distance between the negative sample node and the target node, the gap between the global feature matrix output by the global information completion branch and the node feature matrix, and the gap between the reconstructed graph data output by the node self-information completion branch and the input graph data are minimized to obtain a model of positive and negative sample nodes for generating target nodes set in the graph data.
[0071] S201: Use the encoder to process the topological and semantic information simultaneously to obtain the node feature matrix, and use the MLP layer (Multi-Layer Perceptron) with two hidden layers and ReLU (Rectified Linear Unit) activation function to further process the node representation, and use self-supervised learning to train the model. In the stage of using self-supervised learning to train the model, the present invention uses the first-order neighbors of the target node as positive samples, and other nodes and the target node itself as negative samples, and designs the loss function of self-supervised learning in accordance with the InfoNCE (Information Noise Contrastive Estimation) objective function:
[0072]
[0073] in, Generate loss function for positive and negative sample nodes, N is the number of nodes, v i is the i-th node; InfoNCE() is the information noise contrast estimation objective function, which is used to calculate the ratio of the distance between the target node and the positive sample node and the distance between the target node and the negative sample node output by the first multilayer perceptron, sim(·) is the cosine similarity function, N(v) represents the first-order neighbors of the target node v, V represents all nodes, and H base is the positive and negative sample node matrix output by the first multilayer perceptron, and They are respectively the nodes v in the positive and negative sample node matrices 、 Characterization of nodes u and k, τ is the temperature parameter.
[0074] S202: Implement consistency measurement through cosine similarity and design loss function.
[0075] Since the present invention hopes to be based on the propagation matrix Z PPG The node representation of is consistent before and after propagation, so the consistency measurement is achieved through cosine similarity, which is obtained by the following formula:
[0076]
[0077] in, is the global information completion loss function, z i ∈Z is the representation of node i in the node feature matrix Z, z i ppg ∈Z PPG The global feature matrix Z with global information output by the second multi-layer perceptron PPG The new representation corresponding to node i in ; sim(·) is the cosine similarity function.
[0078] S203: Use the MSE function (mean squared error function) to maximize the consistency between node attributes before and after reconstruction; design the loss function of the self-information branch:
[0079]
[0080] in, is the node self-information completion task loss function, x i is the characterization vector of node i in the input graph data, is the representation vector of the reconstructed node i in the reconstructed graph data output by the decoder; ij is the jth element of the vector representing node i, Reconstruct the jth element of the representation vector of node i, where d is the dimension of the node representation vector.
[0081] Based on the above three loss functions, the total loss function can be obtained:
[0082]
[0083] In order to verify the performance of the proposed method in learning graph data representation, first, the present invention conducts experiments on six benchmark datasets, specifically (1) citation network datasets Cora, Citeseer, and Pubmed; (2) co-author dataset CS; (3) co-purchase datasets Amazon Photo and Amazon Computers. The detailed characteristics of the datasets are shown in Table 1.
[0084] Table 1 Dataset characteristics
[0085] Dataset name Number of categories Number of nodes Number of edges Number of features Cora 7 2,708 5,429 1,433 <![CDATA[ Citeseer ]]> 6 3,327 4,732 3,703 <![CDATA[ Pubmed ]]> 3 19,717 44,338 500 CS 15 18,333 81,894 6,805 Photo 8 7,650 119,081 745 Computers 10 13,752 245,861 767
[0086] Secondly, in order to evaluate the effectiveness of the method of the present invention, the present invention will use the following fourteen benchmark methods and the method of the present invention to conduct node classification experiments on the graph data in the above six data sets. The seven benchmark methods include: GCN (Graph Convolutional Networks) and GAT (Graph Attention Networks): classic semi-supervised graph neural networks. Deepwalk: a model based on random walks. DGI (Deep GraphInfomax), GMI (Graph representation learning via graphical mutual informationmaximization), MVGRL (Contrastive multi-view representation learning ongraphs): self-supervised models based on mutual information. GRACE (Deep graph contrastive representationlearning), ProGCL (Progcl: rethinking hard negative mining in graph contrastivelearning): self-supervised models based on contrastive learning methods with negative sampling. GBT (Graph barlow twins: a self-supervised representation learning framework for graphs): a self-supervised model based on feature decorrelation. AFGRL (Augmentation-free self-supervised learning on graphs), AFGCL (Augmentation-free graph contrastive learning), LOCAL-GCL (Localizedcontrastive learning on graphs), HomoGCL (Homogcl: rethinking homophily in graphcontrastive learning): self-supervised model based on no enhancement.
[0087] The above fourteen benchmark methods and the method of the present invention are used to perform node classification experiments on graph data in six datasets. In the experiment, the present invention follows the downstream classifier settings in GRACE. In particular, AFGRL retains the best performing parameter settings and the same downstream classifier in the original paper. The experimental results of the node classification results are shown in Table 2:
[0088] Table 2 Comparison of node classification results
[0089]
[0090] 1) The proposed method performs best on 4 out of 6 datasets, but performs poorly on the other two datasets. On average, the proposed method outperforms the best baseline model based on enhancement (i.e., GRACE) by 1.05% in node classification. In addition, the proposed method outperforms the best baseline model based on no enhancement (i.e., AFGRL) by 1.06%. At the same time, the proposed method outperforms the supervised method on all datasets.
[0091] 2) The present invention believes that the excellent performance of the proposed model is attributed to the fact that the model comprehensively considers information from three perspectives: local neighbors, global neighbors, and self-information. This makes the learned node representations contain rich local and global information. At the same time, maintaining node self-information is conducive to maintaining the spatial characteristics of the node itself to avoid excessive clustering of nodes in space. Experiments show that the completely non-enhancement method proposed in the present invention can reduce information loss without manual intervention, and outperforms previous contrastive learning frameworks in downstream task performance.
[0092] 3) Use the encoder to obtain node representation, and use the topological and semantic information to construct positive and negative samples at the same time. The first-order neighbors of the target node are used as positive samples, and other nodes are directly used as negative samples, thereby completely avoiding the enhancement process and using self-supervised learning to train the model; design a global propagation matrix for information propagation and aggregation, search for globally similar nodes and complete global information completion; design a self-information completion branch based on the generative model to reconstruct node attributes, thereby constraining the encoder to complete the self-information of the node and alleviating the problem of node self-information loss caused by extensive information sharing between samples.
[0093] The above is a model building method for generating positive and negative sample nodes provided by one or more embodiments of the present invention. Based on the same idea, the present invention also provides a corresponding model building device for generating positive and negative sample nodes, including:
[0094] A model construction module is used to construct a neural network including an encoder, a positive and negative sample node generation branch, a global information completion branch and a node self-information completion branch, wherein the positive and negative sample node generation branch, the global information completion branch and the node self-information completion branch are connected in parallel to the output end of the encoder; the encoder is used to encode the input graph data to obtain a node feature matrix; the positive and negative sample node generation branch is used to enhance the node feature matrix through a first multi-layer perceptron to obtain a positive and negative sample node matrix, and the first-order neighbor nodes directly connected to the target node in the positive and negative sample node matrix are used as positive sample nodes, and other nodes are used as negative sample nodes; the global information completion branch is used to calculate the similarity between nodes according to the node feature matrix to introduce high-order non-neighbor node information that is not directly connected to the target node to obtain a node global propagation matrix; and the node global propagation matrix is weightedly propagated and aggregated through a second multi-layer perceptron to obtain a global feature matrix with global information; the node self-information completion branch is used to decode the node feature matrix to map the node feature matrix into the input graph data form to obtain reconstructed graph data.
[0095] The model training module is used to construct a data set and use the data set to train the neural network. During the training process, by iterating the weight parameters in the neural network, the ratio of the distance between the positive sample node and the target node output by the positive and negative sample node generation branch and the distance between the negative sample node and the target node, the gap between the global feature matrix output by the global information completion branch and the node feature matrix, and the gap between the reconstructed graph data output by the node self-information completion branch and the input graph data are minimized to obtain a model of positive and negative sample nodes for generating target nodes set in the graph data.
[0096] For the specific definition of the model building device for generating positive and negative sample nodes, please refer to the definition of the model building method for generating positive and negative sample nodes in the above text, which will not be repeated here. Each module in the above-mentioned model building device for generating positive and negative sample nodes can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0097] The present invention also provides a computer device structure. At the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 The model building method provided for generating positive and negative sample nodes.
[0098] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0099] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, 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, they should be considered to be within the scope of the present invention.
Claims
1. A model construction method for generating positive and negative sample nodes, used to generate positive and negative sample nodes of target nodes set in graph data, characterized in that: include: Constructing a neural network including an encoder, a positive and negative sample node generation branch, a global information completion branch, and a node self-information completion branch, wherein the positive and negative sample node generation branch, the global information completion branch, and the node self-information completion branch are connected in parallel to the output end of the encoder; The encoder is used to encode the input graph data to obtain a node feature matrix; The positive and negative sample node generation branch is used to enhance the node feature matrix through the first multi-layer perceptron to obtain the positive and negative sample node matrix, and take the first-order neighbor nodes directly connected to the target node in the positive and negative sample node matrix as positive sample nodes and other nodes as negative sample nodes; The global information completion branch is used to calculate the similarity between nodes according to the node feature matrix, so as to introduce the high-order non-neighbor node information that is not directly connected to the target node, and obtain the node global propagation matrix; and the node global propagation matrix is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information; The node self-information completion branch is used to decode the node feature matrix to map the node feature matrix into an input graph data form to obtain reconstructed graph data; A data set is constructed and the neural network is trained using the data set. During the training process, by iterating the weight parameters in the neural network, the ratio of the distance between the positive sample node and the target node output by the positive and negative sample node generation branch and the distance between the negative sample node and the target node, the gap between the global feature matrix output by the global information completion branch and the node feature matrix, and the gap between the reconstructed graph data output by the node self-information completion branch and the input graph data are minimized to obtain a model of positive and negative sample nodes for generating the target node set in the graph data.
2. The model construction method for generating positive and negative sample nodes according to claim 1, characterized in that: The encoding of the input graph data to obtain the node feature matrix specifically includes: Z=g φ (X,A) Among them, Z is the node feature matrix; g φ (·) is an encoder composed of two layers of GCN; X is the feature matrix of the input graph data, and A is the adjacency matrix of the input graph data.
3. The model construction method for generating positive and negative sample nodes according to claim 2, characterized in that: The node feature matrix is enhanced by the first multi-layer perceptron to obtain a positive and negative sample node matrix, specifically including: H base =f α (Z) Among them, H base The node feature matrix Z passes through the first multi-layer perceptron f α (·) The positive and negative sample node matrix obtained after enhancement, H base The i-th row of the matrix H i base is the learned representation vector of node i.
4. The model construction method for generating positive and negative sample nodes according to claim 2, characterized in that: The similarity between nodes is calculated according to the node feature matrix to introduce high-order non-neighbor node information that is not directly connected to the target node, and obtain the node global propagation matrix; The global propagation matrix of the nodes is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information, including: The node feature matrix is used to calculate the similarity between nodes to construct the node global propagation matrix: In the formula, A ij GP is the node global propagation matrix A GP The value at position (i, j) in z i ∈Z and z j ∈Z, is the representation vector of nodes i and j in the node feature matrix Z; sim(·) is the cosine similarity function; γ is a parameter used to control the sensitivity of the function; The global propagation matrix of the nodes is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information: Z PPG =A GP ·f β (Z) In the formula, Z PPG is the global feature matrix; f β (·) is the second multilayer perceptron.
5. The model construction method for generating positive and negative sample nodes according to claim 2, characterized in that: The decoding of the node feature matrix to map the node feature matrix into an input graph data form to obtain the reconstructed graph data specifically includes: In the formula, is the reconstructed image data; g θ (·) is a decoder consisting of a two-layer GCN.
6. The model construction method for generating positive and negative sample nodes according to claim 1, characterized in that: The method of minimizing the ratio of the distance between the positive sample node and the target node output by the positive and negative sample node generation branch and the distance between the negative sample node and the target node, the gap between the global feature matrix output by the global information completion branch and the node feature matrix, and the gap between the reconstructed graph data output by the node self-information completion branch and the input graph data is implemented based on a loss function, wherein the loss function for: in, Generate loss function for positive and negative sample nodes, N is the number of nodes, v i is the i-th node; InfoNCE() is the information noise contrast estimation objective function, which is used to calculate the ratio of the distance between the target node and the positive sample node and the distance between the target node and the negative sample node output by the first multilayer perceptron, sim(·) is the cosine similarity function, N(v) represents the first-order neighbors of the target node v, V represents all nodes, and H base is the positive and negative sample node matrix output by the first multilayer perceptron, and They are respectively the nodes v in the positive and negative sample node matrices 、 Characterization of nodes u and k, τ is the temperature parameter; is the global information completion loss function, z i is the representation of node i in the node feature matrix Z, z i ppg The global feature matrix Z output by the second multilayer perceptron PPG The new representation corresponding to the middle node i; is the node self-information completion task loss function, x i is the characterization vector of node i in the input graph data, is the representation vector of the reconstructed node i in the reconstructed graph data output by the decoder; ij is the jth element of the vector representing node i, Reconstruct the jth element of the representation vector of node i, where d is the dimension of the node representation vector.
7. A model building device for generating positive and negative sample nodes, characterized in that: include: A model construction module, used to construct a neural network including an encoder, a positive and negative sample node generation branch, a global information completion branch, and a node self-information completion branch, wherein the positive and negative sample node generation branch, the global information completion branch, and the node self-information completion branch are connected in parallel to the output end of the encoder; The encoder is used to encode the input graph data to obtain a node feature matrix; The positive and negative sample node generation branch is used to enhance the node feature matrix through the first multi-layer perceptron to obtain the positive and negative sample node matrix, and take the first-order neighbor nodes directly connected to the target node in the positive and negative sample node matrix as positive sample nodes and other nodes as negative sample nodes; The global information completion branch is used to calculate the similarity between nodes according to the node feature matrix, so as to introduce the high-order non-neighbor node information that is not directly connected to the target node, and obtain the node global propagation matrix; and the node global propagation matrix is weightedly propagated and aggregated through the second multi-layer perceptron to obtain a global feature matrix with global information; The node self-information completion branch is used to decode the node feature matrix to map the node feature matrix into an input graph data form to obtain reconstructed graph data; The model training module is used to construct a data set and use the data set to train the neural network. During the training process, by iterating the weight parameters in the neural network, the ratio of the distance between the positive sample node and the target node output by the positive and negative sample node generation branch and the distance between the negative sample node and the target node, the gap between the global feature matrix output by the global information completion branch and the node feature matrix, and the gap between the reconstructed graph data output by the node self-information completion branch and the input graph data are minimized to obtain a model of positive and negative sample nodes for generating target nodes set in the graph data.
8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Model construction method and device for generating positive and negative sample nodes, medium and equipment
CN121350250A
