Method for shaping graph structure features, terminal device, and computer-readable storage medium

By performing clustered training and parameter updates on contradictory samples in the graph structure and utilizing multi-head attention layers and feature extraction layers, the gradient cancellation problem caused by contradictory samples is solved, a more accurate representation of graph structure features and aggregation of similar elements are achieved, and the performance and accuracy of the model are improved.

CN120449928BActive Publication Date: 2025-09-12YUNNAN NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510952005.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-10
Publication Date
2025-09-12
Estimated Expiration
2045-07-10

AI Technical Summary

Technical Problem

In graph structures, the existence of contradictory samples causes gradients to offset each other during model training and learning, affecting the accuracy and performance of the model, especially in fields such as social networks, bioinformatics, and recommendation systems, resulting in inaccurate node representation and degraded task performance.

Method used

By dividing the contradictory samples into multiple contradictory sample sets, performing multiple forward propagation and backpropagation in the target model, updating the model parameters, and using the multi-head attention layer and feature extraction layer, combined with Euclidean distance and gradient optimization, the influence of contradictory samples is eliminated and the contradictory samples are moved to the center of the category.

Benefits of technology

The performance of the model is significantly improved, enabling similar elements to be effectively aggregated and separated by boundaries, improving the quality and accuracy of graph structure processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120449928B_ABST
    Figure CN120449928B_ABST
Patent Text Reader

Abstract

The present application relates to a method for shaping graph structure features, a terminal device, and a computer-readable storage medium. The method includes: dividing contradictory samples into multiple contradictory sample sets, and performing multiple centripetal training on the contradictory samples in a target model to continuously update the model parameters of the target model, so that the trained target model can move the contradictory samples to the center of the category to which they belong, thereby resolving the contradictory samples and significantly improving the performance of the target model. Finally, the target model can obtain a target graph structure with similar elements aggregated and boundaries separated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of graph data processing, and in particular to a method for shaping graph structural features, a terminal device, and a computer-readable storage medium. Background Art

[0002] Graphs, due to their complex topology and rich semantic relationships, are widely used in fields such as social network analysis, bioinformatics, computational chemistry, and recommender systems. The characteristic representation of a graph is determined by its dynamic topology, inherent characteristics, and neighborhood connectivity patterns. However, when similar elements in a graph are aggregated, the feature distribution of the subgraphs often changes, resulting in different true features within the same structure. This difference in feature distribution can lead to offsetting gradients at different nodes during model training and learning.

[0003] For example, in typical graph data applications such as citation networks and social networks, certain special nodes, due to their unique connectivity (such as interdisciplinary citation relationships in citation networks), exhibit characteristic patterns that differ from those of adjacent nodes or other regular nodes. When similar elements in these graph structures are aggregated, the gradients generated by these nodes with special characteristics conflict with the gradients of adjacent nodes, making it difficult for the model to accurately learn the correct representation of each node, resulting in inaccurate node representations, or "contradictory samples." These inaccurate node representations can affect the performance of subsequent graph-based tasks, such as aggregating similar elements in a graph structure.

[0004] In view of this, there is an urgent need to propose a method for shaping graph structure features, a terminal device and a computer-readable storage medium in order to effectively solve the problem of "contradictory samples" affecting model performance.

[0005] The above content is only used to assist in understanding the technical solution of this application and does not constitute an admission that the above content is prior art. Summary of the Invention

[0006] This application aims to solve the technical problem that contradictory samples affect model performance by providing a method for shaping graph structure features, a terminal device and a computer-readable storage medium.

[0007] To achieve the above objectives, an embodiment of the present application provides a method for shaping graph structural features, comprising:

[0008] Determining contradictory samples in the graph structure, and dividing the contradictory samples into a plurality of contradictory sample sets;

[0009] Forward propagating the graph structure in a pre-trained target model to obtain a first hidden layer feature corresponding to each sample in each of the contradictory sample sets, wherein initial model parameters of the target model when processing each of the contradictory sample sets are set to model parameters obtained after the last pre-training of the target model, and the first hidden layer feature is a node feature of the contradictory sample in the graph structure output by the residual connection multi-head attention layer in the target model;

[0010] updating the model parameters of the target model based on the first hidden layer features corresponding to each sample in each of the contradictory sample sets;

[0011] Forward propagating the graph structure in the target model to obtain a second hidden layer feature corresponding to each sample in each of the contradictory sample sets, wherein initial model parameters of the target model when processing each of the contradictory sample sets are set to model parameters obtained after the target model was last updated, and the second hidden layer feature is a node feature of the contradictory sample in the graph structure output by the residual connection multi-head attention layer in the target model;

[0012] updating the model parameters of the target model based on the first hidden layer features and the second hidden layer features corresponding to each sample in each of the contradictory sample sets;

[0013] Forward propagating the graph structure in the target model to obtain a target graph structure after similar elements are aggregated, wherein the target graph structure is the output of the residual connection multi-head attention layer in the target model;

[0014] The target model includes at least two parallel feature extraction layers, a first splicing layer and a residual connection multi-head attention layer connected in sequence, and the output of the feature extraction layer is connected to the input of the first splicing layer; the feature extraction layer includes a first convolutional layer, a first activation function layer and a first dropout layer connected in sequence.

[0015] In some embodiments, updating the model parameters of the target model based on the first hidden layer features corresponding to each sample in each of the contradictory sample sets includes:

[0016] Calculate the feature mean of the first hidden layer feature corresponding to each sample in each contradictory sample set and the feature mean of the category to which it belongs; calculate the feature mean of the first hidden layer feature corresponding to each sample in each contradictory sample set and the feature mean of the category to which it belongs

[0017] The square of the Euclidean distance to the mean of the above features;

[0018] Calculating the sum of the squares of the Euclidean distances corresponding to each sample in each of the contradictory sample sets, wherein the sum is the boundary loss value of the contradictory sample set;

[0019] Back-propagating the boundary loss value of each of the contradictory sample sets in the target model to obtain a first gradient corresponding to each of the contradictory sample sets;

[0020] A preset optimizer is used to update the model parameters of the target model according to the first gradient corresponding to each of the contradictory sample sets.

[0021] In some embodiments, updating the model parameters of the target model based on the first hidden layer features and the second hidden layer features corresponding to each sample in each of the contradictory sample sets includes:

