Node embedding optimization method and device and medium
Through adaptive graph enhancement and random attack optimization of node embedding methods, combined with graph attention and comparison learning, the problems of insufficient generalization ability and false negatives of node embedding methods are solved, and the quality and adaptability of node embedding are improved.
Patent Information
- Application Number
- CN202510284804.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-08-01
AI Technical Summary
In the prior art, node embedding methods are easily affected by graph structure, resulting in insufficient generalization capabilities, and problems with excessive smoothing of node characteristics and false negative samples, affecting the embedding quality.
Through adaptive graph enhancement, threshold processing and random attack methods, the similarity weight is calculated, and the node embedding representation is optimized until the preset iteration number is reached. Combined with the graph attention mechanism and graph comparison learning, the quality and generalization ability of node embedding are improved.
It significantly improves the quality and generalization ability of node embedding, effectively avoids excessive smoothing of node characteristics, identify and filter false negative samples, and enhances the adaptability and accuracy of the model.
Smart Images

Figure CN120409538A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of graph neural network technology, and in particular, to a method and device for optimizing node embedding and a medium. Background Art
[0002] In related technologies, node embedding, as an important part of graph neural networks, plays a crucial role in downstream tasks. The core goal of node embedding is to map the nodes in a graph to a low-dimensional space, preserving the topological relationships and feature information between nodes, so as to provide effective feature representations for tasks such as node classification, link prediction, and community discovery. Currently, the methods of node embedding mainly include methods based on neural networks (GNN) and methods based on graph contrastive learning (GCL). The GNN method is easily affected by the graph structure, which may lead to the lack of generalization ability of node embedding. And in deep GNNs, node features may be over-smoothed, resulting in node embeddings tending to be similar and losing distinctiveness. The GCL method may have "false negative" samples, that is, nodes semantically similar to the anchor node are wrongly regarded as negative samples, thus affecting the quality of node embedding.
[0003] In summary, the technical problems existing in related technologies need to be improved. Summary of the Invention
[0004] The main purpose of the embodiments of this application is to propose a method and device for optimizing node embedding and a medium, which can effectively improve the quality and generalization ability of node embedding.
[0005] To achieve the above object, on the one hand, an embodiment of this application proposes a method for optimizing node embedding, and the method includes the following steps:
[0006] Obtain the network graph to be processed;
[0007] Perform adaptive graph augmentation on the network graph to be processed to obtain several graph views;
[0008] Perform threshold processing on the nodes of each graph view to obtain the enhanced node embedding representation of each node;
[0009] Augment the network graph to be processed by a random attack method;
[0010] Calculate the similarity weight of the augmented network graph to be processed;
[0011] Calculate the loss value of the network graph to be processed according to the enhanced node embedding representation and the similarity weight;
[0012] Update the node embedding representation of the network graph to be processed according to the loss value until the network graph to be processed is in a convergent state or the number of iterations is greater than or equal to a preset number of times.
[0013] In some embodiments, the threshold processing of the nodes in each of the graph views to obtain the enhanced node embedding representation of each node includes:
[0014] Calculating the attention coefficient of each node in each of the graph views;
[0015] Calculating the initial embedding representation of each node according to the attention coefficient;
[0016] Obtaining a preset threshold;
[0017] Processing the initial embedding representation according to the preset threshold to obtain the enhanced node embedding representation of each node.
[0018] In some embodiments, the calculation formula of the attention coefficient is as follows:
[0019]
[0020] In the formula, represents the attention coefficient of the i-th node in the k-th graph view; represents the learnable weight matrix obtained from the feature matrix through the k-th graph view; represents the learnable weight vector; x i represents the i-th node feature vector; x j represents the feature vector of the j-th neighbor node; x p represents the feature vector of the p-th neighbor node; v p ∈N i represents the p-th vertex in the N i -th vertex set; || represents the concatenation operation, and LeakyReLU(·) represents the non-linear activation function.
[0021] In some embodiments, the calculation formula of the initial embedding representation is as follows:
[0022]
[0023] In the formula, f(v i ) represents the initial embedding representation of the i-th node; represents the j-th vertex in the N i -th vertex set; x j represents the feature vector of the j-th neighbor node; ELU(·) represents the non-linear activation function.
[0024] In some embodiments, the calculation of the similarity weight of the enhanced network graph to be processed includes:
[0025] Calculating the graph structure similarity of the enhanced network graph to be processed;
[0026] Calculate the feature similarity of the to-be-processed network graph after enhancement;
[0027] Calculate the fusion similarity according to the graph structure similarity and the feature similarity;
[0028] Obtain a first temperature hyperparameter and a second temperature hyperparameter;
[0029] Calculate a monotonically increasing function according to the fusion similarity and the first temperature hyperparameter;
[0030] Calculate a monotonically decreasing function according to the fusion similarity and the second temperature hyperparameter;
[0031] Calculate the node positive sample possibility in the similarity weight according to the monotonically increasing function;
[0032] Calculate the node negative sample possibility in the similarity weight according to the monotonically decreasing function.
[0033] In some embodiments, the calculation formula of the loss value is as follows:
[0034]
[0035] In the formula, represents the loss value; represents the node v i 's positive sample possibility; represents the node v i 's negative sample possibility; represents the node v i belonging to the i-th node in the positive sample set ; represents the node v i belonging to the i-th node in the negative sample set ; The f′(v) and f′(v i ) in represent the enhanced node embedding representations of any two nodes in the positive sample set; The f′(v) and f′(v i ) in represent the enhanced node embedding representations of any two nodes in the negative sample set; The f′(v) and f′(v ′ ) in represent the enhanced node embedding representations of any two nodes in the to-be-processed network graph; τ represents the third temperature hyperparameter.
[0036] In some embodiments, the updating the node embedding representation of the to-be-processed network graph according to the loss value includes:
[0037] Calculate the gradient of the loss value with respect to the node embedding representation in the to-be-processed network graph through backpropagation;
[0038] Update the node embedding representation of the to-be-processed network graph according to the gradient.
[0039] To achieve the above object, on the other hand, an embodiment of the present application proposes a node embedding optimization device, which includes:
[0040] A first module, configured to obtain a to-be-processed network graph;
[0041] A second module, configured to perform adaptive graph augmentation on the to-be-processed network graph to obtain a plurality of graph views;
[0042] A third module, configured to perform threshold processing on the nodes of each graph view to obtain an enhanced node embedding representation of each node;
[0043] A fourth module, configured to enhance the to-be-processed network graph by a random attack method;
[0044] A fifth module, configured to calculate the similarity weight of the enhanced to-be-processed network graph;
[0045] A sixth module, configured to calculate the loss value of the to-be-processed network graph according to the enhanced node embedding representation and the similarity weight;
[0046] A seventh module, configured to update the node embedding representation of the to-be-processed network graph according to the loss value until the to-be-processed network graph is in a converged state or the number of iterations is greater than or equal to a preset number of times.
[0047] To achieve the above object, on the other hand, an embodiment of the present application proposes a computer device, including:
[0048] At least one processor;
[0049] At least one memory, configured to store at least one program;
[0050] When the at least one program is executed by the at least one processor, the at least one processor implements the above method.
[0051] To achieve the above object, on the other hand, an embodiment of the present application proposes a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above method is implemented.
[0052] The embodiments of the present application at least include the following beneficial effects: The present application provides a node embedding optimization method, device and medium. The solution obtains several graph views by performing adaptive graph enhancement on the network graph to be processed, so as to improve rich training samples through diversified graph views, which can help the node embedding model learn different node relationships and graph structures, and effectively improve the generalization ability of the node embedding model; then, by performing threshold processing on the nodes of each graph view, an enhanced node embedding representation of each node can be obtained, which can effectively avoid excessive smoothing of node features; at the same time, after enhancing the network graph to be processed by a random attack method, the similarity weight of the enhanced network graph to be processed is calculated, and the loss value of the network graph to be processed is calculated according to the enhanced node embedding representation and the similarity weight, and then the node embedding representation of the network graph to be processed is updated according to the loss value until the network graph to be processed is in a convergent state or the number of iterations is greater than or equal to a preset number, so as to effectively improve the quality of node embedding. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 is a flowchart of the node embedding optimization method provided by the embodiments of the present application;
[0054] Figure 2 is a schematic framework diagram of the node embedding optimization method provided by the embodiments of the present application;
[0055] Figure 3 is a schematic structural diagram of the node embedding optimization device provided by the embodiments of the present application;
[0056] Figure 4 is a schematic hardware structure diagram of the computer device provided by the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0057] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods that are consistent with some aspects of the embodiments of the present application.
[0058] It can be understood that the terms "first", "second", etc. used in this application may be used herein to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if", "when" as used herein may be interpreted as "when...", "while...", or "in response to determining".
[0059] The terms "at least one", "multiple", "each", "any one", etc. used in this application, at least one includes one, two or more than two, multiple includes two or more than two, each refers to each one of the corresponding multiple, and any one refers to any one of the multiple.
[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0061] In the related art, node embedding, as an important part of graph neural networks, plays a crucial role in downstream tasks. The core goal of node embedding is to map the nodes in a graph into a low-dimensional space, preserving the topological relationship and feature information between nodes, so as to provide effective feature representations for tasks such as node classification, link prediction, and community discovery. Currently, node embedding is mainly divided into two categories:
[0062] (1) Methods based on graph neural networks (GNNs):
[0063] GNN methods focus on using graph structure information for node feature aggregation and learning the local relationships between nodes through graph convolution operations. For example, GCN updates the feature representation of a node by aggregating the information of its neighbor nodes, so that the global features of the node can be gradually captured in a multi-layer network structure. Although GNNs have achieved good results on graph data, they also have some limitations. First, GNNs have a strong dependence on the graph structure, which may lead to a lack of generalization ability of their node embeddings when facing changes in the graph structure. If the structure of the graph changes, the performance of the GNN model may decrease significantly. Second, GNNs do not directly consider the similarity information between nodes, which may lead to poor performance in distinguishing semantically similar nodes in the generated node embeddings and make it difficult to distinguish semantically similar nodes.
[0064] (2) Methods based on graph contrastive learning (GCL):
[0065] GCL learns the similarity between nodes through contrastive learning, mapping semantically similar nodes to closer positions and semantically different nodes to more distant positions. For example, the InfoNCE loss function learns node embeddings by maximizing the similarity between positive sample pairs and minimizing the similarity between negative sample pairs. The advantage of the GCL method is its ability to effectively learn the semantic relationships between nodes and improve the discriminability of node embeddings. However, there are also some problems with the GCL method. First, the GCL method usually requires a large amount of positive sample data, which is often difficult to obtain in practical applications. Second, the GCL method may have "false negative" samples, that is, nodes that are semantically similar to the anchor node are wrongly regarded as negative samples, thus affecting the embedding quality.
[0066] In view of this, embodiments of the present application provide a node embedding optimization method, device and medium, which can effectively improve the quality of node embeddings and the generalization ability of node embedding models.
[0067] The node embedding optimization method provided by the embodiments of the present application relates to the field of graph neural network technology. The node embedding optimization method provided by the embodiments of the present application can be applied to a terminal, a server, or software running on a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a vehicle-mounted terminal, etc., but is not limited thereto; the server side can be configured as an independent physical server, or can be configured as a server cluster or distributed system composed of multiple physical servers, or can be configured as a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application implementing the node embedding optimization method, etc., but is not limited to the above forms.
[0068] This application can be used in numerous general or specific computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and so on. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This application can also be practiced in a distributed computing environment where tasks are executed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0069] The embodiments of this application will be specifically described below in conjunction with the accompanying drawings:
[0070] Figure 1 It is an optional flowchart of the node embedding optimization method provided by the embodiments of this application. Figure 1 The method in may include but is not limited to steps S110 to S170:
[0071] Step S110, obtain the network graph to be processed;
[0072] Step S120, perform adaptive graph enhancement on the network graph to be processed to obtain several graph views;
[0073] Step S130, perform threshold processing on the nodes of each graph view to obtain the enhanced node embedding representation of each node;
[0074] Step S140, enhance the network graph to be processed through a random attack method;
[0075] Step S150, calculate the similarity weight of the enhanced network graph to be processed;
[0076] Step S160, calculate the loss value of the network graph to be processed according to the enhanced node embedding representation and the similarity weight;
[0077] Step S170, update the node embedding representation of the network graph to be processed according to the loss value until the network graph to be processed is in a convergent state or the number of iterations is greater than or equal to a preset number of times.
[0078] It can be understood that after determining the network graph to be processed in this embodiment, data preprocessing is performed on the network graph to be processed to extract the node features in the network graph to be processed and construct an adjacency matrix. Assume that the network graph to be processed is where Denotes the vertex set, Denotes the edge set, X ∈ R N×F Denotes the set of node feature vectors, F is the dimension of node features, A ∈ {0, 1} N×N Denotes the adjacency matrix.
[0079] In the embodiments of the present application, as Figure 2 shown, this embodiment performs two independent processing procedures on the network graph to be processed: the first processing procedure is to perform threshold processing on the network graph to be processed; the second processing procedure is to calculate the similarity weight of the network graph to be processed.
[0080] Specifically, the threshold processing procedure includes but is not limited to the following steps:
[0081] Calculate the attention coefficient of each node in each graph view;
[0082] Calculate the initial embedding representation of each node according to the attention coefficient;
[0083] Obtain a preset threshold;
[0084] Process the initial embedding representation according to the preset threshold to obtain the enhanced node embedding representation of each node.
[0085] It can be understood that this embodiment uses a Graph Attention Network (GAT) to learn node embeddings. Each node calculates an attention coefficient based on the features of its neighbor nodes and the connection relationship between them. These attention coefficients are then used to weight the features of the neighbor nodes and aggregated to the current node through a summation operation to form the enhanced feature representation of the node. GAT weights and aggregates node features through an attention mechanism to highlight important neighbor node information. Among them, the calculation formula of the attention coefficient is shown in Formula 1:
[0086]
[0087] In the formula, Denotes the attention coefficient of the i-th node in the k-th graph view; Denotes the learnable weight matrix obtained from the feature matrix through the k-th graph view; Denotes the learnable weight vector; x i Denotes the i-th node feature vector; x j Denotes the feature vector of the j-th neighbor node; x p Denotes the feature vector of the p-th neighbor node; v p ∈ N i Denotes the N iThe p-th vertex in the vertex set; || represents the concatenation operation, and LeakyReLU(·) represents the non-linear activation function.
[0088] Then, the node features are weighted and summed according to the calculated attention coefficients to obtain the initial embedding representation of each node. Among them, the calculation formula of the initial embedding representation is shown in Formula 2:
[0089]
[0090] In the formula, f(v i ) represents the initial embedding representation of the i-th node; represents the j-th vertex in the N i -th vertex set; x j represents the feature vector of the j-th neighbor node; ELU(·) represents the non-linear activation function.
[0091] Next, based on a preset threshold, the initial node embeddings are divided into different intervals, and the initial node embeddings in each interval are threshold-processed to enhance the discrimination of the initial node embeddings, obtaining the enhanced node embedding representation corresponding to each node. Among them, the enhanced node embedding representation is shown in Formula 3:
[0092]
[0093] In the formula, θ represents the size of the preset threshold.
[0094] It can be understood that the process of calculating the similarity weight for the network graph to be processed includes, but is not limited to, the following steps:
[0095] Calculate the graph structure similarity of the enhanced network graph to be processed;
[0096] Calculate the feature similarity of the enhanced network graph to be processed;
[0097] Calculate the fusion similarity according to the graph structure similarity and the feature similarity;
[0098] Obtain the first temperature hyperparameter and the second temperature hyperparameter;
[0099] Calculate a monotonically increasing function according to the fusion similarity and the first temperature hyperparameter;
[0100] Calculate a monotonically decreasing function according to the fusion similarity and the second temperature hyperparameter;
[0101] Calculate the node positive sample possibility in the similarity weight according to the monotonically increasing function;
[0102] Calculate the node negative sample possibility in the similarity weight according to the monotonically decreasing function.
[0103] In the embodiments of the present application, an iterative approximation method is used to calculate the Personalized PageRank (PPR) matrix to obtain the graph structure similarity. Among them, the calculation formula of the graph structure similarity is shown in Formula 4:
[0104]
[0105] In the formula, sim G (v i ,v j ) represents the graph structure similarity; D represents the degree matrix of the adjacency matrix A'; K represents the number of iteration steps; α ∈ (0, 1) represents the propagation coefficient.
[0106] The calculation formula of the feature similarity is shown in Formula 5:
[0107] sim F (v i ,v j ) = cos(x i ,x j ) Formula 5;
[0108] In the formula, sim F (v i ,v j ) represents the feature similarity; cos(x i ,x j ) represents the cosine similarity between two nodes x i and x j .
[0109] The calculation formula of the fusion similarity is shown in Formula 6:
[0110] sim(v i ,v j ) = β·sim F (v i ,v j )·γ + (1 - β)·sim G (v i ,v j ) Formula 6;
[0111] In the formula, sim(v i ,v j ) represents the fusion similarity; β is a hyperparameter for balancing the two similarities; γ = ∑sim G (v i ,v j ) / ∑sim F (v i ,v j) is a scaling factor that controls the relative scale of the two similarity scores, so that the magnitudes of the two similarities are on the same order of magnitude.
[0112] To control the magnitude and distribution of the weights, in this embodiment, two monotonic functions are used to process the similarity as follows to achieve the adjustment of the influence degrees of the positive and negative samples. Specifically, the monotonically increasing function is calculated by formula 7:
[0113]
[0114] The monotonically decreasing function is calculated by formula 8:
[0115]
[0116] In the formula, represents the monotonically increasing function, represents the monotonically decreasing function, τ p represents the first temperature hyperparameter; τ n represents the second temperature hyperparameter.
[0117] The node positive sample likelihood in the similarity weight is calculated by formula 9:
[0118]
[0119] The node negative sample likelihood in the similarity weight is calculated by formula 10:
[0120]
[0121] In the formula, represents the node positive sample likelihood; represents the node negative sample likelihood; and are M and N nodes obtained from the uniform distribution respectively.
[0122] After completing the above two processing procedures, the loss value of the network graph to be processed is calculated according to the enhanced node embedding representation and the similarity weight. Among them, the calculation formula of the loss value is as shown in formula 11:
[0123]
[0124] In the formula, represents the loss value; represents the node v i 's positive sample likelihood; represents the node v i 's negative sample likelihood; represents the node v i belonging to the i-th node in the positive sample set ; Denote node v i belongs to the negative sample set and is the i-th node in it; The f′(v) and f′(v i ) in represent the enhanced node embedding representations of any two nodes in the positive sample set; The f′(v) and f′(v i ) in represent the enhanced node embedding representations of any two nodes in the negative sample set; The f′(v) and f′(v ′ ) in represent the enhanced node embedding representations of any two nodes in the to-be-processed network graph; τ represents the third temperature hyperparameter.
[0125] It can be understood that the above processing process can be a training process of the node embedding model. Based on the above processing process, this embodiment can complete the entire training and parameter optimization process of the node embedding model through the following steps:
[0126] Step 1, calculate the loss function according to the parameters of the current node embedding model where the parameters of the model include the node embedding representation f(v i ), the similarity weight and the attention weight vector and the weight matrix W (k) , and the temperature parameter τ.
[0127] Step 2, calculate the gradients of the loss function with respect to each parameter through backpropagation Exemplarily: the gradient of the loss function with respect to the weight matrix in the graph attention network (GAT):
[0128] Step 3, use the gradient descent method (Adam optimizer) to update the parameters of the node embedding model. Exemplarily, update the node embedding representation:
[0129] Step 4, repeat the iteration until the node embedding model converges or reaches a predetermined number of training rounds.
[0130] Specifically, the pseudocode corresponding to the method of this embodiment is shown in Table 1:
[0131] Table 1
[0132]
[0133] In some embodiments, experiments are conducted on the embodiments of the present application. Three citation networks (Cora, CiteSeer, PubMed) and one commodity network (Amazon - photo) are selected as implementation cases for the experiment. Each case is a complex network dataset composed of nodes, edges, features, and class labels, etc. The experiment takes the improved graph embedding method as the core, and through node similarity calculation and threshold processing technology, the discrimination ability and generalization ability of node embedding are improved. Now, taking 6 nodes V = {v1, v2, v3, v4, v5, v6} as an example, each node has 4 features and each node is connected to several edges. Specifically, the experimental steps include but are not limited to the following steps:
[0134] Step 1: Data pre - processing:
[0135] Construct an adjacency matrix A and extract the node feature matrix X.
[0136]
[0137] Step 2: GAT embedding learning
[0138] Use the graph attention network (GAT) to calculate node embeddings, assign weights to their features according to the importance of neighbor nodes, and generate the initial node embedding H through non - linear activation. The specific calculation process is as follows:
[0139] Step 2.1: Obtain weight coefficients: Each node distributes attention weights to its neighbors based on the adjacency matrix. For the sake of simplifying the example, it is assumed here that the attention coefficients are evenly distributed. In actual applications, the attention coefficients are calculated by formula (1):
[0140] v1: d1 = 2 → attention weight = 0.5;
[0141] v2: d2 = 3 → attention weight = 0.33;
[0142] The same operation is performed for other nodes.
[0143] Step 2.2: Aggregate the weights of nodes: Each node aggregates the features of its neighbors weighted by the attention coefficients:
[0144] For v1 (neighbors are {v2, v3}):
[0145] H(v1) = 0.5×[0, 1, 0, 1] + 0.5×[1, 1, 0, 0] = [0.5, 1, 0, 0.5];
[0146] For v2 (neighbors are {v1, v3, v5}):
[0147] H(v2) = 0.33 × [1, 0, 1, 0] + 0.33 × [1, 1, 0, 0] + 0.33 × [1, 0, 0, 1] = [0.99, 0.33, 0.33, 0.33];
[0148] The same calculation method is used for other nodes, and finally the embedding matrix is obtained:
[0149]
[0150] Step 3: Threshold processing
[0151] Set the preset threshold of the embedding vector, and divide the embedding space into several intervals. Optimize the embedding vectors in each interval to enhance the feature discrimination and delete the low-weight information. Here, the preset threshold is 0.4, and the embedding matrix is obtained:
[0152]
[0153] Step 4: Enhance the adjacency matrix
[0154] Enhance the adjacency matrix through the random attack method, including adding or deleting a certain proportion of edges. Here, the perturbation ratio is set to 5%, and the edges connecting {v1, v5} and {v2, v4} are added to obtain the enhanced adjacency matrix A':
[0155]
[0156] Step 5: Similarity weight calculation
[0157] Calculate the semantic similarity between nodes using personalized PageRank and cosine similarity. By comparing with the embedding results, identify possible "false negative" samples and correct the embedding representation. Here, the propagation coefficient α is set to 0.1, the hyperparameter β for balancing graph similarity and feature similarity is 0.5, and the number of random walk steps k is 10, to obtain the similarity weight matrix:
[0158]
[0159] Step 6: Loss calculation
[0160] Combined with the positive and negative sample weights, optimize the node embedding representation f(v i ) using formula (11), the similarity weight and the attention weight vector in the graph attention mechanism and the weight matrix W (k) , temperature hyperparameter τ and other parameters.
[0161] Step 7: Obtain the optimized embedding matrix
[0162] Using the optimized parameters calculated in step 6, regenerate the embedding matrix of the nodes, remove the noise information in the embeddings, and further improve the discrimination. According to the experimental example, after optimizing 6 nodes, the following embedding matrix is obtained:
[0163]
[0164] Step 8: Obtain the classification result
[0165] Calculate the similarity matrix using cosine similarity:
[0166]
[0167] Nodes 0, 1, 2, 3, 4 form a main category with high similarity, indicating that their relationship in the embedding feature space is relatively close. The similarity between node 5 and other nodes is low, so it is classified into a separate category.
[0168] From the above experiments, it can be seen that compared with the traditional method, the method of the embodiment of the present application for generating node embeddings has a significant improvement in accuracy when applied to downstream tasks.
[0169] In summary, the method of the embodiment of the present application combines the advantages of graph attention mechanism (GAT) and graph contrastive learning (GCL), and introduces similarity contrast and threshold processing techniques, which significantly improves the quality and applicability of node embeddings. In the training of the node embedding model, the attention mechanism of GAT is used to effectively capture the importance information of neighbor nodes, so as to generate richer and more discriminative embedding representations; through threshold processing, redundant information in the embedding vectors is removed, the feature representations are optimized, and the calculation efficiency and the adaptability of the model are improved. At the same time, the present invention effectively identifies and filters "false negative" samples through similarity contrast learning, reduces the interference of noise on the training process, and further enhances the embedding accuracy and generalization ability of the model.
[0170] In addition, the method of the embodiment of the present application integrates graph structure similarity and node feature similarity, uses multi-dimensional similarity information for comprehensive modeling, and comprehensively mines the semantic associations between nodes, providing a more accurate and complete perspective for the embedding representation of complex networks. In the data augmentation stage, a random attack method is used to delete or add edges to simulate the dynamic changes of the network, making the model have stronger noise resistance and robustness. The present invention is applicable to various types of complex networks, including social networks, knowledge graphs, and biological networks, and can be widely used in tasks such as recommendation systems, community discovery, and user profiling.
[0171] Generally speaking, the method of the embodiment of the present application improves the representation ability, classification and clustering performance of node embeddings. At the same time, it has high efficiency, generality and adaptability, and has important practical value and broad application prospects in the field of complex network analysis.
[0172] Referring to Figure 3 , the embodiment of the present application provides a node embedding optimization device, which includes:
[0173] The first module 310 is used to obtain the network graph to be processed;
[0174] The second module 320 is used to perform adaptive graph enhancement on the network graph to be processed to obtain several graph views;
[0175] The third module 330 is used to perform threshold processing on the nodes of each graph view to obtain the enhanced node embedding representation of each node;
[0176] The fourth module 340 is used to enhance the network graph to be processed by a random attack method;
[0177] The fifth module 350 is used to calculate the similarity weight of the enhanced network graph to be processed;
[0178] The sixth module 360 is used to calculate the loss value of the network graph to be processed according to the enhanced node embedding representation and the similarity weight;
[0179] The seventh module 370 is used to update the node embedding representation of the network graph to be processed according to the loss value until the network graph to be processed is in a convergent state or the number of iterations is greater than or equal to a preset number of times.
[0180] It can be understood that the content in the above method embodiments is applicable to the device embodiments of the present application. The functions specifically implemented by the device embodiments of the present application are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those of the above method embodiments.
[0181] The embodiment of the present application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor implements the above method when executing the computer program. This computer device can be any intelligent terminal including a tablet computer, a vehicle-mounted computer, etc.
[0182] It can be understood that the content in the above method embodiments is applicable to the device embodiments of the present application. The functions specifically implemented by the device embodiments of the present application are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those of the above method embodiments.
[0183] Please refer to Figure 4 , Figure 4Schematically shows the hardware structure of a computer device according to another embodiment. The computer device includes:
[0184] A processor 410, which can be implemented in ways such as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0185] A memory 420, which can be implemented in forms such as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 420 can store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 420 and are called by the processor 410 to execute the above methods of the embodiments of the present application;
[0186] An input / output interface 430, which is used to implement information input and output;
[0187] A communication interface 440, which is used to implement communication interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or through wireless means (such as mobile network, WIFI, Bluetooth, etc.);
[0188] A bus 450, which transmits information between various components of the device (such as the processor 410, the memory 420, the input / output interface 430, and the communication interface 440);
[0189] Among them, the processor 410, the memory 420, the input / output interface 430, and the communication interface 440 achieve communication connections with each other inside the device through the bus 450.
[0190] The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above methods are implemented.
[0191] It can be understood that the content in the above method embodiments is applicable to the embodiments of this storage medium. The functions specifically implemented by the embodiments of this storage medium are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those of the above method embodiments.
[0192] The memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory optionally includes a memory remotely disposed relative to the processor, and these remote memories can be connected to the processor through a network. Examples of the above networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0193] The embodiments described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art will know that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
[0194] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or combine certain steps, or different steps.
[0195] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0196] Those of ordinary skill in the art can understand that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, and appropriate combinations thereof.
[0197] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0198] It should be understood that in this application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects and indicates that three relationships can exist. For example, "A and / or B" can mean: only A exists, only B exists, and both A and B exist at the same time. Among them, A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after. "At least one (one) of the following" or a similar expression means any combination of these items, including any combination of single items (ones) or plural items (ones). For example, at least one (one) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0199] In several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the above division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of devices or units can be in electrical, mechanical or other forms.
[0200] The units described above as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0201] In addition, each functional unit in various embodiments of this application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0202] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes: various media that can store programs, such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.
[0203] The preferred embodiments of the embodiments of this application have been described above with reference to the accompanying drawings, which does not limit the scope of rights of the embodiments of this application. Any modifications, equivalent replacements, and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of this application shall be within the scope of rights of the embodiments of this application.
Claims
1. A method for optimizing node embedding, characterized in that The method includes the following steps: Obtain the network diagram to be processed; Perform adaptive graph enhancement on the network diagram to be processed to obtain several graph views; Perform threshold processing on the nodes of each graph view to obtain the enhanced node embedding representation of each node; Enhance the network diagram to be processed by a random attack method; Calculate the similarity weight of the enhanced network diagram to be processed; Calculate the loss value of the network diagram to be processed according to the enhanced node embedding representation and the similarity weight; Update the node embedding representation of the network diagram to be processed according to the loss value until the network diagram to be processed is in a converged state or the number of iterations is greater than or equal to a preset number of times.
2. The method according to claim 1, characterized in that, The step of performing threshold processing on the nodes of each graph view to obtain the enhanced node embedding representation of each node includes: Calculate the attention coefficient of each node in each graph view; Calculate the initial embedding representation of each node according to the attention coefficient; Obtain a preset threshold; Process the initial embedding representation according to the preset threshold to obtain the enhanced node embedding representation of each node.
3. The method according to claim 2, wherein The calculation formula of the attention coefficient is as follows: In the formula, represents the attention coefficient of the i-th node in the k-th graph view; represents the learnable weight matrix obtained from the feature matrix through the k-th graph view; represents the learnable weight vector; x i represents the feature vector of the i-th node; x j represents the feature vector of the j-th neighbor node; x p represents the feature vector of the p-th neighbor node; v p ∈ N i represents the p-th vertex in the N i -th vertex set; || represents the concatenation operation, and LeakyReLU(·) represents the non-linear activation function.
4. The method according to claim 3, characterized in that, The calculation formula of the initial embedding representation is as follows: In the formula, f(v i ) represents the initial embedding representation of the i-th node; represents the j-th vertex in the N i -th vertex set; x j represents the feature vector of the j-th neighbor node; ELU(·) represents the non-linear activation function.
5. The method according to claim 1, characterized in that, The step of calculating the similarity weight of the enhanced network diagram to be processed includes: Calculate the graph structure similarity of the enhanced network diagram to be processed; Calculate the feature similarity of the enhanced network diagram to be processed; Calculate the fusion similarity according to the graph structure similarity and the feature similarity; Obtain a first temperature hyperparameter and a second temperature hyperparameter; Calculate a monotonically increasing function according to the fusion similarity and the first temperature hyperparameter; Calculate a monotonically decreasing function according to the fusion similarity and the second temperature hyperparameter; Calculate the node positive sample probability in the similarity weight according to the monotonically increasing function; Calculate the node negative sample probability in the similarity weight according to the monotonically decreasing function.
6. The method according to claim 1, wherein The calculation formula of the loss value is as follows: In the formula, represents the loss value; represents the positive sample probability of node v i ; represents the negative sample probability of node v i ; represents that node v i belongs to the i-th node in the positive sample set ; v i ∈V N represents that node v i belongs to the i-th node in the negative sample set V N ; The f′(v) and f′(v i ) in represent the enhanced node embedding representations of any two nodes in the positive sample set; The f′(v) and f′(v i ) in represent the enhanced node embedding representations of any two nodes in the negative sample set; The f′(v) and f′(v′) in represent the enhanced node embedding representations of any two nodes in the to-be-processed network graph; τ represents the third temperature hyperparameter.
7. The method according to claim 1, wherein The step of updating the node embedding representation of the network diagram to be processed according to the loss value includes: Calculate the gradient of the loss value with respect to the node embedding representation in the network diagram to be processed through backpropagation; Update the node embedding representation of the network diagram to be processed according to the gradient.
8. A node embedding optimization device, characterized in that The device includes: A first module for obtaining the network diagram to be processed; A second module for performing adaptive graph enhancement on the network diagram to be processed to obtain several graph views; A third module for performing threshold processing on the nodes of each graph view to obtain the enhanced node embedding representation of each node; A fourth module for enhancing the network diagram to be processed by a random attack method; A fifth module for calculating the similarity weight of the enhanced network diagram to be processed; A sixth module for calculating the loss value of the network diagram to be processed according to the enhanced node embedding representation and the similarity weight; A seventh module for updating the node embedding representation of the network diagram to be processed according to the loss value until the network diagram to be processed is in a converged state or the number of iterations is greater than or equal to a preset number of times.
9. A computer device, characterized in that, Includes: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.