Training method, device, equipment and medium for dual-view graph neural network model
By employing a dual-view graph neural network model training method, which utilizes complementary perspectives of nodes and edges for comparative learning, the problem of ignoring edge information in existing models is solved, thereby improving the model's transferability and generalization ability and achieving more efficient graph data processing.
Patent Information
- Application Number
- CN202210290121.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-23
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2042-03-23
AI Technical Summary
Existing graph neural network models mainly utilize node features when processing graph data, ignoring edge information, resulting in insufficient transferability and generalization ability.
A dual-view graph neural network model is adopted. By swapping the positions of nodes and edges, node and edge feature matrices are constructed. These matrices are then input into the node-view and edge-view networks respectively for comparative learning. The node-view and edge-view networks are jointly trained to update the model parameters.
It improves the model's transferability and generalization ability, allowing the model to be directly fine-tuned and used in downstream tasks, reducing the need for repeated training, and achieving more effective graph representation learning.
Smart Images

Figure CN114707641B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a training method, device, equipment and medium for a dual-view graph neural network model. Background Art
[0002] Graph data is a data structure, and graph neural network is a branch of deep learning based on graph structure. Common graph data contains nodes and edges, where nodes contain entity information and edges contain relationship information between entities. Many learning tasks now require processing graph data, such as physical system modeling, social network analysis, traffic network analysis, protein structure prediction, and molecular property prediction. These all require the model to learn relevant knowledge from the input of graph data, so the graph neural network model was born.
[0003] Although graph neural networks have achieved great success in the past few years, in supervised or semi-supervised machine learning models, most models are built based on "aggregating neighbor information and updating the node's own state". In this paradigm, node features are fully learned. However, in many real graph data, there is rich information on the edges, which is not fully utilized in most current models.
[0004] The inventors realized that in the above-mentioned comparative learning method, for the need for the model to learn knowledge that is highly transferable, reusable, and common, this approach of only focusing on node information will result in the graph data being used in the model, usually mainly utilizing node features and ignoring edge information, resulting in the model's insufficient transferability and generalization capabilities. Summary of the invention
[0005] The purpose of the present invention is to provide a training method, device, equipment and medium for a dual-view graph neural network model to solve the technical problem that when graph data is used in the model, node features are usually mainly utilized and edge information is ignored, resulting in insufficient model mobility and generalization capabilities.
[0006] In a first aspect, a training method for a dual-view graph neural network model is provided, comprising:
[0007] Obtaining a plurality of graph data with labels, wherein the graph data includes nodes, edges and attribute information, and constructing a node feature matrix and a node adjacency matrix based on the attribute information;
[0008] Interchanging positions of nodes and edges in the graph data to obtain the interchanged graph data, and constructing an edge feature matrix and an edge adjacency matrix based on attribute information of the interchanged graph data;
[0009] Inputting the node feature matrix and the node adjacency matrix into a node perspective network of a dual-perspective graph neural network model to be trained, and obtaining a first judgment result of the graph data, wherein the node perspective network is a GNN network;
[0010] Inputting the edge feature matrix and the edge adjacency matrix into the edge view network of the dual-view graph neural network model to be trained to obtain a second judgment result of the graph data, wherein the edge view network is a GNN network;
[0011] The first judgment result of the graph data and the second judgment result of the graph data are weighted to obtain the judgment result of the graph data, and based on the judgment result of the graph data and the label of the graph data, the node perspective network and the edge perspective network are jointly trained to update the parameters of the dual-perspective graph neural network model to be trained to obtain a trained dual-perspective graph neural network model.
[0012] In a second aspect, a training device for a dual-view graph neural network model is provided, comprising:
[0013] A graph data acquisition module, used to obtain a plurality of graph data with labels, wherein the graph data includes nodes, edges and attribute information, and construct a node feature matrix and a node adjacency matrix based on the attribute information;
[0014] A post-interchange graph data acquisition module, used for interchanging the positions of nodes and edges in the graph data, obtaining the post-interchange graph data, and constructing an edge feature matrix and an edge adjacency matrix based on the attribute information of the post-interchange graph data;
[0015] A first judgment result acquisition module is used to input the node feature matrix and the node adjacency matrix into a node perspective network of a dual-perspective graph neural network model to be trained to obtain a first judgment result of the graph data, wherein the node perspective network is a GNN network;
[0016] A second judgment result acquisition module is used to input the edge feature matrix and the edge adjacency matrix into the edge view network of the dual-view graph neural network model to be trained to obtain a second judgment result of the graph data, wherein the edge view network is a GNN network;
[0017] The model training module is used to weight the first judgment result of the graph data and the second judgment result of the graph data to obtain the judgment result of the graph data, and based on the judgment result of the graph data and the label of the graph data, jointly train the node perspective network and the edge perspective network, update the parameters of the dual-perspective graph neural network model to be trained, and obtain a trained dual-perspective graph neural network model.
[0018] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned intelligent question and answer processing method when executing the computer program.
[0019] In a fourth aspect, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned intelligent question and answer processing method are implemented.
[0020] The training method, system, device and medium of the dual-view graph neural network model of the present invention designs the contrast learning of node and edge complementary perspectives to train the graph neural network, inputs the node feature matrix and the node adjacency matrix into the node perspective network, inputs the edge feature matrix and the edge adjacency matrix into the edge perspective network, and trains the two networks at the same time, so that the update of the weights in the two networks is related to the features of the nodes and edges, and finally obtains the trained dual-view graph neural network model. The idea of contrast learning is adopted to construct positive and negative samples from the input data, so that the model can distinguish positive and negative samples in the implicit representation space, make full use of the feature information of nodes and edges, and make the model have good migration. The obtained model has good generalization. When it is necessary to solve specific downstream tasks, the trained dual-view graph neural network model can be directly used for fine-tuning, thereby avoiding training a new model from scratch for each downstream task. In addition, the proposed dual-view graph neural network self-supervised training strategy can more effectively learn rich key graph representation information, capture the general structural laws in node and edge data, and then give it the fitting ability on downstream graph mining tasks of unlimited types. On the other hand, the method of the present invention transforms the original method of manual parameter adjustment and reliance on machine learning engineers and experts into a method that is applicable to large-scale and replicable industrial deployment. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the description of the embodiments of the present invention are briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative labor:
[0022] Figure 1 Shown is a schematic diagram of an application environment of a training method for a dual-view graph neural network model in an embodiment of the present invention;
[0023] Figure 2 Shown is a schematic flow chart of a training method for a dual-view graph neural network model in one embodiment of the present invention;
[0024] Figure 3It is a schematic diagram of the process of step S30 in one embodiment of the present invention;
[0025] Figure 4 It is a schematic diagram of the process of step S31 in one embodiment of the present invention;
[0026] Figure 5 It is a schematic diagram of the process of step S40 in one embodiment of the present invention;
[0027] Figure 6 Shown is a structural block diagram of a training device for a dual-view graph neural network model in one embodiment of the present invention;
[0028] Figure 7 is a schematic diagram of a structure of a computer device in one embodiment of the present invention;
[0029] Figure 8 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0030] The training method of the dual-view graph neural network model provided by the embodiment of the present invention can be applied to Figure 1 In the application environment of , the client communicates with the server through the network. The server can train the graph neural network through the client design of contrastive learning of complementary perspectives of nodes and edges. By inputting the node feature matrix and the node adjacency matrix into the node perspective network, and the edge feature matrix and the edge adjacency matrix into the edge perspective network, the two networks are trained at the same time, so that the update of the weights in the two networks is related to the features of both nodes and edges, and finally a trained dual-view graph neural network model is obtained. Using the idea of contrastive learning, positive and negative samples are constructed from the input data, so that the model can distinguish positive and negative samples in the implicit representation space, make full use of the feature information of nodes and edges, and make the model have good transferability. The obtained model has good generalization. When it is necessary to solve specific downstream tasks, the trained dual-view graph neural network model can be directly used for fine-tuning, thereby avoiding training a new model from scratch for each downstream task. In addition, the proposed dual-view graph network self-supervised training strategy can more effectively learn rich key graph representation information, capture the general structural laws in node and edge data, and then give it the ability to fit downstream graph mining tasks of unlimited types. On the other hand, the method of the present invention transforms the original manual parameter adjustment, relying on machine learning engineers and experts, into a method that is applicable to large-scale and replicable industrial deployment. Among them, the client can be but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server can be implemented with an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments.
[0031] See also Figure 2 As shown, Figure 2 A flow chart of a training method for a dual-view graph neural network model provided by an embodiment of the present invention includes the following steps:
[0032] S10. Obtain a plurality of graph data with labels, wherein the graph data includes nodes, edges and attribute information, and construct a node feature matrix and a node adjacency matrix based on the attribute information.
[0033] In this embodiment, the graph data is obtained from an open source graph database or a self-made data set, and the specific acquisition method is not limited. Among them, the graph data stores and queries data in the data structure of "graph", and its data model is mainly embodied in attribute information, nodes and edges. The attribute information of the graph data refers to the information contained in the nodes and edges that characterizes the properties of the graph data itself. For example, for the graph data of compounds, its attribute information can be the properties of each atom in the compound, the specific atomic structure, etc. Graph data can quickly solve complex relationship problems through the combination of nodes and edges. For example, for the compound structure, the node represents each atom in the compound, and the edge represents the information of the chemical bond connecting the atoms. Each node in the graph data is connected to the adjacent nodes by an edge, thereby forming a node adjacency matrix. For graph data with N nodes, the node adjacency matrix is a matrix with N rows and N columns, and the element of the i-th row and j-th column in the node adjacency matrix indicates "whether there is an edge between nodes i and j". One of the representation methods is: if there is an edge between nodes i and j, then this element is 1, otherwise it is 0. Of course, it can also be expressed as: if there is an edge between nodes i and j, then this element is 0, otherwise it is 1. The node feature matrix represents the features of each node contained in the graph data, and each row in the node feature matrix represents the features of a node in the graph data. For example, for a compound, the features of a node can be the size of each atom, the weight of the atom, etc.
[0034] S20, exchanging the positions of nodes and edges in the graph data to obtain the graph data after the exchange, and constructing an edge feature matrix and an edge adjacency matrix based on the attribute information of the graph data after the exchange;
[0035] In this embodiment, considering that contrastive learning is one of the most effective technical means in self-supervised learning. The so-called self-supervised contrastive learning is actually for any two data points, the more similar (belonging to the same category), the closer their graph representation will be. The self-supervised learning model based on contrastive learning has achieved great success in image and sequence-based language data structures. The idea is mainly to construct different samples from the input data, and learn the features in the input data by guiding the pre-trained model to discriminate positive and negative samples in the implicit representation space. Based on the above considerations, considering that there are a series of features in the edge, by exchanging nodes and edges, the nodes of the original graph become the edges of the new graph, and the edges of the original graph become the nodes of the new graph, and the graph data of the dual perspective is constructed. At this time, the two perspective information is complementary, and a more fully enriched contrastive learning effect can be obtained. The construction method of the edge feature matrix and the edge adjacency matrix is similar to the above-mentioned node feature matrix and node adjacency matrix, which will not be repeated here. By randomly changing the order between any two or more rows of the edge feature matrix, a negative sample edge feature matrix is obtained. For example, for the three nodes with row numbers 1, 2, and 3 in the edge feature matrix, the positions of the first node and the second node are changed to obtain the negative sample edge feature matrix of 2, 1, and 3.
[0036] S30. Input the node feature matrix and the node adjacency matrix into the node perspective network of the dual-perspective graph neural network model to be trained to obtain a first judgment result of the graph data, where the node perspective network is a GNN network.
[0037] In step S30, the node feature matrix and the node adjacency matrix are input into the node perspective network to obtain a first judgment result of the graph data, including:
[0038] S31, inputting the node feature matrix and the node adjacency matrix into the node perspective network to extract local features of the nodes;
[0039] S32: Compare the local features of the node with the preset average features of the node to obtain a first judgment result of the graph data.
[0040] Specifically, step S31 includes the following process:
[0041] S311, performing feature perturbation processing on the node feature matrix to obtain a negative sample feature matrix of the node;
[0042] S312, inputting the node adjacency matrix, the node feature matrix and the node negative sample feature matrix into the node perspective network, extracting the node positive sample local features and the node negative sample local features, and obtaining the node local features.
[0043] S40. Input the edge feature matrix and the edge adjacency matrix into the edge perspective network of the dual-perspective graph neural network model to be trained to obtain a second judgment result of the graph data, where the edge perspective network is a GNN network.
[0044] In this embodiment, the node feature matrix is subjected to feature perturbation processing to obtain the node negative sample feature matrix, wherein feature perturbation refers to randomly swapping multiple rows of the node feature matrix. For example, there are 4 nodes in the graph data, each node has 32-dimensional features, and the row numbers of the node feature matrix are 1, 2, 3, and 4. After the feature perturbation, the positions of the second node and the third node are swapped. At this time, although the topological structure of the network has not changed, the features of the nodes at each position have changed, and the node negative sample feature matrix is obtained, and the row numbers are 1, 3, 2, and 4. The node feature matrix, the node negative sample feature matrix, and the node adjacency matrix are input into the preset node perspective network. When extracting the local features of the positive samples of the nodes, each convolution layer obtains the relevant features of the positive sample data in the next convolution layer by learning the adjacency matrix and the node feature matrix in the convolution layer. When extracting the local features of the negative samples of the nodes, each convolution layer obtains the relevant features of the negative sample data in the next convolution layer by learning the adjacency matrix and the negative sample feature matrix of the nodes in the convolution layer. By stacking multiple convolutional layers, the aggregation and update of node information in the graph data are achieved. The local features of the positive samples of the nodes and the local features of the negative samples of the nodes together form the local features of the nodes. The local features of the nodes and the average features of the nodes are compared for similarity to obtain the first judgment result of the graph data. The local features of the edges and the average features of the edges are compared for similarity to obtain the second judgment result of the graph data. Among them, the method for extracting the local features of the negative samples of the nodes is: Among them, e is the negative sample local feature of the node, σ is the sigmoid function, is the degree matrix after adding the node feature matrix to the identity matrix, A is the node feature matrix, I is the identity matrix, X is the node adjacency matrix, and θ is the preset parameter matrix. It can be understood that the processing process of the edge perspective network is similar to that of the node perspective network, which will not be repeated here.
[0045] S40, weighting the first judgment result of the graph data and the second judgment result of the graph data to obtain the judgment result of the graph data, and based on the judgment result of the graph data and the label of the graph data, jointly training the node perspective network and the edge perspective network, updating the parameters of the dual-perspective graph neural network model to be trained, and obtaining a trained dual-perspective graph neural network model
[0046] In this embodiment, considering that the characteristics of the individual itself can no longer fully represent all the information of the individual, this may be due to errors in the data collection process or the disguise of some individuals, resulting in deviations in some characteristics. The information of its neighboring nodes is needed to supplement the information of the current node. In turn, more complete information is obtained than the characteristics of a single individual. Therefore, the GCN network is used as a node perspective network and an edge perspective network to extract the characteristics of nodes and edges. The main process of learning the graph neural network model is to aggregate and update the neighbor information of nodes in the graph data through iteration. In one iteration, each node updates its own information by aggregating the characteristics of neighboring nodes and its own characteristics in the previous layer, and usually performs a nonlinear transformation on the aggregated information. By stacking multiple layers of the network, each node can obtain the information of neighboring nodes within the corresponding number of hops. After the node feature matrix and the node adjacency matrix are input into the preset node perspective network, the information of the nodes therein is read through the GCN network to extract the local features of the nodes. The local features of the edges are extracted in the same way, and the loss value is calculated by the loss function, and the weights of the node perspective network and the weights of the edge perspective network are updated according to the loss value. At this time, since the loss value contains information about nodes and edges, when updating the weight of the node perspective network, the information about the edges will be taken into account at the same time. Similarly, when updating the parameters of the edge perspective network, the information about the nodes will be taken into account at the same time, so that the edge perspective network contains node information and the node perspective network contains edge information. During training, joint training of the two is achieved, and dual-perspective network learning is achieved. Specifically, according to the importance of the first judgment result of the graph data and the second judgment result of the graph data, the two can be weighted to obtain the judgment result of the graph data. The calculation method of the judgment result J of the graph data is J=αJ1+βJ2, where J1 is the first judgment result of the graph data, J2 is the second judgment result of the graph data, α is the weight of the first judgment result of the graph data, and β is the weight of the second judgment result of the graph data. α and β are any number in the range of [0,1]. For social network graph data, the nodes contain more information, so the value of α is greater than β; for text sequence graph data, the edges contain more information, so the value of α is less than β. It is understandable that the values of α and β can be adaptively selected by those skilled in the art according to the type of actual graph data.
[0047] In this embodiment, before inputting the node feature matrix and the node adjacency matrix into the preset node perspective network, the method further includes: performing mean processing on the node feature matrix to obtain the average feature of the node. The average feature of the node is obtained by: Where σ is the sigmoid function, M is the number of nodes, and h i is the feature of the i-th node.
[0048] In step S40, the node perspective network and the edge perspective network are jointly trained based on the judgment result of the graph data and the label of the graph data, and the parameters of the dual-perspective graph neural network model to be trained are updated, including the following process:
[0049] S41, obtaining current weight values of the node perspective network and the edge perspective network;
[0050] S42, according to the preset weight update rule, using the loss value and the current weight value to obtain a new weight value;
[0051] S43. Use the new weight value as the weight of the node perspective network and the edge perspective network.
[0052] In this embodiment, the dual-view graph neural network model is constructed based on two GCN networks and a Softmax layer. Specifically, taking link prediction as an example, after the graph data is sent into the two GCN networks, the feature vector of the required information (link) in the graph data is obtained through graph convolution operation, and the feature vector of the required information is sent to the Softmax layer for mapping to obtain the probability value of whether the graph data contains the required information. This probability value is calculated through the loss function, and the parameters and weights in the dual-view graph neural network model are updated according to the calculation results to obtain an updated dual-view graph neural network model. Training is performed again until the loss function converges. After the training is completed, the trained dual-view graph neural network model is obtained and packaged for use. In this embodiment, the weight update rule is: derivative according to the chain rule. Specifically, the error back propagation gradient calculation formula is: Gradp=((w p-1 ) T Grad p-1 )δ, where δ is the current loss value, Gradp is the error back propagation gradient of the pth layer, and w p-1 is the weight of the graph neuron during the p-1th iteration of training. According to the back-propagation gradient, the weight update value is calculated using the following formula: wp = wp-1-ε·Gradp, where ε is the learning rate and wp represents the weight of the current graph neuron. It should be noted that the training process of the node perspective network is similar to that of the edge perspective network, so the training process of the edge perspective network will not be repeated here.
[0053] In this embodiment, the loss value is calculated as Loss=αL1+βL2, where α is the factor parameter of the loss function L1 of the node perspective network, and β is the factor parameter of the loss function L2 of the edge perspective network. That is, the loss function is the sum of the loss function of the node perspective network and the loss function of the edge perspective network. Taking into account the different focuses of the two networks, different factor parameters are set, and the construction of the dual-perspective graph neural network loss function is achieved by adjusting the corresponding factor parameters. During training, the parameters of the two perspective networks are continuously adjusted by the gradient descent method to achieve network construction. Furthermore, the method of inputting the negative sample feature matrix of the node into the node perspective network and extracting the negative sample local features of the node is: Among them, e is the negative sample feature of the node, σ is the sigmoid function, is the degree matrix after adding the node feature matrix to the identity matrix, A is the node feature matrix, I is the identity matrix, X is the node adjacency matrix, and θ is the preset parameter matrix. In this embodiment, the formula of the loss function L1 of the node perspective network is: Among them, N is the number of positive sample nodes, M is the number of negative sample nodes, is the representation vector of the node after extracting local features from the kth positive sample, is the representation vector of the node after extracting local features for the ath negative sample, is the global feature of the positive sample, D is the discriminator, if it approaches 1, it means that the global feature of the positive sample is similar to the local feature, if it approaches 0, it means that the two are not similar. Update the weight value of the node perspective network according to the loss value.
[0054] It can be understood that the dual-view graph neural network model in this embodiment can be applied to a variety of different fields, such as: speech recognition, medical diagnosis, application testing, etc.
[0055] It can be seen that in the above scheme, the contrastive learning of complementary perspectives of nodes and edges is designed to train the graph neural network. By inputting the node feature matrix and the node adjacency matrix into the node perspective network, and the edge feature matrix and the edge adjacency matrix into the edge perspective network, the two networks are trained at the same time, so that the update of the weights in the two networks is related to the features of the nodes and edges, and finally a trained dual-view graph neural network model is obtained. The idea of contrastive learning is adopted to construct positive and negative samples from the input data, so that the model can distinguish positive and negative samples in the implicit representation space, make full use of the feature information of nodes and edges, and make the model have good transferability. The obtained model has good generalization. When it is necessary to solve specific downstream tasks, the trained dual-view graph neural network model can be directly used for fine-tuning, thereby avoiding training a new model from scratch for each downstream task. In addition, the proposed dual-view graph network self-supervised training strategy can more effectively learn rich key graph representation information, capture the general structural laws in node and edge data, and then give it the ability to fit downstream graph mining tasks of unlimited types. On the other hand, the method of the present invention transforms the original method of manual parameter adjustment and reliance on machine learning engineers and experts into a method that is applicable to large-scale and replicable industrial deployment.
[0056] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0057] In one embodiment, a training device for a dual-view graph neural network model is provided, and the training device for the dual-view graph neural network model corresponds one-to-one to the training method for the dual-view graph neural network model in the above embodiment. Figure 6 As shown, the training device of the dual-view graph neural network model includes a graph data acquisition module 111, a swapped graph data acquisition module 112, a first judgment result acquisition module 113, a second judgment result acquisition module 114 and a model training module 115. The functional modules are described in detail as follows:
[0058] The graph data acquisition module 111 is used to obtain a plurality of graph data with labels, wherein the graph data includes nodes, edges and attribute information, and construct a node feature matrix and a node adjacency matrix based on the attribute information.
[0059] The exchanged graph data acquisition module 112 is used to exchange the positions of nodes and edges in the graph data, obtain the exchanged graph data, and construct an edge feature matrix and an edge adjacency matrix based on the attribute information of the exchanged graph data;
[0060] A first judgment result acquisition module 113 is used to input the node feature matrix and the node adjacency matrix into a node perspective network of a dual-perspective graph neural network model to be trained, and obtain a first judgment result of the graph data, wherein the node perspective network is a GNN network;
[0061] A second judgment result acquisition module 114 is used to input the edge feature matrix and the edge adjacency matrix into the edge view network of the dual-view graph neural network model to be trained to obtain a second judgment result of the graph data, wherein the edge view network is a GNN network;
[0062] The model training module 115 is used to weight the first judgment result of the graph data and the second judgment result of the graph data to obtain the judgment result of the graph data, and jointly train the node perspective network and the edge perspective network based on the judgment result of the graph data and the label of the graph data, update the parameters of the dual-perspective graph neural network model to be trained, and obtain a trained dual-perspective graph neural network model.
[0063] In one embodiment, the first judgment result obtaining module 113 is specifically used to:
[0064] Inputting the node feature matrix and the node adjacency matrix into the node perspective network to extract local features of the nodes;
[0065] The local features of the node are compared with the preset average features of the nodes to obtain a first judgment result of the graph data.
[0066] In one embodiment, the first judgment result obtaining module 113 is specifically used to:
[0067] Perform feature perturbation processing on the node feature matrix to obtain the negative sample feature matrix of the node;
[0068] The node feature matrix and the node negative sample feature matrix are input into the node perspective network, the positive sample local features of the node and the negative sample local features of the node are extracted, and the local features of the node are obtained.
[0069] In one embodiment, the first judgment result obtaining module 113 is specifically used to:
[0070] The node feature matrix is averaged to obtain the average features of the node.
[0071] In one embodiment, the first judgment result obtaining module 113 is further used to:
[0072] The method for extracting the local features of negative samples of nodes is: Among them, e is the negative sample local feature of the node, σ is the sigmoid function, is the degree matrix after adding the node feature matrix to the identity matrix, A is the node feature matrix, I is the identity matrix, X is the node adjacency matrix, and θ is the preset parameter matrix.
[0073] In one embodiment, the model training module 115 is specifically used to:
[0074] Obtaining current parameter values of the node perspective network and the edge perspective network;
[0075] According to a preset parameter update rule, a loss value of the graph data judgment result is obtained, and a new parameter value is obtained according to the loss value and the current parameter value;
[0076] The new parameter values are used as parameters of the dual-view graph neural network model to be trained.
[0077] In one embodiment, the model training module 115 is further used to:
[0078] The calculation method of the judgment result J of the graph data is J=αJ1+βJ2, wherein J1 is the first judgment result of the graph data, J2 is the second judgment result of the graph data, α is the weight of the first judgment result of the graph data, and β is the weight of the second judgment result of the graph data.
[0079] The present invention provides a training device for a dual-view graph neural network model, designs contrastive learning of complementary perspectives of nodes and edges to train the graph neural network, inputs a node feature matrix and a node adjacency matrix into a node perspective network, inputs an edge feature matrix and an edge adjacency matrix into an edge perspective network, and trains the two networks simultaneously, so that the update of weights in the two networks is related to the features of both nodes and edges, and finally obtains a trained dual-view graph neural network model. The idea of contrastive learning is adopted to construct positive and negative samples from input data, so that the model can discriminate positive and negative samples in an implicit representation space, and fully utilizes the feature information of nodes and edges, so that the model has good transferability. The obtained model has good generalization. When it is necessary to solve specific downstream tasks, the trained dual-view graph neural network model can be directly used for fine-tuning, thereby avoiding training a new model from scratch for each downstream task. In addition, the proposed dual-view graph network training strategy can more effectively learn rich key graph representation information, capture the general structural laws in node and edge data, and then give it the fitting ability on downstream graph mining tasks of unlimited types. On the other hand, the method of the present invention transforms the original method of manual parameter adjustment and reliance on machine learning engineers and experts into a method that is applicable to large-scale and replicable industrial deployment.
[0080] For the specific limitations on the training device of the dual-view graph neural network model, please refer to the limitations on the training method of the dual-view graph neural network model above, which will not be repeated here. The various modules in the above-mentioned training device of the dual-view graph neural network model can be implemented in whole or in part through 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.
[0081] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client through a network connection. When the computer program is executed by the processor, it implements the functions or steps on the server side of a training method for a dual-view graph neural network model.
[0082] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the client side of a training method for a dual-view graph neural network model
[0083] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0084] Obtaining a plurality of graph data with labels, wherein the graph data includes nodes, edges and attribute information, and constructing a node feature matrix and a node adjacency matrix based on the attribute information;
[0085] Interchanging positions of nodes and edges in the graph data to obtain the interchanged graph data, and constructing an edge feature matrix and an edge adjacency matrix based on attribute information of the interchanged graph data;
[0086] Inputting the node feature matrix and the node adjacency matrix into a node perspective network of a dual-perspective graph neural network model to be trained, and obtaining a first judgment result of the graph data, wherein the node perspective network is a GNN network;
[0087] Inputting the edge feature matrix and the edge adjacency matrix into the edge view network of the dual-view graph neural network model to be trained to obtain a second judgment result of the graph data, wherein the edge view network is a GNN network;
[0088] The first judgment result of the graph data and the second judgment result of the graph data are weighted to obtain the judgment result of the graph data, and based on the judgment result of the graph data and the label of the graph data, the node perspective network and the edge perspective network are jointly trained to update the parameters of the dual-perspective graph neural network model to be trained to obtain a trained dual-perspective graph neural network model.
[0089] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0090] Obtaining a plurality of graph data with labels, wherein the graph data includes nodes, edges and attribute information, and constructing a node feature matrix and a node adjacency matrix based on the attribute information;
[0091] Interchanging positions of nodes and edges in the graph data to obtain the interchanged graph data, and constructing an edge feature matrix and an edge adjacency matrix based on attribute information of the interchanged graph data;
[0092] Inputting the node feature matrix and the node adjacency matrix into a node perspective network of a dual-perspective graph neural network model to be trained, and obtaining a first judgment result of the graph data, wherein the node perspective network is a GNN network;
[0093] Inputting the edge feature matrix and the edge adjacency matrix into the edge view network of the dual-view graph neural network model to be trained to obtain a second judgment result of the graph data, wherein the edge view network is a GNN network;
[0094] The first judgment result of the graph data and the second judgment result of the graph data are weighted to obtain the judgment result of the graph data, and based on the judgment result of the graph data and the label of the graph data, the node perspective network and the edge perspective network are jointly trained to update the parameters of the dual-perspective graph neural network model to be trained to obtain a trained dual-perspective graph neural network model.
[0095] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0096] 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 in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0097] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0098] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A training method for a dual-view graph neural network model, characterized in that: include: Obtaining a plurality of graph data with labels, wherein the graph data includes nodes, edges and attribute information, and constructing a node feature matrix and a node adjacency matrix based on the attribute information; Interchanging positions of nodes and edges in the graph data to obtain the interchanged graph data, and constructing an edge feature matrix and an edge adjacency matrix based on attribute information of the interchanged graph data; Inputting the node feature matrix and the node adjacency matrix into a node perspective network of a dual-perspective graph neural network model to be trained, and obtaining a first judgment result of the graph data, wherein the node perspective network is a GNN network; Inputting the edge feature matrix and the edge adjacency matrix into the edge view network of the dual-view graph neural network model to be trained to obtain a second judgment result of the graph data, wherein the edge view network is a GNN network; The first judgment result of the graph data and the second judgment result of the graph data are weighted to obtain the judgment result of the graph data, and based on the judgment result of the graph data and the label of the graph data, the node perspective network and the edge perspective network are jointly trained to update the parameters of the dual-perspective graph neural network model to be trained to obtain a trained dual-perspective graph neural network model.
2. The training method of the dual-view graph neural network model according to claim 1, characterized in that: The step of inputting the node feature matrix and the node adjacency matrix into the node perspective network to obtain a first judgment result of the graph data includes: Inputting the node feature matrix and the node adjacency matrix into the node perspective network to extract local features of the nodes; The local features of the node are compared with the preset average features of the nodes to obtain a first judgment result of the graph data.
3. The training method of the dual-view graph neural network model according to claim 2, characterized in that: The node feature matrix and the node adjacency matrix are input into the node perspective network to extract the local features of the nodes. The process includes: Perform feature perturbation processing on the node feature matrix to obtain the negative sample feature matrix of the node; The node feature matrix and the node negative sample feature matrix are input into the node perspective network, the positive sample local features of the node and the negative sample local features of the node are extracted, and the local features of the node are obtained.
4. The training method of the dual-view graph neural network model according to claim 3 is characterized in that: The method for extracting the local features of negative samples of nodes is: Among them, e is the negative sample local feature of the node, σ is the sigmoid function, is the degree matrix after adding the node feature matrix to the identity matrix, A is the node feature matrix, I is the identity matrix, X is the node adjacency matrix, and θ is the preset parameter matrix.
5. The training method of the dual-view graph neural network model according to claim 1, characterized in that: The step of jointly training the node perspective network and the edge perspective network based on the judgment result of the graph data and the label of the graph data, and updating the parameters of the dual-perspective graph neural network model to be trained, includes the following process: Obtaining current parameter values of the node perspective network and the edge perspective network; According to a preset parameter update rule, a loss value of the graph data judgment result is obtained, and a new parameter value is obtained according to the loss value and the current parameter value; The new parameter values are used as parameters of the dual-view graph neural network model to be trained.
6. The training method of the dual-view graph neural network model according to claim 1, characterized in that: Before inputting the node feature matrix and the node adjacency matrix into the node perspective network of the dual-perspective graph neural network model to be trained, the method also includes: performing averaging processing on the node feature matrix to obtain the average feature of the node.
7. The training method of the dual-view graph neural network model according to claim 1, characterized in that: The calculation method of the judgment result J of the graph data is J=αJ1+βJ2, wherein J1 is the first judgment result of the graph data, J2 is the second judgment result of the graph data, α is the weight of the first judgment result of the graph data, and β is the weight of the second judgment result of the graph data.
8. A training device for a dual-view graph neural network model, characterized in that: include: A graph data acquisition module, used to obtain a plurality of graph data with labels, wherein the graph data includes nodes, edges and attribute information, and construct a node feature matrix and a node adjacency matrix based on the attribute information; A post-interchange graph data acquisition module, used for interchanging the positions of nodes and edges in the graph data, obtaining the post-interchange graph data, and constructing an edge feature matrix and an edge adjacency matrix based on the attribute information of the post-interchange graph data; A first judgment result acquisition module is used to input the node feature matrix and the node adjacency matrix into a node perspective network of a dual-perspective graph neural network model to be trained to obtain a first judgment result of the graph data, wherein the node perspective network is a GNN network; A second judgment result acquisition module is used to input the edge feature matrix and the edge adjacency matrix into the edge view network of the dual-view graph neural network model to be trained to obtain a second judgment result of the graph data, wherein the edge view network is a GNN network; The model training module is used to weight the first judgment result of the graph data and the second judgment result of the graph data to obtain the judgment result of the graph data, and based on the judgment result of the graph data and the label of the graph data, jointly train the node perspective network and the edge perspective network, update the parameters of the dual-perspective graph neural network model to be trained, and obtain a trained dual-perspective graph neural network model.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