[0022] Calculating the feature average distance of each contradictory sample set according to the first hidden layer feature and the second hidden layer feature corresponding to each sample in each contradictory sample set;

[0023] Determining the weight of the first gradient corresponding to each of the contradictory sample sets according to the feature average distance of each of the contradictory sample sets;

[0024] aggregating the first gradients of all the contradictory sample sets according to the weights of the first gradients of the contradictory sample sets to obtain a first target gradient;

[0025] The preset optimizer is used to update the model parameters of the target model according to the first target gradient.

[0026] In some embodiments, determining contradictory samples in the graph structure includes:

[0027] Performing a forward propagation of the graph structure in the pre-trained target model to obtain a third hidden layer feature corresponding to each sample in the graph structure, wherein the third hidden layer feature is a node feature of the sample in the graph structure output by the residual connection multi-head attention layer in the target model;

[0028] Select a training set;

[0029] Using a pre-classifier to perform training based on the third hidden layer features of each sample in the training set, to determine a category corresponding to each sample in the training set and a decision boundary corresponding to each category;

[0030] Calculate the absolute distance between each sample in each category and the decision boundary of the category to which it belongs;

[0031] The samples in the training set whose absolute distance is less than or equal to a preset threshold are selected as the contradictory samples.

[0032] In some embodiments, the target model further includes a second convolutional layer, a second activation function layer, a second dropout layer, and a second classification layer connected to the residual connection multi-head attention layer in sequence; and before determining the contradictory samples in the graph structure, the method further includes:

[0033] Performing semi-supervised learning pre-training on the target model using the graph structure to obtain a category probability corresponding to each sample in the graph structure, wherein the category probability is an output of the second classification layer;

[0034] The supervised learning loss and unsupervised learning loss of the target model are calculated using the category probability corresponding to each sample, and the model parameters of the target model are updated according to the semi-supervised learning loss and unsupervised learning loss to obtain the pre-trained target model.

[0035] In some embodiments, the feature extraction layer further includes a first classification layer connected to the output of the first discard layer; and before performing semi-supervised learning pre-training on the target model using the graph structure to obtain the category probability corresponding to each sample in the graph structure, the method further includes:

[0036] Using the graph structure, the feature extraction layer in the target model is pre-trained with a preset number of semi-supervised learning rounds to obtain a category probability corresponding to each sample in the graph structure, wherein the category probability is the output of the first classification layer;

[0037] Calculating the supervised learning loss and unsupervised learning loss of the target model using the class probabilities corresponding to each sample;

[0038] The model parameters of the feature extraction layer in the target model are updated according to the semi-supervised learning loss and the unsupervised learning loss to obtain the pre-trained target model; wherein the proportion weight of unlabeled data in each round of training data gradually increases.

[0039] In some embodiments, after updating the model parameters of the target model based on the first hidden layer features and the second hidden layer features corresponding to each sample in each of the contradictory sample sets, the method further includes:

[0040] Forward propagating the graph structure through the target model to obtain a fifth hidden layer feature corresponding to each sample in the graph structure, wherein the fifth hidden layer feature is a node feature of the sample in the graph structure output by the residual connection multi-head attention layer in the target model;

[0041] Select a training set;

[0042] For each category of samples in the training set, a sample is randomly selected from samples of other categories as a negative sample;

[0043] All samples of each category in the training set are randomly shuffled, and the samples of each category in the training set in the original order and the samples in the same position after the shuffled order are used as positive sample pairs, wherein the samples in the original order are positive samples, and the samples in the same position after the shuffled order are paired samples;

[0044] Calculating the contrast loss of the positive sample pair according to the fifth hidden layer feature of the positive sample pair, and calculating the contrast loss of the negative sample according to the fifth hidden layer feature of the positive sample and the fifth hidden layer feature of the negative sample;

[0045] Calculating a total contrast loss based on the contrast loss of the positive sample pair and the contrast loss of the negative sample pair;

[0046] Back-propagating the total contrast loss in the target model to obtain a second target gradient;

[0047] Use a preset optimizer to update the model parameters of the target model according to the second target gradient, wherein the preset optimizer uses a gradient descent method to update the model parameters of the target model according to the second target gradient.

[0048] In some embodiments, the contrast loss of the positive sample pair is:

[0049]

[0050] Among them, the is the contrast loss of the positive sample pair, is the number of categories, m c is the total number of samples in category c is the fifth hidden layer feature of the i-th positive sample in category c, is the fifth hidden layer feature of the i-th paired sample in category c, and p is the Lp norm.

[0051] The contrast loss of the negative sample is:

[0052]

[0053] in, is the contrast loss of negative samples, C is the category, m c is the total number of samples in category C, is the fifth hidden layer feature of the i-th positive sample in category C, is the fifth hidden layer feature of the j-th negative sample in category C, is a constant, p is the Lp norm;

[0054] The total contrast loss is:

[0055]

[0056] in, is the total contrast loss, is the contrast loss of the positive sample pair, is the contrast loss of negative samples, is the weight.

[0057] In addition, to achieve the above-mentioned purpose, the present application also provides a terminal device, which includes: a memory, a processor, and a program for shaping the graph structure features of the terminal device stored on the memory and capable of running on the processor. When the program for shaping the graph structure features of the terminal device is executed by the processor, the steps of the method for shaping the graph structure features as described above are implemented.

[0058] In addition, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which a program for shaping the graph structure features of a terminal device is stored. When the program for shaping the graph structure features of the terminal device is executed by a processor, the steps of the method for shaping the graph structure features as described above are implemented.

[0059] The present application proposes a method for shaping graph structure features, a terminal device, and a computer-readable storage medium. By dividing contradictory samples into multiple contradictory sample sets and performing multiple centripetal training on the contradictory samples in the target model to continuously update the model parameters of the target model, the trained target model can move the contradictory samples to the center of the category to which they belong, thereby resolving the contradictory samples and significantly improving the performance of the target model. Finally, the target model can obtain a target graph structure with similar elements aggregated and boundaries separated. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 A schematic diagram of the network structure of the target model in some embodiments of the present application;

[0061] Figure 2 A flowchart of the steps of a method for shaping graph structure features in some embodiments of the present application;

[0062] Figure 3 A flowchart of the steps of a method for shaping graph structure features in some embodiments of the present application;

[0063] Figure 4 A flowchart of the steps of a method for shaping graph structure features in some embodiments of the present application;

