Dynamic graph representation method and system based on graph neural network and LSTM
By using the DLGN model based on the diagram -based neural network and the improved LSTM memory circulation network in the dynamic graph model, the problem of high dynamic graph model processing costs and the inadequate information update of dynamic graph models have been solved. Essence
Patent Information
- Application Number
- CN202411498012.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-01-24
AI Technical Summary
The prior art has problems such as high processing costs and untimely update of information when processing dynamic graph models.
A dynamic graph representation method based on graph neural network and improved LSTM memory recurrent network is adopted, and the DLGN model is formed by using the GIN graph neural network as the propagation component of the DGNN model and improving the input framework of the LSTM memory recurrent network. The model aggregates node information through a graph neural network and uses an improved LSTM update component to obtain dynamic time series information of the graph network, which improves the model's ability to extract time information.
It improves the learning ability of dynamic graph network node structure, reduces the processing cost and information update delay of the model, and significantly improves the effect of node embedding vectors in node classification and link prediction tasks.
Smart Images

Figure CN119357437A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of dynamic graph representation, and more specifically, relates to a dynamic graph representation method and system based on graph neural network and LSTM. Background Art
[0002] In real life, many data can be represented by graph structures, such as social networks, biomedical protein structures, recommendation systems, etc. Dynamic graph networks refer to graph structures that change over time, in which the properties of nodes (vertices) and edges (edges) may be dynamically updated. Unlike static graphs, dynamic graph networks are used to represent complex systems that evolve over time, such as user interactions in social networks, changes in road conditions in traffic networks, and gene relationships in biological networks. . Researching graph structures will have a positive and important impact on people's daily lives. The existing graph neural network design models are mainly designed for static graph structures. The central idea is to apply deep learning neural networks to aggregate node neighbor information. Many scholars have made improvements and innovations on aggregation functions, training strategies, and algorithm efficiency based on this, resulting in models such as GraphSAGE, GAT, and GIN.
[0003] Among them, GraphSAGE is a graph neural network model, the core of which is to learn how to generate node embeddings by sampling and aggregating information of neighbor nodes. It solves the problem of large-scale data processing in static graphs, but in dynamic graphs, the effect of GraphSAGE may be limited due to the frequent changes in structure and node information. GAT introduces an attention mechanism to weight the importance of neighbor nodes, which can theoretically adapt to the changes of dynamic graphs, but in practical applications, the real-time adjustment of the attention mechanism is a challenge for large-scale dynamic graphs. GIN aims to better capture the structural information of the graph and is very effective in distinguishing different graph structures. However, for time series data or rapid changes in dynamic graphs, the GIN model may need further adjustment and optimization. But the graph models in real life are all dynamic networks. The relationship between recommendation system products and users, and the interaction between individuals in social networks will change over time. At present, some of the more famous dynamic graph neural network research models are mainly EvolveGCN, DySAT, and DyGNN. The EvolveGCN model processes dynamic graphs by evolving the weights of a graph convolutional network (GCN) over time. However, it may encounter performance and efficiency issues when processing large-scale graph data. The DySAT model captures the spatiotemporal characteristics of dynamic graphs by combining structural attention and temporal attention. Although effective, this approach may have high computational costs in real-time big data processing. The DyGNN model captures the temporal dependencies in the graph by constructing a dynamic graph neural network. However, it cannot maintain efficient temporal information updates, especially in scenarios where nodes and edges change frequently. Summary of the invention
[0004] In order to solve the deficiencies in the prior art, the present invention provides a dynamic graph representation method based on graph neural network and LSTM, which solves the technical problems in the prior art of high processing cost of dynamic graph models and untimely information updating.
[0005] The present invention adopts the following technical solution.
[0006] A dynamic graph representation method based on graph neural network and LSTM includes the following steps:
[0007] The DLGN model is obtained by improving the DGNN model based on the graph neural network and the improved LSTM memory recurrent network. The improvements include using the GIN graph neural network as the propagation component of the DGNN model and improving the input framework of the LSTM memory recurrent network and using it as the update component of the DGNN model.
[0008] Collect training data sets, divide the time series length into different time periods according to the activity frequency ratio, and train the DLGN model;
[0009] The dynamic graph node vector is initialized based on the connection information of the dynamic graph nodes over time. After obtaining the dynamic graph node initialization vector, the trained DLGN model is input to obtain the node embedding vector. The node embedding vector is used to characterize the structural characteristics of the dynamic graph network with time-varying node information.
[0010] Preferably, the improved DLGN model includes: a GIN graph neural network, an update component consisting of an improved LSTM memory recurrent network, and a propagation component of the DGNN model;
[0011] The graph neural network is used to aggregate the neighbor information of the nodes in the input vector to obtain the output vector;
[0012] The update component composed of the improved LSTM memory recurrent network updates the state representation of the node on the output vector of the GIN graph neural network. The propagation component of the DLGN model is used to transmit the node's interactive information to the feature vector of the neighboring node.
[0013] Preferably, the node update rule of the GIN model can be expressed as the following formula:
[0014]
[0015] In the formula, is the representation of node v at the kth layer;
[0016] MLP (k) Represents a multilayer perceptron, which is used for nonlinear transformation of node features at the kth layer;
[0017] ε (k) is a learnable parameter or a fixed scalar that adjusts the importance of a node’s own features and its neighbor’s features;
[0018] is the feature representation of node v at the k-1 layer;
[0019] The sum of the feature representations of all neighbors of node v;
[0020] Represents the set of adjacent nodes of node v.
[0021] Preferably, the input framework of the LSTM memory recurrent network is improved: including adding an input framework in the LSTM memory recurrent network to process the input data, the input framework including an activation function, a discount function, an update control gate and an adder, and the output result after the input framework processing is used as the input C of the memory cell of the LSTM memory recurrent network v (t-), specifically including:
[0022] The state value C of the memory cell v (t-) is the state representation of the node at the most recent time point. The state value of the node memory cell includes long-term memory and short-term memory T u (Update the output of the control gate), the expression of the state value of the memory cell is as follows:
[0023]
[0024] T u =σ(W u [C v (t-),g(Δt)]+bu)
[0025]
[0026] In the formula, C v (t-) represents the state value of the memory cell;
[0027] W α , W u Respectively represent the first weight parameter and the second weight parameter of the model learning;
[0028] b a , bu represent the first paranoid unit vector and the first paranoid unit vector of the neural network respectively;
[0029] J represents the sigmoid activation function;
[0030] g(Δt) represents the discount function e -x ;
[0031] bu; represents the bias unit vector of the neural network;
[0032] T u Represents the output of the update control gate.
[0033] Preferably, the DLGN model defines a graph sequence Where Z T ={1, 2, ..., T} is a finite set of indices;
[0034] Each graph G in the sequence i =(V i , E i ) represent an undirected graph, where Vi represents the vertex set, E i Represents the edge set, all graphs in the sequence share the same vertex set V; for graph G i For each vertex v in k ∈V, there is a corresponding eigenvector All eigenvectors are organized in a matrix called the vertex eigenmatrix. In a matrix where each row vector is Symbol [Y] i,j represents the element in the i-th row and j-th column of matrix Y, Y′ represents the transpose of Y, and I d yes The identity matrix in space, softmax and ReLU represent the soft maximization function and the linear rectification unit function respectively.
[0035] Preferably, the training data set includes input data and output data of the DLGN model, wherein: the input data is the initialization feature vector of the dynamic graph node, and the output data is the embedding vector of the dynamic graph node
[0036] Preferably, the time series length is divided into different time periods according to the activity frequency ratio, and the DLGN model is trained, specifically including:
[0037] The graph neural network is used to aggregate node information and then input into the update component composed of LSTM memory recurrent network, and the graph structure time process is divided into several time periods for parallel training;
[0038] A loss function is constructed to evaluate the training results of the DLGN model, and the training is completed when the calculated loss function meets the preset value.
[0039] Preferably, the loss function of the dynamic graph representation method will adopt the cross entropy loss function of pytorch, and the loss function formulas for node classification and link tasks are respectively:
[0040]
[0041] Where J(v, t) represents the node classification task loss function, J((v s , v g , t)) represents the loss function of the node prediction task;
[0042] y[i] represents the actual classification label of the node, represents the embedding vector of the node, N c Indicates the number of nodes;
[0043] σ represents the sigmoid function, represents the embedding vector of the source node, t- represents the moment before the node interaction occurs, T represents the variable of the time dimension, represents the embedding vector of the target node, Q represents the number of negative samples, represents the negative sampling distribution.
[0044] The present invention also proposes a dynamic graph representation system based on graph neural network and LSTM, using the dynamic graph representation method based on graph neural network and LSTM, including: a model construction module, a model training module, a data acquisition module and a node processing module;
[0045] Among them, the model building module improves the DGNN model based on the graph neural network and the improved LSTM memory recurrent network, and the improved DLGN model is obtained;
[0046] The model training module divides the time series length into different time periods according to the activity frequency ratio to train the DLGN model;
[0047] The data acquisition module includes acquiring training data sets for training the DLGN model and acquiring dynamic graph nodes to be processed;
[0048] The node processing module inputs the dynamic graph node initialization vector into the trained DLGN model to obtain the node embedding vector.
[0049] The present invention also provides a terminal, comprising a processor and a storage medium;
[0050] The storage medium is used to store instructions;
[0051] The processor is used to operate according to the instructions to execute the steps of the dynamic graph representation method based on graph neural network and LSTM.
[0052] The present invention also proposes a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the dynamic graph representation method based on graph neural network and LSTM are implemented.
[0053] The beneficial effect of the present invention lies in that, compared with the prior art, the present invention improves the learning ability of the node structure of the dynamic graph network by improving the DGNN model through the graph neural network and LSTM, adopts the GIN graph neural network to capture the neighbor information of the node, and adopts the improved LSTM recurrent network to obtain the dynamic time series information of the graph network, thereby improving the model's ability to extract time information; the present invention also enhances the model's ability to learn the dynamic graph network by improving the LSTM input part framework; at the same time, the time series length is divided into different time periods according to the activity frequency ratio and parallel training is performed to improve the training efficiency; the present invention utilizes the advantages of the graph neural network in learning graph structure information and the advantages of the recurrent neural unit LSTM in time, and combines the two so that the node embedding vector presents better results in node classification and link prediction tasks, and is particularly suitable for tracing business data changes in online channels. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1It is a schematic diagram of the model framework of the dynamic representation method proposed by the present invention;
[0055] Figure 2 It is a schematic diagram of the improved LSTM input part framework proposed in the present invention;
[0056] Figure 3 It is a schematic diagram of the training process of the dynamic representation method proposed by the present invention;
[0057] Figure 4 It is a structural diagram of the dynamic representation system proposed by the present invention;
[0058] Figure 5 This is a comparison chart of the F1 evaluation of the node classification task between the DLGN proposed in this invention and other models. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The embodiments described in this application are only part of the embodiments of the present invention, not all of them. Based on the spirit of the present invention, other embodiments obtained by ordinary technicians in this field without creative work are all within the scope of protection of the present invention.
[0060] like Figure 1 As shown, the present invention proposes a dynamic graph representation method based on graph neural network and LSTM, which specifically includes the following steps:
[0061] Step 1: Based on the graph neural network and the improved LSTM memory recurrent network, the DGNN model is improved to obtain the DLGN model. The improvement includes using the GIN graph neural network as the propagation component of the DGNN model and improving the input framework of the LSTM memory recurrent network and using it as the update component of the DGNN model.
[0062] Step 2: Train the DLGN model: Collect training data sets, including using graph neural networks to aggregate node information and then input it into the LSTM memory network, divide the time series length into different time periods according to the activity frequency ratio, and train the DLGN model;
[0063] The dynamic graph node vector is initialized based on the connection information of the dynamic graph nodes over time. After obtaining the dynamic graph node initialization vector, the trained DLGN model is input to obtain the node embedding vector. The node embedding vector is used to characterize the structural characteristics of the dynamic graph network with time-varying node information.
[0064] Step 4: Input the initialization vector of the dynamic graph node into the trained DLGN model. The model outputs the embedding vector of the node. The embedding vector of the node is used to characterize the structural characteristics of the dynamic graph network with temporal changes in node information.
[0065] Specifically, in step 1, based on the DGNN (Dynamic Graph Nepal Networks) framework, the DGNN framework is improved by combining the GIN (Graph Isomorphism Network) neural network and the LSTM (Long Short-Term Memory) memory recurrent network to obtain the DLGN model.
[0066] The dynamic graph embedding model based on GIN and LSTM includes the following parts: an update component and a propagation component consisting of a GIN neural network and LSTM memory loop units;
[0067] GIN (Graph Isomorphism Network) neural network is used to aggregate node neighbor information. This component can distinguish nodes of different graph structures in the current time period. The node embedding vector after semi-supervised training is finally reduced in dimension by PCA. It can be clearly seen that nodes with similar structures are distributed on the same side of the legend. On the contrary, nodes with larger structural differences have larger Euclidean distances on the legend. It can be seen that the GIN neural network model has achieved good results. The information of the aggregated nodes of the model mainly adopts the GIN graph neural network, which can capture the complex relationship between nodes and the global characteristics of the graph structure. The GIN graph neural network can effectively handle the dynamic changes of the graph and maintain the accuracy and real-time performance of the model. The present invention adopts the GIN graph neural network to capture the isomorphic characteristics of the dynamic graph. Specifically, the representation of each node is updated by aggregating the information of neighbor nodes, so as to achieve the purpose of capturing graph structure information.
[0068] The node update rule of the GIN model can be expressed as the following formula:
[0069]
[0070] In the formula, is the representation of node v at the kth layer;
[0071] MLP (k) Represents a multilayer perceptron, which is used for nonlinear transformation of node features at the kth layer;
[0072] ε (k)is a learnable parameter or a fixed scalar that may vary in different implementations and is used to adjust the importance of a node's own features versus its neighbors' features.
[0073] is the feature representation of node v at the k-1 layer;
[0074] The sum of the feature representations of all neighbors of node v;
[0075] Represents the set of adjacent nodes of node v.
[0076] The meaning of the whole expression is that at the kth layer, the feature representation of vertex v is the weighted sum of its feature representation at the (k-1)th layer and its neighbor's (k-1)th layer feature representation, processed by a multi-layer perceptron MLP. The weighted sum includes a coefficient 1+∈ (k) , which means that the vertex’s own characteristics are strengthened during the aggregation process.
[0077] The LSTM memory cycle unit consists of the following update components:
[0078] Within the time threshold Δt, the state information Cv(t_) of the sampled neighbor information of the node in the previous time period is used as the memory cell of the LSTM component of the improved recurrent network
[0079] like Figure 2 As shown, the present invention improves the input framework of LSTM: the state value C of the memory cell v (t-) is the state representation of the node at the most recent time point. The state value of the node memory cell includes long-term memory and short-term memory T u (Update the output of the control gate), the expression of the state value of the memory cell is as follows:
[0080]
[0081] T u =σ(W u [C v (t-),g(Δt)]+bu)
[0082]
[0083] In the formula, C v (t-) represents the state of the node at the most recent time point;
[0084] W α , W u Respectively represent the first weight parameter and the second weight parameter of the model learning;
[0085] b a , bu represent the bias unit vectors of the neural network respectively;
[0086] σ represents the sigmoid activation function;
[0087] g(Δt) represents the discount function e -x ;
[0088] b u ; represents the bias unit vector of the neural network;
[0089] T u represents the output of the update control gate;
[0090] C v (t-) represents the final state value of the memory cell of this node.
[0091] The framework output node memory cell state value C will be improved v (t-), the message function of node interaction e(t), the node's most recent hidden state h v (t-) is used as the input of LSTM, and the corresponding expression is as follows:
[0092] f i =σ(x i W f +h i-1 U f +b f )
[0093]
[0094] j i =σ(x i W j +h i-1 U j +b j )
[0095] o i =σ(x i W o +h i-1 U o +b o )
[0096]
[0097] In the formula, h i , o i 、c i Respectively represent: hidden state, output value of the current time step, and state value of the memory cell;
[0098] f i represents the forget gate;
[0099] Represents the value of the updated memory cell;
[0100] σ(·) represents the excitation sigmod function;
[0101] x i The message function e(t) representing the interaction between the input value nodes of the current step;
[0102] W f , W j , W o , W c represent the first model weight matrix parameter, the second model weight matrix parameter, the third model weight matrix parameter and the fourth model weight matrix parameter respectively;
[0103] h i-1 Represents the hidden state value h of the previous step v (t-);
[0104] c i-1 Represents the node memory cell state value C v (t_);
[0105] U f , U j , U o , U c represent the first model weight vector parameter, the second model weight vector parameter, the third model weight vector parameter and the fourth model weight vector parameter respectively;
[0106] b f , b j , b o , b c They respectively represent the first bias vector parameter, the second bias vector parameter, the third bias vector parameter and the fourth bias vector parameter of the model training.
[0107] Furthermore, the dynamic graph embedding model based on GIN and LSTM defines a graph sequence Where Z T = {1, 2, ..., T} is a finite set of indices. Each graph G in the sequence i =(V i , E i ) is an undirected graph, where V i represents the vertex set, E i Represents the edge set. All graphs in the sequence share the same vertex set V, that is, for all i∈Z T , with V i = V. For graph G i For each vertex v in k∈V, there is a corresponding eigenvector These eigenvectors are organized in a matrix called the vertex eigenmatrix. In a matrix where each row vector is The symbol [Y]i,j represents the element in the i-th row and j-th column of the matrix Y, Y′ represents the transpose of Y, and I d yes The identity matrix in space, soffmax and ReLU represent the soft maximization function and the linear rectification unit function respectively. is a projection matrix if it is symmetric, positive definite, and satisfies P 2 =P In particular, if P is a diagonal matrix (possibly with some zeros on the main diagonal), it is called a diagonal projection matrix. This means that when P is applied to a d-dimensional column vector v, it will zero all entries in v that correspond to zero elements on the main diagonal of P.
[0108] For the v-LSTM layer, we also consider a sequence in J is an LSTM layer (v-LSTM) with N output nodes, through the function v-LSTM N Definition, this function acts on the above sequence and generates an L×N×T output tensor. For each vertex in L, it processes the features of the vertex in all T time steps through an LSTM network. Here, V p express arrive The isometric embedding is used to transform the input features into a form suitable for LSTM processing. p The definition of δ makes use of the Kronecker delta function δ ip , used to create isometric embeddings. The trained weights are shared among the L LSTM replicas.
[0109] At the end of the model, k nodes are output through L fully connected layers (vs-FC), and the weight matrix Bias Matrix This layer calculates Z for each time step. i Apply a fully connected network (FC layer) with a softmax activation function to produce an L × k output. This is equivalent to using a fully connected layer for each time step of the input tensor and then applying a softmax activation function.
[0110] Propagation component in the DGNN framework: In order to update the information of the affected nodes, the interaction information should be propagated to their cell memory. He transmits the interaction information of the current node to the neighbors of the node to update the feature information of the neighboring nodes. Since the interaction does not directly affect the affected nodes, it is assumed that the interaction does not interfere with the history of the affected nodes, but only brings new information. Therefore, there is no need to decay or reduce the historical information (cell memory), but only add new information to it incrementally. Similar to the intuition that older interactions should have less impact on the recent node information, the interaction should have less impact on the older affected nodes. Introduce a function in the message passing process To calculate the affected nodes, the function is as follows:
[0111]
[0112] in, represents the time interval, τ is the time threshold, and when the time threshold is greater than τ, the node interaction information is stopped from being transmitted to the neighbor. In this way, the transmission of node interaction information is more efficient.
[0113] The main framework uses an improved LSTM recurrent network to obtain dynamic time series information of the graph network. The representation method of the dynamic graph will use a graph neural network to aggregate node information and then input it into the LSTM memory network. The time series length will be divided into different time periods according to the activity frequency ratio and trained in parallel to improve the model training efficiency. The LSTM recurrent structure parameters are shared between time periods to overcome the gradient vanishing / gradient explosion problems caused by too many layers of recurrent units in the recurrent network in graph structure applications. The GIN graph neural network will be used to capture the neighbor information of the node, and the graph enhancement technology will be used to solve the problem that the nodes with the same computational graph cannot be distinguished. The time series length will be divided into different time periods according to the activity frequency ratio and trained in parallel.
[0114] The idea of improving the GIN graph neural network is:
[0115] Information is passed and updated through the relationships between nodes. In this framework, the Graph Isomorphism Network (GIN) is a special GNN variant that is designed to capture information about graph structures more effectively. GIN works through a special aggregation mechanism that can more accurately distinguish different graph structures. The key to GIN is the way it updates node representations, which makes it perform particularly well on the task of graph isomorphism, that is, judging whether two graph structures are the same. In this way, GIN effectively improves the accuracy and efficiency of graph structure data analysis.
[0116] Step 2: Train the improved DGNN model: The main process of model training includes parameter analysis and setting, log configuration, data loading and processing, model initialization, training preparation, training cycle, early stopping strategy, verification and testing, and result saving. See the flowchart of the model training process for details. Figure 2 , the graph neural network is used to aggregate node information and then input into the LSTM memory network, and the graph structure time process is divided into several time periods for parallel training. The model is based on the PyTorch framework and defines the RDGNN class, which includes a memory module class based on the LSTM recurrent neural network, which is used to store and update the state of each node at different time points. The message function MessageFaction function is defined to calculate the information exchanged between nodes. It uses the memory state of the node and the characteristics of the edge to generate messages.
[0117] The specific steps include:
[0118] Step 2-1, obtain the training data set;
[0119] The data set is divided into training set, test set and validation set in a ratio of 8:1:1.
[0120] Specifically, the input data of the model is the initialization node feature vector of the node, and the output data is the embedding vector of the node;
[0121] Step 2-2, model parameter initialization;
[0122] The Memory class is defined to initialize the memory state of the node. The Xavier normal (Glorot normal) initialization method is used to initialize the weights in the neural network. This initialization method aims to keep the variance of the input and output consistent to avoid the problem of gradient disappearance or explosion during the forward and backward propagation of the network. It is suitable for network layers with linear, sigmoid and tanh activation functions. At the same time, the Memory class defines the methods used in the model later, such as backing up the node memory state and obtaining the node memory state.
[0123] Step 2-3, training the model based on the training data set;
[0124] The improved GIN graph neural network encodes node vectors based on the interaction frequency of nodes, takes them as model input, and trains the model through semi-supervised learning to achieve low-dimensional vector representation of dynamic graph nodes. In this way, active nodes and inactive nodes can be distinguished at the model input stage, and nodes with similar frequencies can be selected and eliminated to reduce the complexity of the model. The F1 index and recall rate of the prediction results of the data sets UCI, DNC, Epinions, and Wikipedia have been improved. The experimental results are shown in Tables 1 and Figure 3 .
[0125] The output h of GIN's graph neural network after aggregating and sampling neighbor nodes v (t-) and the current interactive information e(t) are respectively related to h by the established parameters W1 and Wq v The sum of (t-) and e(t) is used as the input signal of LSTM, and the state value C of the memory cell is v (t-) is the state representation of the node at the most recent time point;
[0126] The method for obtaining interactive messages of node neighbor information includes: (1) obtaining the most recent sampled neighbor message information at a time point, and (2) obtaining average information of the sampled neighbor nodes.
[0127] The biased random walk strategy is used in the node sampling strategy to better capture the specific properties of the graph. By introducing bias, certain transfers are more likely to occur.
[0128] Two parameters are introduced: the backtrack parameter p and the in-out parameter q to balance the local and global exploration of the graph during random walks. This strategy aims to control the tendency of random walks by adjusting these two parameters, so that the walk can flexibly balance between exploring the neighborhood of nodes (local structure) and more distant nodes (global structure).
[0129] Step 2-4, update the weight parameters of the model according to the PyTorch framework gradient descent algorithm;
[0130] Step 2-5, determine whether the set conditions for model evaluation are met. If so, output the weight parameters and evaluation index values of the model training, otherwise return to step 2-3 to continue training.
[0131] In order to evaluate the performance of the dynamic graph representation method proposed in this patent, two tasks, semi-supervised node series classification and node linking, were performed. The loss function of the dynamic graph representation method will adopt the cross entropy loss function of pytorch. The loss function expressions corresponding to the node classification and linking tasks are as follows:
[0132]
[0133] The loss function of this dynamic graph representation method will adopt the cross entropy loss function of pytorch. The loss function formula for node classification and link tasks is:
[0134] Where J(v, t) represents the node classification task loss function
[0135] y[i] represents: the actual classification label of the node
[0136] Representation: Embedding vector of the node
[0137] N c Indicates: the number of nodes
[0138] J((v s , v g , t)) represents: the loss function of the node prediction task
[0139] σ represents: sigmoid function
[0140] Representation: Embedding vector of source node
[0141] t- means: the moment before the node interaction occurs
[0142] T represents: variable of time dimension
[0143] Representation: Embedding vector of the target node
[0144] Q represents: the number of negative samples
[0145] Representation: Negative sampling distribution
[0146] Two different metrics are used to evaluate the performance of the link prediction task, one of which is MRR, which is defined as follows:
[0147]
[0148] H is the number of node pairs, rank i It is the ranking of this node among all nodes. MRR calculates the average of the inverse ranking of nodes in the set. Its value is higher when there are more nodes with real links ranked at the top. Another indicator used is the recall rate Recall@k, whose formula is defined as follows:
[0149]
[0150] Only when rank i ≤k, 1{rank i ≤k}=1, otherwise its value is 0. recall@k counts how many real nodes are ranked among the top k of all nodes in their own test pair. The larger the value, the better the performance.
[0151] This loss function is consistent with most node classification and node prediction tasks. The model constructed by the present invention and the existing GCN, GraphSage, dynnode2vec, DynGEM, JODIE, DGNN, and TCN models were used to conduct experiments on the data sets UCI, DNC, Epinions, and Wikipedia. The model evaluation module uses the recall function (recall), the mean reciprocal ranking function (MRR), and F1. The cosine similarity between the source node memory and the target node memory is calculated by the target selection function to select possible target nodes. It first normalizes the source node memory (src_mem) and the target node memory (u obtained by merging memory_s and memory_g), and then calculates the cosine similarity between the normalized source node memory and the target node memory. Finally, it returns the similarity value and the corresponding index, where the index is arranged in descending order according to the similarity value. The recall rate (recall function) calculates the proportion of correctly predicted target nodes among the top_k most similar nodes. It is an indicator for evaluating the performance of the model in finding the correct target node. MRR is a way to evaluate the accuracy of model predictions. It calculates the average of the reciprocal of the number of times the model ranks the true target node first. A high MRR value indicates that the model performs better in predicting the correct target node. The edge prediction evaluation function uses the above choose_target, recall, and MRR functions to evaluate the performance of the graph network model on the edge prediction task. It first generates negative samples, then uses the model to predict each pair of nodes in the batch, and calculates the recall and MRR. This process is repeated on all test batches, and finally returns the average of the recall and MRR over all batches. The evaluation module quantifies the performance of the model on the task of predicting whether there is an edge between nodes in the graph by calculating the recall and MRR. This is a common evaluation framework in graph network research, used to measure the effectiveness of models on tasks such as link prediction or recommendation systems.
[0152] The main idea of the parallel training model is to divide the time series length into different time periods according to the activity frequency ratio, and each time period aggregates information through the GIN neural network, the improved LSTM update component, and the propagation component. Each time period shares the weight parameters of the LSTM update component.
[0153] like Figure 4 As shown, the present invention also proposes a dynamic graph representation system based on graph neural network and LSTM, which is used to implement the above-mentioned dynamic graph representation method based on graph neural network and LSTM, including: a model building module, a model training module, a data acquisition module and a node processing module;
[0154] Among them, the model building module improves the DGNN model based on the graph neural network and the improved LSTM memory recurrent network, and the improved DLGN model is obtained;
[0155] The model training module divides the time series length into different time periods according to the activity frequency ratio to train the DLGN model;
[0156] The data acquisition module includes acquiring training data sets for training the DLGN model and acquiring dynamic graph nodes to be processed;
[0157] The node processing module inputs the dynamic graph node initialization vector into the trained DLGN model to obtain the node embedding vector.
[0158] In order to evaluate the performance of the model, extensive experiments were conducted based on the model. A negative sampling strategy was used to predict node links. Model prediction was evaluated on three commonly used graph datasets: UCI, DNC, and Epinions. The rating indicators used were F1 and MRR ranking.
[0159] The experimental results are as follows Figure 5 As shown in Table 1, the results in Table 1 show that the MRR index of the node link task of the model on the datasets UCI, DNC, Epinions, and Wikipedia is higher than the current models JODIE and DGNN that have good dynamic graph embedding performance, and far exceeds the static models GCN and GraphSage. Similarly, in the common node classification task, we performed a semi-supervised node classification task on the dataset UCI, and drew the following graph based on the experimental data. Figure 3 As shown in the line graph, it can be found that the F1 index of the model DLGN of this patent is higher than that of JODIE and TCN in all values of the horizontal axis of Ratio of Labeled Vertices, and increases with the increase of the horizontal axis value. As with the node link task, this model far exceeds the static models GraphSageh and WD-GCN compared. The key point of this patent is that it combines graph neural networks and LSTM time memory units, makes full use of graph structure information and time information, and uses node set segmented parallel training to improve the efficiency of model training. Some progress has been made in the dynamic graph representation method, and subsequent research will continue to improve on this basis.
[0160] Table 1: Indicators obtained by testing different models on different data sets
[0161]
[0162]
[0163] The beneficial effect of the present invention lies in that, compared with the prior art, the present invention improves the learning ability of the node structure of the dynamic graph network by improving the DGNN model through graph neural network and LSTM, adopts the GIN graph neural network to capture the neighbor information of the node, and adopts the improved LSTM recurrent network to obtain the dynamic time series information of the graph network, thereby improving the model's ability to extract time information, and by improving the LSTM input part framework, the model's ability to learn dynamic graph networks is enhanced.
[0164] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0165] Computer readable storage medium can be a tangible device that can hold and store instructions used by an instruction execution device. Computer readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive lists) of computer readable storage medium include: portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), static random access memories (SRAM), portable compact disk read-only memories (CD-ROM), digital versatile disks (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or convex structures in grooves on which instructions are stored, and any suitable combination thereof. Computer readable storage medium used here is not interpreted as a transient signal itself, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagated by waveguides or other transmission media (e.g., light pulses by optical fiber cables), or electrical signals transmitted by wires.
[0166] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0167] The computer program instructions for performing the disclosed operation may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the disclosed invention.
[0168] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A dynamic graph representation method based on graph neural network and LSTM, characterized in that: The steps include: The DLGN model is obtained by improving the DGNN model based on the graph neural network and the improved LSTM memory recurrent network. The improvements include using the GIN graph neural network as the propagation component of the DGNN model and improving the input framework of the LSTM memory recurrent network and using it as the update component of the DGNN model. Collect training data sets, divide the time series length into different time periods according to the activity frequency ratio, and train the DLGN model; The dynamic graph node vector is initialized based on the connection information of the dynamic graph nodes over time. After obtaining the dynamic graph node initialization vector, the trained DLGN model is input to obtain the node embedding vector. The node embedding vector is used to characterize the structural characteristics of the dynamic graph network with time-varying node information.
2. The dynamic graph representation method based on graph neural network and LSTM according to claim 1, characterized in that: The improved DLGN model includes: GIN graph neural network, update component composed of improved LSTM memory recurrent network and propagation component of DGNN model; The graph neural network is used to aggregate the neighbor information of the nodes in the input vector to obtain the output vector; The update component composed of the improved LSTM memory recurrent network updates the state representation of the node for the output vector of the GIN graph neural network; the propagation component of the DLGN model is used to transmit the interaction information of the node to the feature vector of the neighboring node.
3. The dynamic graph representation method based on graph neural network and LSTM according to claim 1, characterized in that: The node update rule of the GIN model is expressed as the following formula: In the formula, is the representation of node v at the kth layer; MLP (k) Represents a multilayer perceptron, which is used for nonlinear transformation of node features at the kth layer; ε (k) is a learnable parameter or a fixed scalar that adjusts the importance of a node’s own features and its neighbor’s features; is the feature representation of node v at the k-1 layer; The sum of the feature representations of all neighbors of node v; Represents the set of adjacent nodes of node v.
4. The dynamic graph representation method based on graph neural network and LSTM according to claim 1, characterized in that: Improve the input framework of the LSTM memory recurrent network: add an input framework to the LSTM memory recurrent network to process the input data. The input framework includes an activation function, a discount function, an update control gate, and an adder. The output result processed by the input framework is used as the input C of the memory cell of the LSTM memory recurrent network. v (t-), specifically including: Improve the input framework of LSTM: the state value C of the memory cell v (t-) is the state representation of the node at the most recent time point. The state value of the node memory cell includes long-term memory and short-term memory T u , the expression of the state value of the memory cell is as follows: T u =σ(W u [C v (t-),g(Δt)]+bu) In the formula, C v (t-) represents the state value of the memory cell; W α , W u Respectively represent the first weight parameter and the second weight parameter of the model learning; b a , bu represent the first paranoid unit vector and the first paranoid unit vector of the neural network respectively; σ represents the sigmoid activation function; g(Δt) represents the discount function e -x ; bu; represents the bias unit vector of the neural network; T u Represents the output of the update control gate.
5. The dynamic graph representation method based on graph neural network and LSTM according to claim 1, characterized in that: The DLGN model defines a graph sequence Where Z T ={1, 2, ..., T} is a finite set of indices; Each graph G in the sequence i =(V i , E i ) represent an undirected graph, where Vi represents the vertex set, E i Represents the edge set, all graphs in the sequence share the same vertex set V; for graph G i For each vertex v in k ∈V, there is a corresponding eigenvector All eigenvectors are organized in a matrix called the vertex eigenmatrix. In a matrix where each row vector is Symbol [Y] i,j represents the element in the i-th row and j-th column of matrix Y, Y′ represents the transpose of Y, and I d yes The identity matrix in space, softmax and ReLU represent the soft maximization function and the linear rectification unit function respectively.
6. The dynamic graph representation method based on graph neural network and LSTM according to claim 1, characterized in that: The training data set includes the input data and output data of the DLGN model, where the input data is the initialization feature vector of the dynamic graph node, and the output data is the embedding vector of the dynamic graph node.
7. The dynamic graph representation method based on graph neural network and LSTM according to claim 1, characterized in that: The time series length is divided into different time periods according to the activity frequency ratio, and the DLGN model is trained, including: The graph neural network is used to aggregate node information and then input into the update component composed of LSTM memory recurrent network, and the graph structure time process is divided into several time periods for parallel training; A loss function is constructed to evaluate the training results of the DLGN model, and the training is completed when the calculated loss function meets the preset value.
8. The dynamic graph representation method based on graph neural network and LSTM according to claim 7, characterized in that: The loss function of this dynamic graph representation method will use the cross entropy loss function of pytorch. The loss function formulas for node classification and link tasks are: Where J(v, t) represents the node classification task loss function, J((v s , v g , t)) represents the loss function of the node prediction task; y[i] represents the actual classification label of the node, represents the embedding vector of the node, N c Indicates the number of nodes; σ represents the sigmoid function, represents the embedding vector of the source node, t- represents the moment before the node interaction occurs, T represents the variable of the time dimension, represents the embedding vector of the target node, Q represents the number of negative samples, represents the negative sampling distribution.
9. A dynamic graph representation system based on graph neural network and LSTM, using the dynamic graph representation method based on graph neural network and LSTM according to any one of claims 1 to 8, characterized in that: include: Model building module, model training module, data acquisition module and node processing module; The model building module improves the DGNN model based on the graph neural network and the improved LSTM memory recurrent network, including using the GIN graph neural network as the propagation component of the DGNN model, improving the input framework of the LSTM memory recurrent network and using it as the update component of the DGNN model, and obtaining the DLGN model after the improvement; The model training module divides the time series length into different time periods according to the activity frequency ratio to train the DLGN model; The data acquisition module includes acquiring training data sets for training the DLGN model and acquiring dynamic graph nodes to be processed; The node processing module initializes the dynamic graph node vector based on the connection information of the dynamic graph nodes over time, inputs the initialization vector of the dynamic graph node into the trained DLGN model, and obtains the node embedding vector to represent the structural characteristics of the dynamic graph network with time-varying node information.
10. A terminal comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is used to operate according to the instructions to execute the steps of the dynamic graph representation method based on graph neural network and LSTM according to any one of claims 1-8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the dynamic graph representation method based on graph neural network and LSTM described in any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Method for detecting network security behavior of power system based on deep learning dynamic graph neural network technology
CN119854043A
Psychological state prediction method and system based on geometric mean and graph structure
CN120260837A