[0064] Figure 5 A flowchart of the steps of a method for shaping graph structure features in some embodiments of the present application;

[0065] Figure 6 It is a schematic diagram of the terminal structure of the hardware operating environment involved in some embodiments of the present application.

[0066] The realization of the objectives, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0067] It should be understood that the specific embodiments described herein are merely intended to explain the present application and are not intended to limit the present application. In order to better understand the above technical solutions, exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0068] Example 1

[0069] Reference Figure 1 , Figure 1 This is a schematic diagram of the network structure of the target model of some embodiments of the present application. Figure 1 As shown, the target model of this embodiment includes at least two parallel feature extraction layers, a first concatenation layer and a residual connection multi-head attention layer connected in sequence, wherein the output of the feature extraction layer is connected to the input of the first concatenation layer. The feature extraction layer includes a first convolution layer, a first activation function layer, and a first dropout layer connected in sequence.

[0070] In some embodiments, the first convolutional layer can adopt the convolutional layer in the classic graph neural network. The convolutional layer of the classic graph neural network is the convolutional layer in the classic graph neural network, which is used to extract features from the graph structure. It should be noted that the first convolutional layer in the at least two parallel feature extraction layers of this embodiment is taken from the convolutional layer in different classic graph neural networks, and different methods are used to extract features. For example, the frequency domain method and the spatial domain method. Therefore, by adopting multiple convolutional layers taken from the classic graph neural network to extract features at different levels of the graph structure, the data features can be fully captured, thereby providing rich information for shaping the graph structure features.

[0071] As you can understand, frequency-domain methods, based on graph signal processing theory, use the graph's Laplacian matrix to perform spectral convolution, map the graph signal to the frequency domain through Fourier transform, and then perform filtering. Spatial-domain methods perform local convolution operations directly on the graph, achieving information transfer by aggregating features from neighboring nodes.

[0072] Furthermore, the classic graph neural networks described above refer to groundbreaking, representative, and widely influential models in the field of graph neural networks. For example, classic graph neural networks include but are not limited to graph convolutional networks (GCNs), graph attention networks (GATs), graph sampling and aggregation (GraphSAGEs), and spectral graph convolutional networks (SGCNs).

[0073] As an example, the convolutional layer in the spectral convolutional network and the convolutional layer in the graph convolutional network can be taken as the first convolutional layer in the feature extraction layer, respectively. The convolutional layer in the spectral convolutional network uses the frequency domain method for feature extraction, while the convolutional layer in the graph convolutional network uses the spatial domain method for feature extraction.

[0074] In some embodiments, the first activation function uses a ReLU function, which is not specifically limited in this embodiment.

[0075] In some embodiments, the first dropout layer uses a random dropout mechanism to drop samples in the graph structure to prevent the target model from overfitting.

[0076] In some embodiments, the residual-connected multi-head attention layer includes at least two attention layers and a second splicing layer that is residually connected to the output of the previous attention layer and the first splicing layer. Specifically, the residual connection mechanism involves concatenating the output of the previous attention layer with the original input of the residual-connected multi-head attention layer, i.e., the output of the first splicing layer, to obtain fused features. This feature is then passed as input to the next attention layer for subsequent attention calculation and feature extraction, thereby achieving the fusion and progressive processing of features at different levels.

[0077] In some embodiments, the feature extraction layer further includes a first classification layer connected to the output of the first discard layer, which may use a log_softmax function to calculate the category probability corresponding to each sample in the graph structure output by the first discard layer in the feature extraction layer.

[0078] In some embodiments, the target model also includes a second convolutional layer, a second activation function layer, a second dropout layer, and a second classification layer connected to the residual connection multi-head attention layer in sequence, for fusing features of different levels extracted by at least two feature extraction layers to obtain a more comprehensive and representative feature representation, thereby improving the performance of the target model in extracting features.

[0079] In some embodiments, the second convolutional layer can be a convolutional layer taken from any graph neural network. Of course, those skilled in the art can also select or construct a suitable graph neural network convolutional layer according to the classified application scenario. This embodiment does not make specific limitations on this.

[0080] In some embodiments, the second activation function layer uses a nonlinear activation function, for example, a Sigmoid function.

[0081] In some embodiments, the second dropout layer uses a random dropout mechanism to drop samples in the graph structure to prevent the target model from overfitting.

[0082] In some embodiments, the second classification layer uses the log_softmax function to calculate the category probability corresponding to each sample in the graph structure output by the second discard layer.

[0083] Combination of the above Figure 1 The network structure of the target model of some embodiments of the present application is described in detail. Figure 2 This paper describes in depth the graph structure feature shaping method of some embodiments of this application. This method aims to eliminate the interference of contradictory samples on feature representation by performing targeted training on the target model, so that similar elements of the target graph structure output by the target model are aggregated and their boundaries are separated, effectively improving the quality and performance of graph structure processing.

[0084] It should be noted that the model parameters of the target model mentioned below all refer to the model parameters of the first convolutional layer in the feature extraction layer, and will not be repeated below.

[0085] Example 2

[0086] Reference Figure 2 , Figure 2 A method for shaping graph structure features according to some embodiments of the present application is shown, which includes steps S101 to S106.

[0087] Step S101: determining contradictory samples in a graph structure, and dividing the contradictory samples into multiple contradictory sample sets;

[0088] In this embodiment, the graph structure is the basic graph structure carrier for the feature representation of the graph data to be extracted, which includes a graph structure (Graph), which is composed of nodes (Node) and edges (Edge), and is mathematically expressed as G=(V, E). is a set of edges: ,side Connecting Nodes and . In addition, the graph structure can also include a node feature matrix and an edge index. The node feature matrix stores the feature vector corresponding to each node in the form of a matrix. Each row represents a node, and each column represents a specific feature dimension. These features can describe the various properties and characteristics of the node. The edge index is used to clarify the connection status of the edges in the graph. It is usually expressed as a two-dimensional matrix, each row of which corresponds to an edge, recording the index numbers of the two nodes connected by the edge. The edge index can clearly know the relationship between the nodes in the graph.

[0089] In some embodiments, the indexes of all contradictory samples are first randomly shuffled; then, based on the number of samples in a pre-set contradictory sample set, the contradictory samples after shuffling the indexes are evenly divided into multiple contradictory sample sets of similar size, thereby achieving the reorganization and distribution of the contradictory samples. For example, the number of samples in the contradictory sample set is , the i-th contradictory sample set obtained by the above method can be expressed as , the set of k contradictory sample sets can be expressed as How to determine contradictory samples in the graph structure will be described in detail in subsequent embodiments.

[0090] Step S102: forward propagating the graph structure in a pre-trained target model to obtain a first hidden layer feature corresponding to each sample in each of the contradictory sample sets, wherein the initial model parameters of the target model when processing each of the contradictory sample sets are set to the model parameters of the target model after the last pre-training, and the first hidden layer feature is the node feature of the contradictory sample in the graph structure output by the residual connection multi-head attention layer in the target model;

[0091] In this embodiment, when the target model processes each contradictory sample set, it is necessary to set the target model's initial model parameters to the model parameters obtained after the target model's last pre-training to ensure that the initial training state of each contradictory sample set is consistent. For example, the model parameters obtained after the target model's last pre-training are the first model parameters. Therefore, before each forward propagation of the contradictory sample set, the target model's initial model parameters are first modified to the first model parameters.

[0092] Therefore, the execution process of the above step S102 can be expressed as the following formula (1):

[0093] (1)

[0094] in, is the first hidden layer feature of the sample, Indicates the target model in the initial model parameters Next, forward propagation is performed on the graph structure (X, E).

[0095] Step S103: updating the model parameters of the target model based on the first hidden layer features corresponding to each sample in each of the contradictory sample sets;

[0096] In some embodiments, the specific execution process of the above step S103 is:

[0097] First, calculate the feature mean of the first hidden layer feature corresponding to each sample in each contradictory sample set, which corresponds to the category to which it belongs. The expression is as follows (2):

[0098] (2)

[0099] in, For the The first hidden layer features corresponding to the samples Belongs to category c j The characteristic mean of is a category The number of samples in is a category The index set of samples in , It is indivual .

[0100] Then calculate the square of the Euclidean distance between the first hidden layer feature of each sample in each contradictory sample set and the feature mean of the corresponding category, which is expressed as the following formula (3):

[0101] (3)

[0102] Among them, the For the The first hidden layer features of samples To The categories to which the samples belong The characteristic mean The square of the Euclidean distance, The category index.

[0103] The sum of the squared Euclidean distances of each sample in each contradictory sample set is further calculated, where the sum is the boundary loss value of the contradictory sample set, which is expressed as the following formula (4):

[0104] (4)

[0105] in, Contradictory sample set The square of the Euclidean distance between each sample The sum of Contradictory sample set Middle The boundary loss value of each sample.

[0106] After that, the boundary loss value of each contradictory sample set is back-propagated in the target model to obtain the first gradient corresponding to each contradictory sample set, which is expressed as the following formula (5):

[0107] (5)

[0108] in, Contradictory sample set The first gradient of Represents the contradictory sample set Boundary loss value Find the partial derivatives, Express Find the partial derivatives, are the initial model parameters of the target model.

[0109] Finally, the preset optimizer is used to update the model parameters of the target model according to the first gradient corresponding to each contradictory sample set. The updating process is: , I can understand, is the initial model parameter of the target model The updated model parameters of the target model are the target model. It is understood that the preset optimizer will use a corresponding optimization algorithm such as a gradient descent method to update the model parameters of the target model.

[0110] After the target model is updated, the following steps S104 to S106 are continued to be executed.

[0111] Step S104: forward propagating the graph structure in the target model to obtain a second hidden layer feature corresponding to each sample in each contradictory sample set, wherein the initial model parameters of the target model when processing each contradictory sample set are set to the model parameters obtained after the target model was last updated, and the second hidden layer feature is the node feature of the contradictory sample in the graph structure output by the residual connection multi-head attention layer in the target model;

[0112] In this embodiment, similar to the training of the aforementioned contradictory samples, before forward propagation of each contradictory sample set, the initial model parameters of the target model need to be set to the model parameters after the target model is updated in step S103 above. .

[0113] Step S105: updating the model parameters of the target model based on the first hidden layer features and the second hidden layer features corresponding to each sample in each of the contradictory sample sets;

[0114] In some embodiments, the specific execution process of the above step S105 is:

[0115] First, the feature average distance of each contradictory sample set is calculated based on the first hidden layer features and the second hidden layer features corresponding to each sample in each contradictory sample set. The expression is as follows (6):

[0116] (6)

[0117] in, Contradictory sample set The average Euclidean distance of the features output by the model before and after updating the model, is the sum of all training set samples of all categories, is the second hidden layer feature of the j-th sample, is the first hidden layer feature of the jth sample.

[0118] Then, according to the average feature distance of each contradictory sample set, the weight of the first gradient corresponding to each contradictory sample set is determined, and its expression is as follows (7) and (8):

[0119] (7)

[0120] in, is the weight, is the average distance of the features of the contradictory sample set, is a smoothing factor to prevent division by zero.

[0121] Get the weight W i After that, it needs to be normalized. The normalization process is as follows (8):

[0122] (8)

[0123] in, is the weight of the first gradient corresponding to the normalized contradictory sample set, is the weight of the first gradient corresponding to the contradictory sample set, For the The weight of the contradictory sample set is k, and k is the total number of contradictory sample sets.

[0124] Then, according to the weight of the first gradient of each contradictory sample set, the first gradients of all contradictory sample sets are aggregated to obtain the first target gradient, which is expressed as the following formula (9):

[0125] (9)

[0126] in, is the first target gradient, is the first gradient of the contradictory sample set, is the weight of the first gradient of the i-th contradictory sample set, and k is the total number of contradictory sample sets.

[0127] Finally, the preset optimizer is used to update the model parameters of the target model according to the first target gradient. The updating process is:

[0128]

[0129] Understandable are the updated model parameters of the target model, is the initial model parameter of the target model. It can be understood that the model parameters obtained after the last update of the target model are , so the initial model parameters of the current target model are = .

[0130] Therefore, through the above-mentioned training of contradictory samples in this embodiment, the target model can move the contradictory samples toward the center of their own category while ensuring that the vast majority of non-contradictory samples do not move, thereby eliminating the influence of the contradictory samples.

[0131] Step S106: forward propagating the graph structure in the target model to obtain a target graph structure after aggregation of similar elements, where the target graph structure is the output of the residual connection multi-head attention layer in the target model.

[0132] In this embodiment, because the target model was specifically trained for contradictory samples during the previous training process, the model can effectively identify and eliminate the interference caused by contradictory samples. As a result, in the current step, similar elements in the target graph structure output by the target model are clustered together and separated by boundaries, minimizing the errors and deviations caused by contradictory samples, thereby significantly improving the quality and effectiveness of the aggregation of similar elements in the graph structure.

[0133] Combination of the above Figure 2 The shaping method of the graph structure features of some embodiments of the present application is described in detail. Figure 3 The method of shaping the graph structure features of some embodiments of the present application is further described.

[0134] Example 3

[0135] Reference Figure 3 , Figure 3 This is a flowchart of the steps of the method for shaping the graph structure features of some embodiments of this application. It should be noted that, Figure 3 The method shown includes steps S201 to S205, which are the aforementioned Figure 2 A specific implementation of determining contradictory samples of the graph structure in step S101 in the method shown.

[0136] Step S201: forward propagating the graph structure in the pre-trained target model to obtain a third hidden layer feature corresponding to each sample in the graph structure, wherein the third hidden layer feature is a node feature of the sample in the graph structure output by the residual connection multi-head attention layer in the target model;

[0137] In this embodiment, the target model has been pre-trained, so the initial model parameters of the target model are the model parameters obtained after the target model was last pre-trained. For example, if the model parameters obtained after the target model was last pre-trained were the first model parameters, then the initial model parameters of the target model here are the first model parameters.

[0138] Step S202: selecting a training set;

[0139] In this embodiment, the method for selecting the training set is not limited, and those skilled in the art may select it based on their professional experience. For example, the graph structure may be randomly divided into training sets according to a certain ratio based on data characteristics, such as the number of nodes, edge connection density, and the distribution of node features.

[0140] Step S203: using a pre-classifier to perform training based on the third hidden layer features of each sample in the training set, to determine a category and a decision boundary corresponding to each sample in the training set;

[0141] In this embodiment, the pre-classifier is trained using the third hidden layer features of each sample in the aforementioned selected training set, ensuring that the pre-classifier has a good fit to the training set and obtaining a decision function. It will be appreciated that the decision boundary for each class can be determined using this decision function. For example, a curve or hyperplane formed by points where the decision function output is 0 or less than a preset threshold can be used as the decision boundary.

[0142] Assume that the third hidden layer feature of the sample in the training set is , the decision function obtained after pre-classifier pre-training is ,in is the decision boundary of the category, is a pre-classifier.

[0143] Step S204: Calculate the absolute distance between each sample in each category and the decision boundary of the category to which it belongs;

[0144] In this embodiment, as an example, the category score of the sample can be mapped to the interval [0, 1]. If the decision boundary is 0.5, then the absolute distance from the sample to the decision boundary is the absolute value of the category score minus 0.5.

[0145] Step S205: Selecting samples in the training set whose absolute distance is less than a preset threshold as the contradictory samples.

[0146] In this embodiment, the smaller the absolute distance is, the closer the sample is to the category boundary. Therefore, samples with an absolute distance less than or equal to a preset threshold are selected as contradictory samples.

[0147] In some embodiments, the preset threshold is set to the minimum absolute distance of each category, so that the sample with the minimum absolute distance in each category is selected as the contradictory sample. If there are too many samples with the minimum absolute distance, a preset number of samples can be selected as contradictory samples.

[0148] Through the above-mentioned contradictory sample selection method of this embodiment, contradictory samples can be accurately identified, thereby providing strong support for the subsequent resolution of contradictory samples and model optimization.

[0149] Combination of the above Figure 3 The shaping method of the graph structure features of some embodiments of the present application is described in detail. Figure 4 The method of shaping the graph structure features of some embodiments of the present application is further described.

[0150] Example 4

[0151] Reference Figure 4 , Figure 4 This is a flowchart of the steps of a method for shaping graph structure features in some embodiments of the present application. Figure 4 The method shown includes steps S301 and S302, which are performed before the above-mentioned step S101 and are used to pre-train the target model.

[0152] Step S301: performing semi-supervised learning pre-training on the target model using the graph structure to obtain a category probability corresponding to each sample in the graph structure, wherein the category probability is the output of the second classification layer;

[0153] In this embodiment, a graph structure is input into the target model, which then performs semi-supervised learning training on the input graph structure to obtain the class probabilities corresponding to each sample in the graph structure. It is understandable that due to the semi-supervised learning training, some of the graph structure is labeled with class labels, while others are not.

[0154] Step S302: Calculating the supervised learning loss and unsupervised learning loss of the target model using the category probability corresponding to each sample;

[0155] In this embodiment, the supervised learning loss is calculated by the category probability of samples marked with category labels, and the unsupervised learning loss is calculated by the category probability of samples not marked with category labels.

[0156] In some embodiments, the expression of supervised learning loss is the following formula (10), and the expression of unsupervised learning loss is the following formula (11):

[0157] (10)

[0158] in, is the supervised learning loss, For samples The class probability of belonging to class c, The true category label for the sample, is the total number of samples marked with category labels.

[0159] (11)

[0160] in Loss for unsupervised learning For samples The class probability of belonging to class c, is the category output by the sample model, is the total number of samples that are not labeled.

[0161] Step S303: updating the model parameters of the target model according to the supervised learning loss and the unsupervised learning loss to obtain the pre-trained target model.

[0162] In this embodiment, after obtaining the supervised learning loss and the unsupervised learning loss, the pre-trained model parameters of the target model can be further calculated based on the supervised learning loss and the unsupervised learning loss, thereby updating the current model parameters of the target model to the model parameters calculated based on the supervised learning loss and the unsupervised learning loss. For example, the pre-trained model parameters of the target model calculated based on the supervised learning loss and the unsupervised learning loss are the first model parameters, and then the current model parameters of the target model are updated to the first model parameters, thereby obtaining the pre-trained target model.

[0163] In some embodiments, the expression for calculating the model parameters of the pre-trained target model based on the supervised learning loss and unsupervised learning loss obtained above is the following formula (12):

[0164] (12)

[0165] in, are the model parameters after pre-training of the target model, is the current model parameter of the target model, is the unsupervised learning loss, is the supervised learning loss, is the weight, is the gradient, is the learning rate.

[0166] Through the above-mentioned pre-training of the target model, feature complementarity across target models, dynamic attention weight allocation, and end-to-end classification with graph structure awareness can be achieved, significantly improving the generalization ability of the target model in semi-supervised scenarios.

[0167] In some embodiments, before executing step S301 above, that is, before pre-training the target model, the feature extraction layer of the target model is first trained to improve the generalization ability of the target model in feature extraction. As an implementation method for training the feature extraction layer, the feature extraction layer of the target model can be trained through a preset number of rounds of semi-supervised learning.

[0168] It is understandable that due to the semi-supervised learning training, part of the graph structure is marked with the real category labels, while part is not marked with the real category labels.

[0169] Specifically, the feature extraction layer in the target model is trained with a preset number of semi-supervised learning rounds using a graph structure to obtain the category probability corresponding to each sample in the graph structure, where the category probability is the output of the first classification layer. The semi-supervised learning loss and the unsupervised learning loss are then calculated based on the category probability corresponding to the sample. Similarly, the supervised learning loss here is calculated based on the category probability of samples marked with category labels, while the unsupervised learning loss is calculated based on the category probability of samples not marked with category labels. The specific calculation method is not specifically limited in this embodiment.

[0170] In some embodiments, when the feature extraction layer is trained for semi-supervised learning, the weight of the proportion of unlabeled data in the training data of each round is also limited to gradually increase. It should be noted that the weight of the proportion of unlabeled data in the training data of each round is gradually increased, which means that in the later training rounds, the proportion of unlabeled data is larger, and the proportion of labeled data is smaller. Through such a setting, the target model's dependence on manually labeled data can be significantly reduced, effectively reducing the labeling cost. The target model uses unlabeled data to mine potential features and distribution patterns, which not only expands the scale of training data, but also learns more universal knowledge from massive unlabeled samples, thereby improving the generalization ability of feature extraction. At the same time, as the target model deepens its understanding of the inherent patterns of the data, the judgment of the results in the prediction process is more accurate and stable, thereby increasing the confidence level of the target model's feature extraction, and ultimately achieving an efficient, accurate and robust classification effect.

[0171] In some embodiments, the weight expression of the unlabeled data in each round of training data is as follows (13):

[0172] (13)

[0173] Among them, epoch is the current round, epochs is the total training round, Tune the hyperparameters of the power function growth curve.

[0174] The above overall combination Figure 4 The method for shaping graph structure features in some embodiments of this application is described in detail. By pre-training the target model through semi-supervised learning, the overall generalization ability of the pre-trained target model is significantly improved. This enhanced generalization performance enables the target model to better adapt to different scenarios and changes in data distribution. When faced with complex and changing graph structures, the pre-trained target model can more accurately and stably extract key features from the data, laying a solid foundation for the subsequent aggregation of similar elements in the graph structure, effectively enhancing the practicality and effectiveness of the target model in the field of graph data.

[0175] Example 5

[0176] Reference Figure 5 , Figure 5 This is a flowchart of the steps of the method for shaping the graph structure features of some embodiments of this application. It should be noted that, Figure 5 The method shown is executed after the above step S105 to further train the target model and improve the target model's ability to aggregate similar elements in the graph structure, which includes steps S401 to S409.

[0177] Step S401: forward propagating the graph structure in the target model to obtain a fifth hidden layer feature corresponding to each sample in the graph structure, wherein the fifth hidden layer feature is a node feature of the sample in the graph structure output by the residual connection multi-head attention layer in the target model;

[0178] In this embodiment, based on the above, it can be known that after the target model executes the above step S105, its model parameters are updated to . Therefore, the target model here is is the initial model parameter, and the fifth hidden layer features corresponding to each sample in the graph structure are predicted.

[0179] In some embodiments, after obtaining the fifth hidden layer feature by executing the above step S401, the fifth hidden layer feature is further input into the residual connection multi-head attention layer, and the node feature of the sample in the graph structure output again by the residual connection multi-head attention layer is used as the actual fifth hidden layer feature.

[0180] Step S402: selecting a training set;

[0181] In this embodiment, the method of selecting the training set is not limited, and those skilled in the art can select it based on their own professional experience. For example, the fifth hidden layer features corresponding to each sample in the training set can be masked, and the category label features corresponding to each sample in the training set can be masked to select the training set. When the training set mask of a sample in the entire sample set is True, it means that this sample is a training set. If the training set mask of this sample is False, it means that this sample is not a training set. Here, the category label features corresponding to each sample are generated based on the category label, for example, using One-Hot Encoding to generate a binary vector of category label features from the category label.

[0182] Next, the following steps S403 and S404 are executed to generate corresponding paired samples and negative samples for each sample in the training set.

[0183] Step S403: For each category of samples in the training set, randomly select a sample from samples of other categories as a negative sample;

[0184] In this embodiment, a sample that belongs to a different category from the sample is randomly selected as a negative sample.

[0185] In some embodiments, negative samples can also be selected in this way, that is, for each class , from non Random selection from the class samples as a negative sample of class c, and if Then directly use all non class samples to prevent negative samples from dominating the loss calculation due to class imbalance.

[0186] Step S404: All samples of each category in the training set are randomly shuffled, and the samples of each category in the training set in the original order and the samples in the same position after the shuffled order are used as positive sample pairs, wherein the samples in the original order are positive samples, and the samples in the same position after the shuffled order are paired samples;

[0187] In this embodiment, all samples of the same category are randomly shuffled, and the samples in the same position after shuffling are used as paired samples.

[0188] Next, an improved loss calculation method is used to calculate the contrastive loss. The contrastive loss of positive sample pairs aims to optimize intra-class closeness. By shortening the feature distance of samples of the same category, the model is prompted to learn more representative common features within the class, so that samples of the same category are clustered as much as possible in the feature space. The contrastive loss of negative samples aims to optimize inter-class separation. By increasing the feature spacing of samples of different categories, the model is guided to highlight the differential features between categories, allowing samples of different categories to form a clear interval in the feature space. These two optimization directions complement each other and jointly promote the model to construct a more discriminative feature space. This not only allows the model to classify samples of the same category more accurately and reduce intra-class misjudgments, but also effectively distinguishes samples of different categories and reduces inter-class confusion, thereby further significantly improving the overall classification performance and generalization ability of the model, enabling it to achieve stable and accurate classification even when faced with complex and changing data.

[0189] Step S405: calculating the contrast loss of the positive sample pair according to the fifth hidden layer feature of the positive sample pair, and calculating the contrast loss of the negative sample according to the fifth hidden layer feature of the positive sample and the fifth hidden layer feature of the negative sample;

[0190] Specifically, the contrast loss of the positive sample pair is expressed as follows (14):

[0191] (14)

[0192] in is the contrast loss of the positive sample pair, is the number of all categories, is the number of samples in category c, i is the i-th sample in category c, is the fifth hidden layer feature of the positive sample, is the fifth hidden layer feature of the paired sample, is the Lp norm. It should be noted that, When , it degenerates into the Euclidean square distance, enhancing the spherical distribution within the class. It is more robust to noise, but the optimization difficulty increases. The value of can be determined by the specific data set, and different values ​​have different effects.

[0193] The contrast loss of negative samples is expressed as follows (15):

[0194] (15)

[0195] in, is the contrast loss of negative samples, is the number of all categories, is the number of samples in category c, i is the i-th sample in category c, is the fifth hidden layer feature of the positive sample, is the fifth hidden layer feature of the negative sample, is the Lp norm, is a hyperparameter, The distribution sharpness can be controlled. Increase the weight of difficult samples.

[0196] Step S406: Calculating a total contrast loss based on the contrast loss of the positive sample pair and the contrast loss of the negative sample pair;

[0197] In some embodiments, the total contrast loss is expressed as follows (16):

[0198] (16)

[0199] in, is the total contrast loss, is the contrast loss of the positive sample pair, is the contrast loss of negative samples, is the weight. Adjust the suppression strength of negative samples to avoid manually setting weights, in inverse form Force the model to actively reduce the similarity of negative samples.

[0200] Step S407: back-propagating the total contrast loss in the target model to obtain a second target gradient;

[0201] The execution process of the above steps can be expressed by the following expression (17):

[0202] (17)

[0203] in, is the second target gradient, Represents the positive sample loss Find the partial derivatives, Representation parameters Find the partial derivatives, is the weight, Represents the loss of negative samples Find the partial derivative.

[0204] In this embodiment, the gradient direction of the positive sample is to reduce the distance between samples of the same type, and the gradient direction of the negative sample is to expand the feature distance between samples of different types.

[0205] Step S408: using a preset optimizer to update the model parameters of the target model according to the second target gradient, wherein the preset optimizer uses a gradient descent method to update the model parameters of the target model according to the second target gradient.

[0206] In some embodiments, the preset optimizer may adopt a gradient descent method to update the model parameters of the target model. This process can be expressed by the following expression (18):

[0207] (18)

[0208] are the updated model parameters, is the model parameter obtained after the last update of the target model, is the gradient, is the learning rate, is the second target gradient.

[0209] By executing the above steps, weights are dynamically assigned to the contrast loss function through an adaptive contrast weight assignment mechanism, so that graph structure feature representations of the same type are clustered together and graph structure feature representations of different types are mutually exclusive, thereby further improving the performance of the target model in extracting aggregation of similar elements of the graph structure.

[0210] It can be understood that after executing the above step S408, the above step S106 is executed to obtain a target graph structure in which similar elements are aggregated and boundaries are separated.

[0211] The above overall combination Figure 5 The method for shaping the graph structure features of some embodiments of the present application is specifically explained, so that the target model of this embodiment further improves the quality of the extracted graph structure feature representation.

[0212] Reference Figure 6 , Figure 6 This is a schematic diagram of the terminal structure of the hardware operating environment involved in the embodiment of the present application.

[0213] The terminal in the embodiment of the present application may be a terminal device.

[0214] like Figure 6As shown, the terminal may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. The communication bus 1002 is used to implement communication between these components. The user interface 1003 may include a display, an input unit such as a keyboard, a mouse, etc. Optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory, such as a disk storage device. The memory 1005 may also be a storage device independent of the processor 1001.

[0215] Those skilled in the art will understand that Figure 6 The terminal structure shown in the figure does not constitute a limitation to the terminal, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0216] like Figure 6 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a program for shaping the graph structure characteristics of the terminal device.

[0217] exist Figure 6 In the terminal shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the processor 1001 can be used to call the graph structure feature shaping program of the terminal device stored in the memory 1005, and execute the graph structure feature shaping method described in any of the previous embodiments.

[0218] In addition, to achieve the above-mentioned purpose, the present application also provides a terminal device, which includes: a memory, a processor, and a program for shaping the graph structure features of the terminal device stored on the memory and capable of running on the processor. When the program for shaping the graph structure features of the terminal device is executed by the processor, the steps of the method for shaping the graph structure features as described above are implemented.

[0219] In addition, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which a program for shaping the graph structure features of a terminal device is stored. When the program for shaping the graph structure features of the terminal device is executed by a processor, the steps of the method for shaping the graph structure features as described above are implemented.

[0220] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.

[0221] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0222] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course, by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device (which can be a VR device, a computer, a tablet computer, a mobile phone) to execute the methods described in each embodiment of the present application.

[0223] The above are only preferred embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for shaping graph structural features, characterized in that: The method for shaping the graph structure features includes: Determining contradictory samples in the graph structure, and dividing the contradictory samples into a plurality of contradictory sample sets; Forward propagating the graph structure in a pre-trained target model to obtain a first hidden layer feature corresponding to each sample in each of the contradictory sample sets, wherein initial model parameters of the target model when processing each of the contradictory sample sets are set to model parameters obtained after the last pre-training of the target model, and the first hidden layer feature is a node feature of the contradictory sample in the graph structure output by the residual connection multi-head attention layer in the target model; updating the model parameters of the target model based on the first hidden layer features corresponding to each sample in each of the contradictory sample sets; Forward propagating the graph structure in the target model to obtain a second hidden layer feature corresponding to each sample in each of the contradictory sample sets, wherein initial model parameters of the target model when processing each of the contradictory sample sets are set to model parameters obtained after the target model was last updated, and the second hidden layer feature is a node feature of the contradictory sample in the graph structure output by the residual connection multi-head attention layer in the target model; updating the model parameters of the target model based on the first hidden layer features and the second hidden layer features corresponding to each sample in each of the contradictory sample sets; Forward propagating the graph structure in the target model to obtain a target graph structure after similar elements are aggregated, wherein the target graph structure is the output of the residual connection multi-head attention layer in the target model; The target model includes at least two parallel feature extraction layers, a first splicing layer and a residual connection multi-head attention layer connected in sequence, and the output of the feature extraction layer is connected to the input of the first splicing layer; the feature extraction layer includes a first convolutional layer, a first activation function layer, and a first dropout layer connected in sequence; The updating of the model parameters of the target model based on the first hidden layer features corresponding to each sample in each of the contradictory sample sets includes: Calculating the feature mean of the category to which the first hidden layer feature corresponding to each sample in each of the contradictory sample sets belongs; calculating the square of the Euclidean distance between the first hidden layer feature corresponding to each sample in each of the contradictory sample sets and the feature mean of the category to which it belongs; Calculating the sum of the squares of the Euclidean distances corresponding to each sample in each of the contradictory sample sets, wherein the sum is the boundary loss value of the contradictory sample set; Back-propagating the boundary loss value of each of the contradictory sample sets in the target model to obtain a first gradient corresponding to each of the contradictory sample sets; Using a preset optimizer, updating the model parameters of the target model according to the first gradient corresponding to each of the contradictory sample sets; The updating of the model parameters of the target model based on the first hidden layer features and the second hidden layer features corresponding to each sample in each of the contradictory sample sets includes: Calculating the feature average distance of each contradictory sample set according to the first hidden layer feature and the second hidden layer feature corresponding to each sample in each contradictory sample set; Determining the weight of the first gradient corresponding to each of the contradictory sample sets according to the feature average distance of each of the contradictory sample sets; aggregating the first gradients of all the contradictory sample sets according to the weights of the first gradients of the contradictory sample sets to obtain a first target gradient; The preset optimizer is used to update the model parameters of the target model according to the first target gradient.

2. The method according to claim 1, characterized in that Determining contradictory samples in the graph structure includes: Performing a forward propagation of the graph structure in the pre-trained target model to obtain a third hidden layer feature corresponding to each sample in the graph structure, wherein the third hidden layer feature is a node feature of the sample in the graph structure output by the residual connection multi-head attention layer in the target model; Select a training set; Using a pre-classifier to perform training based on the third hidden layer features of each sample in the training set, to determine a category corresponding to each sample in the training set and a decision boundary corresponding to each category; Calculate the absolute distance between each sample in each category and the decision boundary of the category to which it belongs; The samples in the training set whose absolute distance is less than or equal to a preset threshold are selected as the contradictory samples.

3. The method according to claim 1, characterized in that The target model further includes a second convolutional layer, a second activation function layer, a second dropout layer, and a second classification layer connected to the residual connection multi-head attention layer in sequence; and before determining the contradictory samples in the graph structure, the method further includes: Performing semi-supervised learning pre-training on the target model using the graph structure to obtain a category probability corresponding to each sample in the graph structure, wherein the category probability is an output of the second classification layer; Calculating the supervised learning loss and unsupervised learning loss of the target model using the class probabilities corresponding to each sample; The model parameters of the target model are updated according to the semi-supervised learning loss and the unsupervised learning loss to obtain the pre-trained target model.

4. The method according to claim 3, characterized in that The feature extraction layer further includes a first classification layer connected to the output of the first discard layer; and the method further includes: performing semi-supervised learning pre-training on the target model using the graph structure to obtain the category probability corresponding to each sample in the graph structure. Using the graph structure, the feature extraction layer in the target model is pre-trained with a preset number of semi-supervised learning rounds to obtain a category probability corresponding to each sample in the graph structure, wherein the category probability is the output of the first classification layer; Calculating the supervised learning loss and unsupervised learning loss of the target model using the class probabilities corresponding to each sample; The model parameters of the feature extraction layer in the target model are updated according to the semi-supervised learning loss and the unsupervised learning loss to obtain the pre-trained target model; wherein the proportion weight of unlabeled data in each round of training data gradually increases.

5. The method according to claim 1, characterized in that After updating the model parameters of the target model based on the first hidden layer features and the second hidden layer features corresponding to each sample in each of the contradictory sample sets, the method further includes: Forward propagating the graph structure through the target model to obtain a fifth hidden layer feature corresponding to each sample in the graph structure, wherein the fifth hidden layer feature is a node feature of the sample in the graph structure output by the residual connection multi-head attention layer in the target model; Select a training set; For each category of samples in the training set, a sample is randomly selected from samples of other categories as a negative sample; All samples of each category in the training set are randomly shuffled, and the samples of each category in the training set in the original order and the samples in the same position after the shuffled order are used as positive sample pairs, wherein the samples in the original order are positive samples, and the samples in the same position after the shuffled order are paired samples; Calculating the contrast loss of the positive sample pair according to the fifth hidden layer feature of the positive sample pair, and calculating the contrast loss of the negative sample according to the fifth hidden layer feature of the positive sample and the fifth hidden layer feature of the negative sample; Calculating a total contrast loss based on the contrast loss of the positive sample pair and the contrast loss of the negative sample pair; Back-propagating the total contrast loss in the target model to obtain a second target gradient; Use a preset optimizer to update the model parameters of the target model according to the second target gradient, wherein the preset optimizer uses a gradient descent method to update the model parameters of the target model according to the second target gradient.

6. The method according to claim 5, characterized in that The contrast loss of the positive sample pair is: ; Among them, the is the contrast loss of the positive sample pair, is the number of categories, m c is the total number of samples in category c, is the fifth hidden layer feature of the i-th positive sample in category c, is the fifth hidden layer feature of the i-th paired sample in category c, and p is the Lp norm; The contrast loss of the negative sample is: ; in, is the contrast loss of negative samples, is the number of categories, m c For category The total number of samples in For category The fifth hidden layer feature of the i-th positive sample in, For category The fifth hidden layer feature of the j-th negative sample in, is a constant, p is the Lp norm; The total contrast loss is: ; in, is the total contrast loss, is the contrast loss of the positive sample pair, is the contrast loss of negative samples, is the weight.

7. A terminal device, characterized in that: The terminal device includes: a memory, a processor, and a program for shaping the graph structure features of the terminal device stored in the memory and runnable on the processor. When the program for shaping the graph structure features of the terminal device is executed by the processor, the steps of the method for shaping the graph structure features as described in any one of claims 1 to 6 are implemented.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a program for shaping the graph structure features of a terminal device, and when the program for shaping the graph structure features of the terminal device is executed by a processor, the steps of the method for shaping the graph structure features according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Data recovery method and system, computer equipment and storage medium

    CN114372526A

  • Feature extraction model training method, data classification method, device and equipment

    CN118708943A