Comparative learning method and device for unsupervised graph neural network
By using noise-enhanced adjacency matrix and clustering technology to generate sample pairs in the graph neural network model, the problem of low accuracy of graph data annotation is solved, and the comparison learning accuracy and prediction accuracy of the model are improved.
Patent Information
- Application Number
- CN202510038319.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-10
- Publication Date
- 2025-02-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prediction accuracy of existing graph neural network models is still not high in practical applications, mainly because the label accuracy of graph data is low.
By adding noise vectors to the adjacency matrix of sample graph data, multiple sample adjacency matrices are generated and used to input graph neural network models for training. The embedded representations of the model output are clustered based on clustering hyperparameters, positive and negative sample pairs are generated, comparison loss values are calculated and model parameters are adjusted.
The comparison learning accuracy of graph neural network models is improved, the impact of false positive and negative samples is reduced, and the final prediction accuracy is improved.
Smart Images

Figure CN119476399A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of deep learning technology, and in particular to a comparative learning method and device for unsupervised graph neural networks. Background Art
[0002] Graph data analysis is to let computers simulate the human brain to process, analyze and understand graph data, and to mine the semantic information hidden behind the graph data to further study the characteristics of the target node, target connection or the entire graph. With the continuous advancement of deep learning technology, graph mining and analysis technology based on graph neural network models has also been widely used in personalized recommendations, financial risk control, attack tracing, drug development and other fields. However, the accuracy of most graph data annotations is relatively low, which imposes certain limitations on the performance of graph neural network models.
[0003] In the related technology, the graph contrast learning (GCL) method can be used to learn common features from unlabeled graph data with the training goal of bringing the representation of positive sample pairs closer and pulling the representation of negative sample pairs apart. The model can be optimized through the contrast loss between the generated positive and negative sample pairs to solve the problem of low annotation accuracy of graph data and improve the performance of graph neural network models.
[0004] However, the graph neural network model trained by the above method still has errors in actual use, and the prediction accuracy of the graph neural network model is still not high. Summary of the invention
[0005] In view of the above problems, the embodiments of the present application provide a comparative learning method, device, electronic device and readable storage medium for unsupervised graph neural networks, so as to overcome the above problems or at least partially solve the above problems.
[0006] In a first aspect, an embodiment of the present application provides a contrastive learning method for an unsupervised graph neural network, the method comprising: Adding a noise vector to a first sample adjacency matrix corresponding to the sample graph data to obtain a second sample adjacency matrix and a third sample adjacency matrix; wherein the noise vectors included in the second sample adjacency matrix and the third sample adjacency matrix are different; and the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data; Inputting the first sample embedding representation and the second sample adjacency matrix corresponding to the sample graph data into the first graph neural network model to obtain the first sample final embedding representation output by the first graph neural network model, and inputting the first sample embedding representation and the third sample adjacency matrix into the first graph neural network model to obtain the second sample final embedding representation output by the first graph neural network model; wherein the first sample embedding representation is generated based on the first node data of each sample node in the sample graph data; Based on the clustering hyperparameter, clustering the final embedding representation of the first sample and the embedding representation of the second sample to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters; wherein the number of the clusters is determined based on the clustering hyperparameter; Generate a first positive sample pair based on the cluster label, the cluster probability, the first sample final embedding representation, and the second sample final embedding representation, and generate a first negative sample pair based on the cluster label, the cluster probability, the first sample final embedding representation, and the second sample final embedding representation; Determining a contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair; Based on the contrast loss value, the model parameters of the first graph neural network model are adjusted to obtain a target graph neural network model; the target graph neural network model is used to output a target final embedding representation of the target user based on the target social record graph data corresponding to the target user.
[0007] Optionally, clustering the first sample final embedding representation and the second sample final embedding representation based on the clustering hyperparameter to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters, includes: Based on the clustering hyperparameter, clustering the final embedding representation of the first sample and the final embedding representation of the second sample to obtain a plurality of cluster clusters; Determine the clustering probabilities corresponding to each of the clusters based on the preset clustering weight vectors corresponding to each of the clusters, the final embedding representation of the first sample, and the final embedding representation of the second sample; Based on the preset clustering weight vectors of the clustering clusters and the first sample final embedding representation or the second sample final embedding representation corresponding to the maximum value of the clustering probability, a clustering label of each clustering cluster is generated.
[0008] Optionally, generating a first positive sample pair based on the cluster label, the cluster probability, the first sample final embedding representation, and the second sample final embedding representation includes: When the second sample adjacency matrix corresponding to the first sample final embedding representation and the first sample adjacency matrix corresponding to the third sample adjacency matrix corresponding to the second sample final embedding representation are the same, combining the first sample final embedding representation and the second sample final embedding representation to obtain a first sample final embedding representation pair; In a case where the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair are the same, determining the first sample final embedding representation pair as a first positive sample pair; In a case where the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair are different, determining a first cluster distribution consistency score of the first sample final embedding representation pair based on the cluster probabilities respectively corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair; When the first cluster distribution consistency score is greater than or equal to a first threshold, the first sample final embedding representation pair is determined as a first positive sample pair.
[0009] Optionally, generating a first negative sample pair based on the cluster label, the cluster probability, the final embedding representation of the first sample, and the final embedding representation of the second sample includes: Combining the first sample final embedding representation and the second sample final embedding representation to obtain a second sample final embedding representation pair; In a case where the cluster labels respectively corresponding to the first sample final embedding representation and the first sample final embedding representation included in the second sample final embedding representation pair are different, determining a second cluster distribution consistency score of the second sample final embedding representation pair based on the cluster probabilities respectively corresponding to the first sample final embedding representation and the second sample final embedding representation included in the second sample final embedding representation pair; When the second cluster distribution consistency score is less than or equal to a second threshold, the second sample final embedding representation pair is determined as a first negative sample pair; wherein the second threshold is less than the first threshold.
[0010] Optionally, determining the contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair includes: Determine, from the first negative sample pairs, second negative sample pairs corresponding to each of the first positive sample pairs; wherein the second negative sample pairs corresponding to the first positive sample pairs contain the same first sample final embedding representation or second sample final embedding representation as the first positive sample pairs; Determining a weight value of the second negative sample pair based on the cosine similarity of the second negative sample pair; Determining a weight normalization coefficient of the second negative sample pair based on the weight value and a preset number of training cycles; Based on the first positive sample pair, the weight value, the weight normalization coefficient and the second negative sample pair, determine the contrast loss value of the first graph neural network model.
[0011] Optionally, adjusting the model parameters of the first graph neural network model based on the contrast loss value to obtain a target graph neural network model includes: Based on the clustering probability, determining an overall clustering loss value of the first graph neural network model; Based on the overall clustering loss value and the contrast loss value, the model parameters of the first graph neural network model and the clustering hyperparameters are adjusted to obtain a target graph neural network model.
[0012] Optionally, determining an overall clustering loss value of the first graph neural network model based on the clustering probability includes: Using the Sinkhorn-Knopp algorithm to generate a first clustering probability matrix corresponding to the clustering probability; Determine a first clustering loss value of the first graph neural network model based on a second clustering probability matrix formed by the clustering probabilities and the first clustering probability matrix; Determining a second clustering loss value of the first graph neural network model based on a first information entropy of the clustering probability; The first clustering loss value and the second clustering loss value are summed to obtain an overall clustering loss value of the first graph neural network model.
[0013] Optionally, generating a first positive sample pair based on the cluster label, the cluster probability, the first sample final embedding representation, and the second sample final embedding representation includes: Based on the current number of training cycles of the first graph neural network model, the total number of released final embedded representations of the first sample and the total number of released final embedded representations of the second sample are calculated in combination with a first preset increasing function; According to the order of the first information entropies corresponding to the clustering probabilities from large to small, based on the total released number, a third sample final embedded representation of the first released number is determined from the first sample final embedded representation, and a fourth sample final embedded representation of the second released number is determined from the second sample final embedded representation; wherein the first released number of the first sample final embedded representation and the second released number of the second sample final embedded representation are the same, and the total released number is equal to the sum of the first released number and the second released number; A first positive sample pair is generated based on the cluster label, the cluster probability, the third sample final embedding representation, and the fourth sample final embedding representation.
[0014] Optionally, adjusting the model parameters and clustering hyperparameters of the first graph neural network model based on the overall clustering loss value and the contrast loss value to obtain a target graph neural network model includes: Determining a balance coefficient corresponding to the overall clustering loss value; Determining a model loss value of the first graph neural network model based on the balance coefficient, the overall clustering loss value, and the contrast loss value; Based on the model loss value, the model parameters of the first graph neural network model and the clustering hyperparameters are adjusted to obtain a target graph neural network model.
[0015] In a second aspect, an embodiment of the present application provides a contrastive learning device for an unsupervised graph neural network, the device comprising: An adding module, used for adding a noise vector to a first sample adjacency matrix corresponding to the sample graph data, to obtain a second sample adjacency matrix and a third sample adjacency matrix; wherein the noise vectors included in the second sample adjacency matrix and the third sample adjacency matrix are different; and the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data; An input-output module, used for inputting the first sample embedding representation and the second sample adjacency matrix corresponding to the sample graph data into the first graph neural network model to obtain the first sample final embedding representation output by the first graph neural network model, and inputting the first sample embedding representation and the third sample adjacency matrix into the first graph neural network model to obtain the second sample final embedding representation output by the first graph neural network model; wherein the first sample embedding representation is generated based on the first node data of each sample node in the sample graph data; A clustering module, configured to cluster the final embedding representation of the first sample and the embedding representation of the second sample based on a clustering hyperparameter, to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters; wherein the number of the clusters is determined based on the clustering hyperparameter; A generating module, configured to generate a first positive sample pair based on the clustering label, the clustering probability, the first sample final embedding representation, and the second sample final embedding representation, and to generate a first negative sample pair based on the clustering label, the clustering probability, the first sample final embedding representation, and the second sample final embedding representation; A determination module, configured to determine a contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair; A parameter adjustment module is used to adjust the model parameters of the first graph neural network model based on the contrast loss value to obtain a target graph neural network model; the target graph neural network model is used to output the target final embedding representation of the target user based on the target social record graph data corresponding to the target user.
[0016] Optionally, the clustering module includes: A clustering submodule, configured to cluster the final embedding representation of the first sample and the final embedding representation of the second sample based on a clustering hyperparameter to obtain a plurality of cluster clusters; A first determination submodule, configured to determine the clustering probabilities corresponding to each of the clustering clusters based on the preset clustering weight vectors corresponding to each of the clustering clusters, the first sample final embedding representation, and the second sample final embedding representation; The first generating submodule is used to generate cluster labels for each of the cluster clusters based on the preset cluster weight vectors of each of the cluster clusters and the first sample final embedding representation or the second sample final embedding representation corresponding to the maximum value of the cluster probability.
[0017] Optionally, the generating module includes: A first combining submodule is configured to combine the first sample final embedding representation and the second sample final embedding representation to obtain a first sample final embedding representation pair when the second sample adjacency matrix corresponding to the first sample final embedding representation and the first sample adjacency matrix corresponding to the third sample adjacency matrix corresponding to the second sample final embedding representation are the same; A second determination submodule is configured to determine the first sample final embedding representation pair as a first positive sample pair when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair are the same; A third determination submodule is configured to determine a first cluster distribution consistency score of the first sample final embedding representation pair based on the cluster probabilities respectively corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair, when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair are different; The fourth determination submodule is configured to determine the first sample final embedding representation pair as a first positive sample pair when the first cluster distribution consistency score is greater than or equal to a first threshold.
[0018] Optionally, the generating module includes: A second combining submodule, configured to combine the first sample final embedding representation and the second sample final embedding representation to obtain a second sample final embedding representation pair; a fifth determination submodule, configured to determine a second cluster distribution consistency score of the second sample final embedding representation pair based on the cluster probabilities corresponding to the first sample final embedding representation and the second sample final embedding representation respectively included in the second sample final embedding representation pair, when the cluster labels corresponding to the first sample final embedding representation and the first sample final embedding representation respectively included in the second sample final embedding representation pair are different; The sixth determination submodule is used to determine the second sample final embedding representation pair as a first negative sample pair when the second cluster distribution consistency score is less than or equal to a second threshold; wherein the second threshold is less than the first threshold.
[0019] Optionally, the determining module includes: a seventh determination submodule, configured to determine, from the first negative sample pairs, second negative sample pairs corresponding to each of the first positive sample pairs; wherein the second negative sample pairs corresponding to the first positive sample pairs contain the same first sample final embedding representation or second sample final embedding representation as the first positive sample pairs; an eighth determination submodule, configured to determine a weight value of the second negative sample pair based on the cosine similarity of the second negative sample pair; a ninth determination submodule, configured to determine a weight normalization coefficient of the second negative sample pair based on the weight value and a preset number of training cycles; The tenth determination submodule is used to determine the contrast loss value of the first graph neural network model based on the first positive sample pair, the weight value, the weight normalization coefficient and the second negative sample pair.
[0020] Optionally, the parameter adjustment module includes: An eleventh determination submodule, used to determine an overall clustering loss value of the first graph neural network model based on the clustering probability; An adjustment submodule is used to adjust the model parameters of the first graph neural network model and the clustering hyperparameters based on the overall clustering loss value and the contrast loss value to obtain a target graph neural network model.
[0021] Optionally, the eleventh determining submodule includes: A generating unit, configured to generate a first clustering probability matrix corresponding to the clustering probability by using a Sinkhorn-Knopp algorithm; A first determining unit, configured to determine a first clustering loss value of the first graph neural network model based on a second clustering probability matrix formed by the clustering probabilities and the first clustering probability matrix; A second determining unit, configured to determine a second clustering loss value of the first graph neural network model based on the first information entropy of the clustering probability; A summing unit is used to sum the first clustering loss value and the second clustering loss value to obtain an overall clustering loss value of the first graph neural network model.
[0022] Optionally, the generating module includes: A calculation submodule, used to calculate the total number of releases of the final embedded representation of the first sample and the final embedded representation of the second sample based on the current number of training cycles of the first graph neural network model and in combination with a first preset increasing function; A twelfth determination submodule is configured to determine, in descending order of the first information entropies corresponding to the clustering probabilities, a third sample final embedding representation of the first release number from the first sample final embedding representation, and determine a fourth sample final embedding representation of the second release number from the second sample final embedding representation, based on the total release number; wherein the first release number of the first sample final embedding representation is the same as the second release number of the second sample final embedding representation, and the total release number is equal to the sum of the first release number and the second release number; The second generating submodule is used to generate a first positive sample pair based on the cluster label, the cluster probability, the third sample final embedding representation and the fourth sample final embedding representation.
[0023] Optionally, the adjustment submodule includes: A third determining unit, used to determine a balance coefficient corresponding to the overall clustering loss value; a fourth determining unit, configured to determine a model loss value of the first graph neural network model based on the balance coefficient, the overall clustering loss value, and the contrast loss value; An adjustment unit is used to adjust the model parameters of the first graph neural network model and the clustering hyperparameters based on the model loss value to obtain a target graph neural network model.
[0024] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to implement a comparative learning method for an unsupervised graph neural network as described in any one of the above.
[0025] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the comparative learning method for an unsupervised graph neural network as described in any one of the above items is implemented.
[0026] The specific beneficial effects are: In the embodiment of the present application, a noise vector is added to a first sample adjacency matrix corresponding to the sample graph data to obtain a second sample adjacency matrix and a third sample adjacency matrix; wherein the noise vectors contained in the second sample adjacency matrix and the third sample adjacency matrix are different; the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data, the first sample embedding representation corresponding to the sample graph data and the second sample adjacency matrix are input into the first graph neural network model to obtain the first sample final embedding representation output by the first graph neural network model, the first sample embedding representation and the third sample adjacency matrix are input into the first graph neural network model to obtain the second sample final embedding representation output by the first graph neural network model; wherein the first sample embedding representation is generated based on the first node data of each sample node in the sample graph data, and the first sample final embedding representation and the second sample embedding representation are clustered based on the clustering hyperparameters to obtain a plurality of cluster clusters and cluster labels and cluster probabilities corresponding to each cluster cluster; wherein the number of cluster clusters is determined based on the clustering hyperparameters, and a first positive sample pair is generated based on the cluster labels, cluster probabilities, the first sample final embedding representation and the second sample final embedding representation, and Based on the clustering label, the clustering probability, the final embedding representation of the first sample and the final embedding representation of the second sample, a first negative sample pair is generated; based on the first positive sample pair and the first negative sample pair, a contrast loss value of the first graph neural network model is determined; based on the contrast loss value, the model parameters of the first graph neural network model are adjusted to obtain a target graph neural network model; the target graph neural network model is used to output the target final embedding representation of the target user based on the target social record graph data corresponding to the target user; the final embedding representation of the sample output by the first graph neural network model to be trained can be clustered to obtain clustering labels, and positive and negative sample pairs are generated according to the clustering probability and the clustering label, so as to construct a contrast loss value according to the positive and negative sample pairs; finally, the model parameters of the first graph neural network model are adjusted according to the contrast loss value to obtain the target graph neural network model, which can reduce the occurrence of false positive and negative sample pairs in the first positive sample pair and the first negative sample pair to a certain extent, thereby weakening the influence of false positive and negative sample pairs in the training process of the first graph neural network model to a certain extent, improving the contrast learning accuracy of the first graph neural network model, and improving the prediction accuracy of the target graph neural network obtained to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0028] Figure 1 It is a flowchart of a comparative learning method for unsupervised graph neural network provided in an embodiment of the present application; Figure 2 It is a flowchart of another comparative learning method for unsupervised graph neural network provided in an embodiment of the present application; Figure 3 It is a flowchart of a specific implementation method of a contrastive learning method for an unsupervised graph neural network provided in an embodiment of the present application; Figure 4 It is a logic block diagram of a contrastive learning device for unsupervised graph neural network provided in an embodiment of the present application; Figure 5 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The exemplary embodiments of the present application will be described in more detail below in conjunction with the accompanying drawings in the embodiments of the present application. Although the 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 set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to enable the scope of the present application to be fully communicated to those skilled in the art.
[0030] Reference Figure 1 , Figure 1 A flow chart of a comparative learning method for an unsupervised graph neural network provided in an embodiment of the present application, the method comprising: Step 101, adding a noise vector to a first sample adjacency matrix corresponding to the sample graph data to obtain a second sample adjacency matrix and a third sample adjacency matrix; wherein the noise vectors contained in the second sample adjacency matrix and the third sample adjacency matrix are different; and the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data.
[0031] In an embodiment of the present application, the sample graph data may include multiple sample nodes and the connection relationship between each sample node. In the sample graph data, two types of sample nodes may be included. A first sample adjacency matrix of the sample graph data may be generated according to the connection relationship between each sample node. In the first sample adjacency matrix of the sample graph data, a row may be used to represent a sample node, and a column may be used to represent another sample node. The element value in the sample adjacency matrix may be 0 or 1. The element value 0 indicates that there is no connection relationship between the sample nodes corresponding to the row and column of the element, and the element value 1 indicates that there is a connection relationship between the sample nodes corresponding to the row and column of the element. On this basis, a graph data enhancement method may be used to add a noise vector to the first sample adjacency matrix, so that a second sample embedding representation and a third sample embedding representation may be obtained. In the second sample embedding representation and the third sample embedding representation, the noise vectors included may be different. The noise vector may change the element value of the adjacency matrix, for example, 1 may be changed to 0, or 0 may be changed to 1.
[0032] Step 102: input the first sample embedding representation and the second sample adjacency matrix corresponding to the sample graph data into the first graph neural network model to obtain the first sample final embedding representation output by the first graph neural network model; input the first sample embedding representation and the third sample adjacency matrix into the first graph neural network model to obtain the second sample final embedding representation output by the first graph neural network model.
[0033] In an embodiment of the present application, the first graph neural network model can be a common graph neural network model based on graph contrastive learning, such as LightGCN, SGL, NCL, SimGCL, etc., or it can be an improved graph neural network model using the above network model as a basic model. On this basis, the first sample embedding representation and the second sample adjacency matrix of the sample graph data can be input into the first graph neural network model, so that the first sample final embedding representation output by the first graph neural network model can be obtained, and at the same time, the first sample embedding representation and the third sample adjacency matrix of the sample graph data can be input into the first graph neural network model, so that the second sample final embedding representation output by the first graph neural network model can be obtained.
[0034] Step 103: clustering the final embedding representation of the first sample and the embedding representation of the second sample based on the clustering hyperparameter to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters; wherein the number of the clusters is determined based on the clustering hyperparameter.
[0035] In an embodiment of the present application, a clustering hyperparameter can be used to determine the number of clusters obtained after clustering, thereby limiting the clustering process. If the clustering hyperparameter is a positive integer, the clustering hyperparameter can be directly used as the number of clusters; if the clustering hyperparameter is not a positive integer, the clustering hyperparameter can be rounded, and the rounded result is used as the number of clusters. Obviously, the clustering hyperparameter must be greater than 0. On this basis, the final embedding representation of the first sample and the final embedding representation of the second sample are clustered to obtain multiple clusters. At the same time, when clustering, each final embedding representation of the first sample and the final embedding representation of the second sample can have a corresponding clustering probability distribution function, so that the clustering labels and clustering probabilities corresponding to each cluster can be obtained according to the clustering probability distribution function and the category of the cluster. For example, the clustering probability distribution function corresponding to each cluster can be used as the clustering label of each cluster, or the maximum value of the clustering probability in each cluster can be used as the clustering label of each cluster. The clustering probability sets corresponding to each cluster cluster may be composed of the clustering probabilities corresponding to the final embedding representations of the first samples and the final embedding representations of the second samples in the cluster cluster.
[0036] Step 104: Generate a first positive sample pair based on the cluster label, the cluster probability, the final embedding representation of the first sample, and the final embedding representation of the second sample, and generate a first negative sample pair based on the cluster label, the cluster probability, the final embedding representation of the first sample, and the final embedding representation of the second sample.
[0037] In an embodiment of the present application, a positive sample pair refers to a sample pair consisting of samples belonging to the same category, and a negative sample pair refers to a sample pair consisting of samples belonging to different categories. The first positive sample pair and the first negative sample pair can be generated according to the clustering label, the clustering probability set and the final embedding representation of the first sample, respectively. Among them, the data source of the first positive sample pair and the first negative sample pair is the final embedding representation of the first sample, and the clustering label and the clustering probability set can be used as the data access judgment condition of the first positive sample pair. For example, the final embedding representation of the first sample and the final embedding representation of the second sample with the same clustering label can constitute the first positive sample pair, and the final embedding representation of the first sample and the final embedding representation of the second sample with different clustering labels and a clustering probability greater than or equal to a preset threshold can also constitute the first positive sample pair, and the clustering probability set can be used as the data source of the clustering probability; the final embedding representation of the first sample and the final embedding representation of the second sample with different clustering labels and a clustering probability less than or equal to another preset threshold can constitute the first negative sample pair.
[0038] Step 105: Determine a contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair.
[0039] In an embodiment of the present application, the contrast loss value of the first graph neural network model can be calculated based on the first positive sample pair and the first negative sample pair, and the specific calculation method is shown in the following formulas 1 to 3: (Formula 1) (Formula 2) (Formula 3) In the above formulas 1 to 3, represents the contrast loss value of the first graph neural network model, P represents the set of final embedding representations of the first sample, Represents the modulus of P, i.e., the number of final embedded representations of the first sample. Indicates the final embedding representation of the first sample corresponding to sample node i, is the first positive sample pair, and Equivalent. ( )and( ) is the first positive sample pair The corresponding two first negative sample pairs, Represents the first positive sample pair and the first negative sample pair ( ), Represents the first positive sample pair and the first negative sample pair ( ), ln() is the natural logarithm, exp() is the natural exponential, It is a temperature parameter and can be preset manually.
[0040] Step 106: Based on the contrast loss value, adjust the model parameters of the first graph neural network model to obtain a target graph neural network model; the target graph neural network model is used to output the target final embedding representation of the target user based on the target social record graph data corresponding to the target user.
[0041] In an embodiment of the present application, the model parameters of the first graph neural network model can be adjusted according to the contrast loss value between the first positive sample pair and the first negative sample pair, so that the first graph neural network model after adjusting the model parameters is used as the target graph neural network model. Among them, the adjustment direction of the model parameters can be the direction in which the contrast loss value is reduced. Specifically, the adjustment process of the model parameters of the first graph neural network model can be repeated multiple times, that is, after completing the adjustment of the model parameters once, the process of steps 101 to 106 can be repeated to adjust the model parameters for the next time. If the contrast loss value of the first graph neural network model meets the convergence condition, or the number of training cycles of the first graph neural network model meets the preset number of times, the adjustment of the model parameters of the first graph neural network model can be stopped, and the first graph neural network model obtained after the last model parameter adjustment is used as the target graph neural network model. The target social record graph data corresponding to the target user can be used as the input data of the target graph neural network model. After the target social record graph data corresponding to the above target user is input into the target graph neural network model, the target graph neural network model can output the target final embedding representation of the target user.
[0042] In a possible embodiment, the target user can be classified according to the target social record graph data of the target user. Specifically, the target social record graph data of the target user can be used as the input data of the target graph neural network model, so that the target final embedding representation of the target user output by the target graph neural network model can be obtained. Then, the target final embedding representation can be used as the input data of the trained SVM classifier, so that the SVM classifier can output the classification result. For example, the classification result can be "friendly users, ordinary users and malicious users", or "active users, inactive users and dormant users", etc. The training process of the SVM classifier can be to use the trained graph neural network model as the encoder of the social network user embedding representation, select users with known classification information as training samples, input the embedding representation of the training samples into the SVM classifier for classification prediction, calculate the classification loss value according to the classification prediction result and the true value, update and optimize the classifier parameters based on the calculated loss, repeat the above steps until the preset training termination condition is reached (such as the number of iterations reaches the preset number or the classification loss value converges), and the trained SVM classifier can be obtained after the training is completed.
[0043] In an embodiment of the present application, a second sample adjacency matrix and a third sample adjacency matrix are obtained by adding a noise vector to a first sample adjacency matrix corresponding to sample graph data; wherein the noise vectors contained in the second sample adjacency matrix and the third sample adjacency matrix are different; the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data, the first sample embedding representation corresponding to the sample graph data and the second sample adjacency matrix are input into the first graph neural network model, and the first sample final embedding representation output by the first graph neural network model is obtained, and the first sample embedding representation and the third sample adjacency matrix are input into the first graph neural network model, and the second sample final embedding representation output by the first graph neural network model is obtained; wherein the first sample embedding representation is generated based on the first node data of each sample node in the sample graph data, and the first sample final embedding representation and the second sample embedding representation are clustered based on the clustering hyperparameters to obtain multiple cluster clusters and cluster labels and cluster probabilities corresponding to each cluster cluster; wherein the number of cluster clusters is determined based on the clustering hyperparameters, and a first positive sample pair is generated based on the cluster labels, cluster probabilities, the first sample final embedding representation and the second sample final embedding representation. , and based on the clustering label, clustering probability, the final embedding representation of the first sample and the final embedding representation of the second sample, generate a first negative sample pair, determine the contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair, adjust the model parameters of the first graph neural network model based on the contrast loss value, and obtain the target graph neural network model; the target graph neural network model is used to output the target final embedding representation of the target user based on the target social record graph data corresponding to the target user, and can cluster the final embedding representation of the sample output by the first graph neural network model to be trained to obtain clustering labels, and generate positive and negative sample pairs according to the clustering probability and the clustering label, so as to construct a contrast loss value according to the positive and negative sample pairs, and finally adjust the model parameters of the first graph neural network model according to the contrast loss value to obtain the target graph neural network model, which can reduce the occurrence of false positive and negative sample pairs in the first positive sample pair and the first negative sample pair to a certain extent, thereby weakening the influence of false positive and negative sample pairs in the training process of the first graph neural network model to a certain extent, improving the contrast learning accuracy of the first graph neural network model, and improving the prediction accuracy of the target graph neural network obtained to a certain extent.
[0044] Reference Figure 2 , Figure 2 A schematic flow chart of another contrastive learning method for an unsupervised graph neural network provided in an embodiment of the present application, the method may include: Step 201, adding a noise vector to a first sample adjacency matrix corresponding to the sample graph data to obtain a second sample adjacency matrix and a third sample adjacency matrix; wherein the noise vectors contained in the second sample adjacency matrix and the third sample adjacency matrix are different; and the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data.
[0045] In the embodiments of the present application, the implementation content of this step can refer to the embodiment content of step 101, which will not be repeated here.
[0046] Step 202: Input the first sample embedding representation and the second sample adjacency matrix corresponding to the sample graph data into the first graph neural network model to obtain the first sample final embedding representation output by the first graph neural network model; input the first sample embedding representation and the third sample adjacency matrix into the first graph neural network model to obtain the second sample final embedding representation output by the first graph neural network model; wherein the first sample embedding representation is generated based on the first node data of each sample node in the sample graph data.
[0047] In the embodiments of the present application, the implementation content of this step can refer to the implementation content of step 102, which will not be repeated here.
[0048] Step 203: clustering the final embedding representation of the first sample and the embedding representation of the second sample based on the clustering hyperparameter to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters; wherein the number of the clusters is determined based on the clustering hyperparameter.
[0049] In the embodiments of the present application, the implementation content of this step can refer to the implementation content of step 103, which will not be repeated here.
[0050] Optionally, step 203 may include the following sub-steps: Sub-step 2031: clustering the final embedding representation of the first sample and the final embedding representation of the second sample based on clustering hyperparameters to obtain multiple clusters.
[0051] In an embodiment of the present application, the first sample final embedding representation and the second sample final embedding representation output by the first graph neural network can be clustered according to the clustering hyperparameters, so as to obtain multiple clustering clusters. The specific implementation content of the clustering hyperparameters and clustering clusters can refer to the relevant content in the embodiment of step 103, which will not be repeated here.
[0052] Sub-step 2032: determining the clustering probabilities corresponding to each of the clusters based on the preset clustering weight vectors corresponding to each of the clusters, the final embedding representation of the first sample, and the final embedding representation of the second sample.
[0053] In the embodiment of the present application, each cluster may correspond to a preset cluster weight vector, which may define the cluster characteristics of the cluster and may be manually preset according to actual needs. For each cluster, its cluster probability distribution function may be expressed in the form of the following formula 4: (Formula 4) In the above formula 4, Represents the final embedding representation of the first sample The clustering probability, Represents the final embedding representation of the first sample The preset clustering weight vector of the cluster to which it belongs, symbolized by " ” represents the dot product, and softmax() is the normalized exponential function.
[0054] In an embodiment of the present application, the clustering probabilities corresponding to the first sample final embedding representation and the second sample final embedding representation contained in each cluster can be calculated using Formula 3 based on the preset clustering weight vectors corresponding to each clustering cluster and the first sample final embedding representation and the second sample final embedding representation contained in each clustering cluster, so that the probability set composed of the clustering probabilities corresponding to the first sample final embedding representation and the second sample final embedding representation can be used as the clustering probability of the corresponding clustering cluster.
[0055] Sub-step 2033: generating cluster labels for each of the cluster clusters based on the preset cluster weight vectors of each of the cluster clusters and the first sample final embedding representation or the second sample final embedding representation corresponding to the maximum value of the cluster probability.
[0056] In an embodiment of the present application, the maximum value of the clustering probability contained in each cluster cluster can be determined, so that the clustering label of each cluster cluster can be generated according to the final embedding representation of the first sample or the final embedding representation of the second sample corresponding to the maximum value, and the preset clustering weight vector of the cluster cluster where the final embedding representation of the first sample or the final embedding representation of the second sample is located. For example, the final embedding representation of the first sample or the final embedding representation of the second sample corresponding to the maximum value of the clustering probability and the preset clustering weight vector can be directly used as the clustering label, or the final embedding representation of the first sample or the final embedding representation of the second sample corresponding to the maximum value can be data spliced with the preset clustering weight vector, and the result of the data splicing can be used as the clustering label. The cluster label can be expressed in the form of the following formula 5: (Formula 5) In the above formula 5, c is the cluster label, k is the cluster number, The first sample of cluster k is finally embedded into the cluster probability of z, () is a function that finds parameters.
[0057] In an embodiment of the present application, the final embedding representation of the first sample and the final embedding representation of the second sample are clustered based on clustering hyperparameters to obtain multiple cluster clusters. The clustering probabilities corresponding to each cluster cluster are determined based on the preset clustering weight vectors corresponding to each cluster cluster, the final embedding representation of the first sample, and the second sample final embedding representation. Clustering labels for each cluster cluster are generated based on the preset clustering weight vectors of each cluster cluster and the final embedding representation of the first sample or the final embedding representation of the second sample corresponding to the maximum value of the clustering probability. The final embedding representation of the first sample can be clustered to obtain multiple cluster clusters, and the preset clustering weight vectors corresponding to each cluster cluster can be added when calculating the clustering probability to obtain weighted clustering probabilities and cluster labels, which can improve the accuracy and reliability of the clustering probabilities and cluster labels to a certain extent, and improve the prediction accuracy of the target graph neural network model finally obtained.
[0058] Step 204: Generate a first positive sample pair based on the cluster label, the cluster probability, the final embedding representation of the first sample, and the final embedding representation of the second sample, and generate a first negative sample pair based on the cluster label, the cluster probability, the final embedding representation of the first sample, and the final embedding representation of the second sample.
[0059] In the embodiments of the present application, the implementation content of this step can refer to the implementation content of step 104, which will not be repeated here.
[0060] Optionally, step 204 may include the following sub-steps: Sub-step 2041, based on the current number of training cycles of the first graph neural network model, combined with a first preset increasing function, calculates the total number of releases of the final embedded representation of the first sample and the final embedded representation of the second sample.
[0061] In an embodiment of the present application, the current number of training cycles of the first graph neural network model can be obtained, so that the number of training cycles can be used as the independent variable of the first preset increasing function, and the function value of the first preset increasing function can be calculated, so that the function value can be used as the total number of releases of the final embedding representation of the first sample and the final embedding representation of the second sample. Among them, the first preset increasing function can be a rounding function with the current number of training cycles of the first graph neural network as the independent variable, which is greater than zero and monotonically increasing.
[0062] Sub-step 2042, in descending order of the first information entropies corresponding to the clustering probabilities, based on the total released number, determine the third sample final embedded representation of the first released number from the first sample final embedded representation, and determine the fourth sample final embedded representation of the second released number from the second sample final embedded representation; wherein the first released number of the first sample final embedded representation and the second released number of the second sample final embedded representation are the same, and the total released number is equal to the sum of the first released number and the second released number.
[0063] In an embodiment of the present application, for each cluster, the third sample final embedding representation of the first release quantity can be determined from the first sample final embedding representation contained in each cluster in the order of the first information entropy corresponding to the clustering probability from large to small, and the fourth sample final embedding representation of the second release quantity can be determined from the second sample final embedding representation contained in each cluster, wherein the first release quantity of the first sample final embedding representation and the second release quantity of the second sample final embedding representation can be the same, and the total release quantity can be equal to the sum of the first release quantity and the second release quantity. The calculation method of the first information entropy is shown in Formula 6 below: (Formula 6) In the above formula 6, represents the first information entropy of the final embedding representation of the first sample or the final embedding representation of the second sample z, k is the serial number of the cluster, represents the clustering probability of the final embedding representation of the first sample in cluster k or the final embedding representation of the second sample z, Represents the natural logarithm.
[0064] Sub-step 2043: generating a first positive sample pair based on the cluster label, the cluster probability, the final embedding representation of the third sample and the final embedding representation of the fourth sample.
[0065] In an embodiment of the present application, a first positive sample pair may be generated according to the clustering label, the clustering probability, the final embedding representation of the third sample, and the final embedding representation of the fourth sample. The data source of the first positive sample pair may be the final embedding representation of the third sample and the final embedding representation of the fourth sample. For other implementation contents of generating the first positive sample pair, please refer to the embodiment contents of step 104, which will not be repeated here.
[0066] In an embodiment of the present application, by calculating the total number of releases of the first sample final embedding representation and the second sample final embedding representation based on the current number of training cycles of the first graph neural network model and in combination with a first preset increasing function, the third sample final embedding representation of the first release number is determined from the first sample final embedding representation in descending order of the first information entropy corresponding to the clustering probabilities based on the total number of releases, and the fourth sample final embedding representation of the second release number is determined from the second sample final embedding representation; wherein the first release number of the first sample final embedding representation and the second release number of the second sample final embedding representation are the same, and the total release number is equal to the sum of the first release number and the second release number, and a first positive sample pair is generated based on the clustering label, the clustering probability, the third sample final embedding representation and the fourth sample final embedding representation, the number of the first sample final embedding representation used when generating the positive sample pair can be gradually increased, and the noise of the positive sample pair can be gradually increased, which can increase the learning efficiency of the first graph neural network model for the positive sample pair features, and can improve the prediction accuracy and robustness of the target graph neural network model finally obtained.
[0067] Sub-step 2044, when the second sample adjacency matrix corresponding to the first sample final embedding representation and the first sample adjacency matrix corresponding to the third sample adjacency matrix corresponding to the second sample final embedding representation are the same, combine the first sample final embedding representation and the second sample final embedding representation to obtain a first sample final embedding representation pair.
[0068] In an embodiment of the present application, it can be first determined whether the first sample adjacency matrix corresponding to the second sample adjacency matrix corresponding to the final embedding representation of the first sample and the first sample adjacency matrix corresponding to the third sample adjacency matrix corresponding to the final embedding representation of the second sample are the same, wherein the second sample adjacency matrix and the third sample adjacency matrix obtained by adding noise to the first sample adjacency matrix can be considered to correspond to the above-mentioned first sample adjacency matrix. If the second sample adjacency matrix corresponding to the final embedding representation of the first sample and the first sample adjacency matrix corresponding to the third sample adjacency matrix corresponding to the final embedding representation of the second sample are the same, the final embedding representation of the first sample and the final embedding representation of the second sample can be combined to obtain a first sample final embedding representation pair. The number of first sample final embedding representations selected during the combination can be two. When the first sample final embedding representation pair is generated by combination, the first sample final embedding representation pair can be screened to delete duplicate first sample final embedding representation pairs.
[0069] Sub-step 2045: When the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair are the same, the first sample final embedding representation pair is determined as a first positive sample pair.
[0070] In an embodiment of the present application, when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair are the same, it can be considered that the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair are from the same cluster cluster, and at this time, the first sample final embedding representation pair can be determined as a first positive sample pair.
[0071] Sub-step 2046, when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair are different, determine a first cluster distribution consistency score of the first sample final embedding representation pair based on the cluster probabilities respectively corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair.
[0072] In an embodiment of the present application, when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair are different, the first cluster distribution consistency score of the first sample final embedding representation pair can be calculated based on the cluster probabilities corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair. The calculation method of the cluster distribution consistency score is shown in Formula 7 below: (Formula 7) In the above formula 7, represents the clustering probability of the first sample final embedding representation i contained in the first sample final embedding representation pair in the clustering cluster to which it originally belongs, represents the clustering probability of the second sample final embedding representation j contained in the first sample final embedding representation pair in the cluster to which it originally belongs, Represents the clustering probability of the first sample of cluster k, and the final embedding representation i.
[0073] Sub-step 2047 , when the first cluster distribution consistency score is greater than or equal to a first threshold, determining the first sample final embedding representation pair as a first positive sample pair.
[0074] In an embodiment of the present application, if the first cluster distribution consistency score is greater than or equal to a first threshold, the first sample final embedding representation pair corresponding to the first cluster distribution consistency score can be determined as a first positive sample pair. The first threshold can be set manually.
[0075] In an embodiment of the present application, by combining the first sample final embedding representation and the second sample final embedding representation when the second sample adjacency matrix corresponding to the first sample final embedding representation and the first sample adjacency matrix corresponding to the third sample adjacency matrix corresponding to the second sample final embedding representation are the same, a first sample final embedding representation pair is obtained, and when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair are the same, the first sample final embedding representation pair is determined as a first positive sample pair, and the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair are the same. When the corresponding clustering labels are different, the first cluster distribution consistency score of the first sample final embedding representation pair is determined based on the cluster probabilities corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair. When the first cluster distribution consistency score is greater than or equal to the first threshold, the first sample final embedding representation pair is determined as the first positive sample pair. The first sample final embedding representation pair can be screened by the cluster consistency scores corresponding to the clustering labels and the clustering probabilities to obtain the first positive sample pair, which can effectively avoid the occurrence of false positive sample pairs in the first positive sample pair and improve the accuracy and reliability of the first positive sample pair to a certain extent.
[0076] Sub-step 2048: combining the first sample final embedding representation and the second sample final embedding representation to obtain a second sample final embedding representation pair.
[0077] In an embodiment of the present application, the first sample final embedding representation and the second sample final embedding representation may be combined to obtain a second sample final embedding representation pair.
[0078] Sub-step 2049, when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation included in the second sample final embedding representation pair are different, determine the second cluster distribution consistency score of the second sample final embedding representation pair based on the cluster probabilities corresponding to the first sample final embedding representation and the second sample final embedding representation included in the second sample final embedding representation pair.
[0079] In the embodiment of the present application, the calculation method of the second cluster distribution consistency score is the same as the calculation method of the first cluster distribution consistency score, and the embodiment content of step 2046 and formula 7 can be referred to, which will not be repeated here.
[0080] Sub-step 20410: when the second cluster distribution consistency score is less than or equal to a second threshold, determining the second sample final embedding representation pair as a first negative sample pair; wherein the second threshold is less than the first threshold.
[0081] In an embodiment of the present application, when the second cluster distribution consistency score is less than or equal to a second threshold, the second sample final embedding representation pair can be determined as a first negative sample pair. The second threshold can be set manually and can be less than the first threshold.
[0082] In an embodiment of the present application, a second sample final embedding representation pair is obtained by combining the first sample final embedding representation and the second sample final embedding representation. When the cluster labels corresponding to the first sample final embedding representation and the first sample final embedding representation included in the second sample final embedding representation pair are different, a second cluster distribution consistency score of the second sample final embedding representation pair is determined based on the cluster probabilities corresponding to the first sample final embedding representation and the second sample final embedding representation included in the second sample final embedding representation pair. When the second cluster distribution consistency score is less than or equal to a second threshold, the second sample final embedding representation pair is determined as a first negative sample pair; wherein the second threshold is less than the first threshold, the second sample final embedding representation pair can be screened by the cluster consistency scores corresponding to the cluster labels and the cluster probabilities to obtain the first negative sample pair, which can effectively avoid the appearance of false negative sample pairs in the first negative sample pairs, thereby improving the accuracy and reliability of the first negative sample pairs to a certain extent.
[0083] Step 205: Determine a contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair.
[0084] In the embodiments of the present application, the implementation content of this step can refer to the implementation content of step 105, which will not be repeated here.
[0085] Optionally, step 205 may include the following sub-steps: Sub-step 2051, determining from the first negative sample pairs the second negative sample pairs corresponding to each of the first positive sample pairs respectively; wherein the second negative sample pairs corresponding to the first positive sample pairs contain the same first sample final embedding representation or second sample final embedding representation as the first positive sample pairs.
[0086] In an embodiment of the present application, the second negative sample pairs corresponding to each first positive sample pair can be screened from the first negative sample pair. The screening condition can be that the first negative sample pair contains an identical first sample final embedding representation or a identical second sample final embedding representation as the first positive sample pair, that is, the second negative sample pair corresponding to the first positive sample pair can contain an identical first sample final embedding representation or an identical second sample final embedding representation as the first positive sample pair.
[0087] Sub-step 2052: determining a weight value of the second negative sample pair based on the cosine similarity of the second negative sample pair.
[0088] In an embodiment of the present application, the cosine similarity of the second negative sample pair can be calculated by the final embedded representation of the two first samples contained therein, as shown in the following formula 8: (Formula 8) In the above formula 8, Represents the second negative sample pair The cosine similarity of Represents the second negative sample pair The final embedding representation of the two first samples contained in and The modulus of the dot product of Represents the final embedding representation of the first sample The model, Represents the final embedding representation of the first sample After obtaining the cosine similarity of the second negative sample pair, the weight value of the second negative sample pair can be calculated and determined according to the cosine similarity, and the calculation method is shown in the following formula 9: (Formula 9) In the above formula 9, Represents the second negative sample pair The weight value of is the average of the cosine similarities of all possible second negative sample pairs, Represents the upper limit of the cosine similarity of all possible second negative sample pairs.
[0089] Sub-step 2053: determining a weight normalization coefficient of the second negative sample pair based on the weight value and a preset number of training cycles.
[0090] In an embodiment of the present application, the weight normalization coefficient of the second negative sample pair can be calculated according to the weight value of the second negative sample pair and the preset number of training cycles of the first graph neural network model, and the calculation method thereof is shown in the following formula 10: (Formula 10) In the above formula 10, is the second negative sample pair , m is the preset number of training cycles of the first graph neural network model, N represents the set of all possible second negative sample pairs, and z represents the final embedding representation of the first sample in the second negative sample pair that is different from the first negative sample pair.
[0091] Sub-step 2054, determining the contrast loss value of the first graph neural network model based on the first positive sample pair, the weight value, the weight normalization coefficient and the second negative sample pair.
[0092] In an embodiment of the present application, the contrast loss value of the first graph neural network model can be calculated according to the weight value of the first positive sample pair, the second negative sample pair, the weight normalization coefficient and the second negative sample pair, and the calculation method thereof is shown in Formula 11 below: (Formula 11) In the above formula 11, the meaning of each parameter can refer to the meaning of the parameters in formulas 1 to 3, 9 and 10, and will not be repeated here.
[0093] In an embodiment of the present application, the second negative sample pairs corresponding to each first positive sample pair are determined from the first negative sample pair; wherein the second negative sample pair corresponding to the first positive sample pair contains the same final embedding representation of the first sample or the final embedding representation of the second sample as the first positive sample pair; based on the cosine similarity of the second negative sample pair, the weight value of the second negative sample pair is determined; based on the weight value and the preset number of training cycles, the weight normalization coefficient of the second negative sample pair is determined; based on the first positive sample pair, the weight value, the weight normalization coefficient and the second negative sample pair, the contrast loss value of the first graph neural network model is determined; the contrast loss value of the first graph neural network model can be calculated based on the weight value of the second negative sample pair corresponding to the first positive sample pair and the preset number of training cycles, combined with the final embedding representation of the first sample contained in the first positive sample pair and the second negative sample pair, which can reduce the difference in the numerical part corresponding to the negative sample pair in the contrast loss, making it more balanced, and to a certain extent improve the accuracy and numerical stability of the contrast loss value.
[0094] Step 206: Determine the overall clustering loss value of the first graph neural network model based on the clustering probability.
[0095] In an embodiment of the present application, the overall clustering loss value of the first graph neural network model can be calculated based on the clustering probability of the final embedded representation of the first samples contained in each cluster cluster. For example, the first information entropy of the final embedded representation of each first sample can be calculated based on the clustering probability, and the average value of the first information entropy can be used as the clustering loss value of the entire clustering process. The calculation method of the first information entropy can refer to the calculation method of Formula 6, which will not be repeated here.
[0096] Optionally, step 206 may include the following sub-steps: Sub-step 2061: using the Sinkhorn-Knopp algorithm to generate a first clustering probability matrix corresponding to the clustering probability.
[0097] In an embodiment of the present application, the Sinkhorn-Knopp algorithm is a method for calculating the optimal transmission mapping between two probability distributions. It is mainly used to solve the optimal transmission problem, that is, given two probability distributions, find an optimal way to convert one distribution into another distribution so that the "cost" in the conversion process is minimized. In an embodiment of the present application, the process of obtaining the first clustering probability matrix by the Sinkhorn-Knopp algorithm can be shown in the following formula 12: (Formula 12) In the above formula 12, represents the first clustering probability matrix, is the hyperparameter used for estimation in the Sinkhorn-Knopp algorithm, P is the clustering probability, Indicates is a diagonal square matrix with diagonal elements and the rest of the elements are 0, Indicates is a diagonal square matrix with 0 as the diagonal element and the rest of the elements are 0.
[0098] Sub-step 2062: Determine a first clustering loss value of the first graph neural network model based on a second clustering probability matrix formed by the clustering probabilities and the first clustering probability matrix.
[0099] In an embodiment of the present application, the clustering probability can be directly used as a matrix element to obtain a second clustering probability matrix. The rows of the second clustering probability matrix can correspond to the cluster clusters, and the columns can correspond to the individual clustering probabilities. In this way, the first clustering loss value of the first graph neural network model can be calculated by the second clustering probability matrix and the first clustering probability matrix, and the calculation method can be shown in the following formula 13: (Formula 13) In the above formula 13, represents the first clustering loss value of the first graph neural network model, P represents the second clustering probability matrix, Q represents the first clustering probability matrix, and the symbol " ” represents the element-by-element Frobenius dot product between two matrices.
[0100] Sub-step 2063: Determine a second clustering loss value of the first graph neural network model based on the first information entropy of the clustering probability.
[0101] In an embodiment of the present application, the second clustering loss value of the first graph neural network model can be obtained by calculating the first information entropy of the clustering probability, and the calculation method thereof is shown in Formula 14 below: (Formula 14) In the above formula 14, represents the second clustering loss value, The first information entropy represents the clustering probability corresponding to the final embedding representation of the first sample or the final embedding representation of the second sample i, and N represents the number of first sample embedding representations. That is, the average value of the first information entropy of all clustering probabilities can be used as the second clustering loss value of the first graph neural network model.
[0102] Sub-step 2064: summing the first clustering loss value and the second clustering loss value to obtain an overall clustering loss value of the first graph neural network model.
[0103] In an embodiment of the present application, the first clustering loss value and the second clustering loss value may be summed, so that the summed result may be used as the overall clustering loss value of the first graph neural network model, as shown in the following formula 15: (Formula 15) In the above formula 15, Represents the overall clustering loss value, is the first clustering loss value, is the second clustering loss value.
[0104] In an embodiment of the present application, a first clustering probability matrix corresponding to the clustering probability is generated by adopting the Sinkhorn-Knopp algorithm, a first clustering loss value of the first graph neural network model is determined based on the second clustering probability matrix formed by the clustering probability and the first clustering probability matrix, and a second clustering loss value of the first graph neural network model is determined based on the first information entropy of the clustering probability. The first clustering loss value and the second clustering loss value are summed to obtain the overall clustering loss value of the first graph neural network model. The clustering loss can be calculated from two perspectives to obtain the first clustering loss value and the second clustering loss value, and the overall clustering loss value of the first graph neural network model can be obtained by summing the first clustering loss value and the second clustering loss value, which improves the accuracy and numerical stability of the overall clustering loss value to a certain extent, and can improve the prediction accuracy of the target graph neural network model finally obtained.
[0105] Step 207: Based on the overall clustering loss value and the contrast loss value, adjust the model parameters of the first graph neural network model and the clustering hyperparameters to obtain a target graph neural network model.
[0106] In an embodiment of the present application, the model parameters and clustering hyperparameters of the first graph neural network model can be adjusted according to the overall clustering loss value and the contrast loss value, so as to obtain a target graph neural network model. Among them, the direction of adjusting the model parameters and clustering hyperparameters can be the direction of reducing the overall clustering loss value and the contrast loss value. In addition, the model parameters and clustering hyperparameters can be adjusted multiple times. After one adjustment, the process of steps 201 to 207 and their sub-steps can be repeated. When the number of training cycles of the first graph neural network model reaches the preset number of training cycles, or the overall clustering loss value and the contrast loss value meet the preset convergence conditions, the adjustment can be stopped, and the first graph neural network model obtained after the last adjustment of the model parameters and hyperparameters is determined as the target graph neural network model.
[0107] Optionally, step 207 may include the following sub-steps: Sub-step 2071, determining the balance coefficient corresponding to the overall clustering loss value.
[0108] In an embodiment of the present application, a balance coefficient corresponding to the overall clustering loss value may be determined. The balance coefficient may usually be manually preset before the first graph neural network model starts training according to actual needs.
[0109] Sub-step 2072, determining the model loss value of the first graph neural network model based on the balance coefficient, the overall clustering loss value and the contrast loss value.
[0110] In an embodiment of the present application, the model loss value of the first graph neural network model can be calculated according to the balance coefficient, the overall clustering loss value and the contrast loss value, and the calculation method thereof is shown in the following formula 16: (Formula 16) In the above formula 16, Represents the model loss value of the first graph neural network model, represents the contrast loss value, Represents the overall clustering loss value, Represents the balance coefficient.
[0111] Sub-step 2073: Based on the model loss value, adjust the model parameters of the first graph neural network model and the clustering hyperparameters to obtain the target graph neural network model.
[0112] In an embodiment of the present application, the model parameters and clustering hyperparameters of the first graph neural network model can be adjusted according to the model loss value to obtain a target graph neural network model. The direction of adjusting the model parameters and clustering hyperparameters can be the direction of reducing the model loss value. For other implementation contents of this step, please refer to the embodiment contents of step 207, which will not be repeated here.
[0113] In an embodiment of the present application, by determining the balance coefficient corresponding to the overall clustering loss value, the model loss value of the first graph neural network model is determined based on the balance coefficient, the overall clustering loss value and the contrast loss value, and based on the model loss value, the model parameters and clustering hyperparameters of the first graph neural network model are adjusted to obtain the target graph neural network model. The model loss value of the first graph neural network model can be obtained through the balance coefficient, the overall clustering loss value and the contrast loss value, and the model parameters and clustering hyperparameters of the first graph neural network model can be adjusted through the model loss value to obtain the target graph neural network model. The role of the overall clustering loss value and the contrast loss value in the parameter adjustment process can be determined according to actual needs, thereby further improving the prediction accuracy of the target graph neural network model.
[0114] In an embodiment of the present application, the overall clustering loss value of the first graph neural network model is determined based on the clustering probability, and the model parameters and clustering hyperparameters of the first graph neural network model are adjusted based on the overall clustering loss value and the contrast loss value to obtain a target graph neural network model. The model parameters of the first graph neural network model and the clustering hyperparameters in the clustering process can be adjusted according to the overall clustering loss value and the contrast loss value to obtain the target graph neural network model, which improves the prediction accuracy of the target graph neural network model to a certain extent.
[0115] Reference Figure 3 , Figure 3A flowchart of a specific implementation method of a comparative learning method for an unsupervised graph neural network provided in an embodiment of the present application. In the figure, the process can be started first, and then the graph data after data enhancement can be input into the graph neural network model to be trained in the form of an embedding representation and an adjacency matrix to obtain the final embedding representation output by the graph neural network model, and then the released final embedding representation can be clustered to obtain multiple cluster clusters and the clustering probability and clustering labels of each cluster cluster, and then the final embedding representation can be progressively sampled and released according to the current number of training cycles of the graph neural network model, so that the number of released final embedding representations increases with the increase in the number of training cycles. Then, the released final embedding representation can be used as the data source, and the clustering probability and clustering label can be used as screening conditions to generate positive sample pairs and negative sample pairs. Afterwards, the contrast loss value can be calculated based on the positive sample pairs and the negative sample pairs, and the model parameters of the graph neural network model can be adjusted according to the contrast loss value. Then, it can be determined whether the graph neural network model has completed training iterations (that is, the number of training cycles reaches the preset number or the comparison loss value meets the preset convergence conditions). If the training iterations are not completed, the data-enhanced graph data can be input into the graph neural network model to be trained again. If the training iterations have been completed, the process can be ended.
[0116] Reference Figure 4 , Figure 4 A logic block diagram of a contrastive learning device for an unsupervised graph neural network provided in an embodiment of the present application, the contrastive learning device 400 for an unsupervised graph neural network may include: An adding module 401 is used to add a noise vector to a first sample adjacency matrix corresponding to the sample graph data to obtain a second sample adjacency matrix and a third sample adjacency matrix; wherein the noise vectors included in the second sample adjacency matrix and the third sample adjacency matrix are different; and the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data; An input-output module 402 is used to input the first sample embedding representation and the second sample adjacency matrix corresponding to the sample graph data into the first graph neural network model to obtain the first sample final embedding representation output by the first graph neural network model, and input the first sample embedding representation and the third sample adjacency matrix into the first graph neural network model to obtain the second sample final embedding representation output by the first graph neural network model; wherein the first sample embedding representation is generated based on the first node data of each sample node in the sample graph data; A clustering module 403 is used to cluster the final embedding representation of the first sample and the embedding representation of the second sample based on a clustering hyperparameter to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters; wherein the number of the clusters is determined based on the clustering hyperparameter; A generating module 404, configured to generate a first positive sample pair based on the clustering label, the clustering probability, the first sample final embedding representation, and the second sample final embedding representation, and to generate a first negative sample pair based on the clustering label, the clustering probability, the first sample final embedding representation, and the second sample final embedding representation; A determination module 405, configured to determine a contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair; The parameter adjustment module 406 is used to adjust the model parameters of the first graph neural network model based on the contrast loss value to obtain a target graph neural network model; the target graph neural network model is used to output the target final embedding representation of the target user based on the target social record graph data corresponding to the target user.
[0117] Optionally, the clustering module 403 includes: A clustering submodule, configured to cluster the final embedding representation of the first sample and the final embedding representation of the second sample based on a clustering hyperparameter to obtain a plurality of cluster clusters; A first determination submodule, configured to determine the clustering probabilities corresponding to each of the clustering clusters based on the preset clustering weight vectors corresponding to each of the clustering clusters, the first sample final embedding representation, and the second sample final embedding representation; The first generating submodule is used to generate cluster labels for each of the cluster clusters based on the preset cluster weight vectors of each of the cluster clusters and the first sample final embedding representation or the second sample final embedding representation corresponding to the maximum value of the cluster probability.
[0118] Optionally, the generating module 404 includes: A first combining submodule is configured to combine the first sample final embedding representation and the second sample final embedding representation to obtain a first sample final embedding representation pair when the second sample adjacency matrix corresponding to the first sample final embedding representation and the first sample adjacency matrix corresponding to the third sample adjacency matrix corresponding to the second sample final embedding representation are the same; A second determination submodule is configured to determine the first sample final embedding representation pair as a first positive sample pair when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair are the same; A third determination submodule is configured to determine a first cluster distribution consistency score of the first sample final embedding representation pair based on the cluster probabilities respectively corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair, when the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair are different; The fourth determination submodule is configured to determine the first sample final embedding representation pair as a first positive sample pair when the first cluster distribution consistency score is greater than or equal to a first threshold.
[0119] Optionally, the generating module 404 includes: A second combining submodule, configured to combine the first sample final embedding representation and the second sample final embedding representation to obtain a second sample final embedding representation pair; a fifth determination submodule, configured to determine a second cluster distribution consistency score of the second sample final embedding representation pair based on the cluster probabilities corresponding to the first sample final embedding representation and the second sample final embedding representation respectively included in the second sample final embedding representation pair, when the cluster labels corresponding to the first sample final embedding representation and the first sample final embedding representation respectively included in the second sample final embedding representation pair are different; The sixth determination submodule is used to determine the second sample final embedding representation pair as a first negative sample pair when the second cluster distribution consistency score is less than or equal to a second threshold; wherein the second threshold is less than the first threshold.
[0120] Optionally, the determining module 405 includes: a seventh determination submodule, configured to determine, from the first negative sample pairs, second negative sample pairs corresponding to each of the first positive sample pairs; wherein the second negative sample pairs corresponding to the first positive sample pairs contain the same first sample final embedding representation or second sample final embedding representation as the first positive sample pairs; an eighth determination submodule, configured to determine a weight value of the second negative sample pair based on the cosine similarity of the second negative sample pair; a ninth determination submodule, configured to determine a weight normalization coefficient of the second negative sample pair based on the weight value and a preset number of training cycles; The tenth determination submodule is used to determine the contrast loss value of the first graph neural network model based on the first positive sample pair, the weight value, the weight normalization coefficient and the second negative sample pair.
[0121] Optionally, the parameter adjustment module 406 includes: An eleventh determination submodule, used to determine an overall clustering loss value of the first graph neural network model based on the clustering probability; An adjustment submodule is used to adjust the model parameters of the first graph neural network model and the clustering hyperparameters based on the overall clustering loss value and the contrast loss value to obtain a target graph neural network model.
[0122] Optionally, the eleventh determining submodule includes: A generating unit, configured to generate a first clustering probability matrix corresponding to the clustering probability by using a Sinkhorn-Knopp algorithm; A first determining unit, configured to determine a first clustering loss value of the first graph neural network model based on a second clustering probability matrix formed by the clustering probabilities and the first clustering probability matrix; A second determining unit, configured to determine a second clustering loss value of the first graph neural network model based on the first information entropy of the clustering probability; A summing unit is used to sum the first clustering loss value and the second clustering loss value to obtain an overall clustering loss value of the first graph neural network model.
[0123] Optionally, the generating module 404 includes: A calculation submodule, used to calculate the total number of releases of the final embedded representation of the first sample and the final embedded representation of the second sample based on the current number of training cycles of the first graph neural network model and in combination with a first preset increasing function; A twelfth determination submodule is configured to determine, in descending order of the first information entropies corresponding to the clustering probabilities, a third sample final embedding representation of the first release number from the first sample final embedding representation, and determine a fourth sample final embedding representation of the second release number from the second sample final embedding representation, based on the total release number; wherein the first release number of the first sample final embedding representation is the same as the second release number of the second sample final embedding representation, and the total release number is equal to the sum of the first release number and the second release number; The second generating submodule is used to generate a first positive sample pair based on the cluster label, the cluster probability, the third sample final embedding representation and the fourth sample final embedding representation.
[0124] Optionally, the adjustment submodule includes: A third determining unit, used to determine a balance coefficient corresponding to the overall clustering loss value; a fourth determining unit, configured to determine a model loss value of the first graph neural network model based on the balance coefficient, the overall clustering loss value, and the contrast loss value; An adjustment unit is used to adjust the model parameters of the first graph neural network model and the clustering hyperparameters based on the model loss value to obtain a target graph neural network model.
[0125] The contrastive learning device for unsupervised graph neural network in the embodiment of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than a terminal. Exemplarily, the electronic device can be a GPU BOX, a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmentedreality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personaldigital assistant, PDA), etc., and can also be a server, a network attached storage (Network AttachedStorage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0126] The contrastive learning device for unsupervised graph neural network in the embodiment of the present application can be a device with an operating system. The operating system can be an Android operating system, a Linux, a Windows operating system, etc., and can also be other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0127] The contrastive learning device for unsupervised graph neural network provided in the embodiment of the present application can realize Figures 1 to 3 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0128] The present application embodiment provides an electronic device, see Figure 5 The electronic device 50 includes: a processor 501, a memory 502, and a computer program 5021 stored in the memory 502 and executable on the processor 501. When the processor 501 executes the program, the comparative learning method for unsupervised graph neural networks of the aforementioned embodiment is implemented.
[0129] The embodiment of the present application also provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps in the comparative learning method for unsupervised graph neural networks disclosed in the embodiment of the present application are implemented.
[0130] The embodiment of the present application also provides a computer program product, which, when running on an electronic device, enables a processor to implement the steps in the contrastive learning method for unsupervised graph neural networks disclosed in the embodiment of the present application.
[0131] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0132] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices, electronic devices, and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0133] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0135] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0136] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0137] The above is a detailed introduction to the comparative learning method and device for unsupervised graph neural networks provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A contrastive learning method for unsupervised graph neural networks, characterized in that: The method comprises: Adding a noise vector to a first sample adjacency matrix corresponding to the sample graph data to obtain a second sample adjacency matrix and a third sample adjacency matrix; wherein the noise vectors included in the second sample adjacency matrix and the third sample adjacency matrix are different; and the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data; Inputting the first sample embedding representation and the second sample adjacency matrix corresponding to the sample graph data into the first graph neural network model to obtain the first sample final embedding representation output by the first graph neural network model, and inputting the first sample embedding representation and the third sample adjacency matrix into the first graph neural network model to obtain the second sample final embedding representation output by the first graph neural network model; wherein the first sample embedding representation is generated based on the first node data of each sample node in the sample graph data; Based on the clustering hyperparameter, clustering the final embedding representation of the first sample and the embedding representation of the second sample to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters; wherein the number of the clusters is determined based on the clustering hyperparameter; Generate a first positive sample pair based on the cluster label, the cluster probability, the first sample final embedding representation, and the second sample final embedding representation, and generate a first negative sample pair based on the cluster label, the cluster probability, the first sample final embedding representation, and the second sample final embedding representation; Determining a contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair; Based on the contrast loss value, the model parameters of the first graph neural network model are adjusted to obtain a target graph neural network model; the target graph neural network model is used to output a target final embedding representation of the target user based on the target social record graph data corresponding to the target user.
2. The method according to claim 1, characterized in that The step of clustering the first sample final embedding representation and the second sample final embedding representation based on the clustering hyperparameter to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters, including: Based on the clustering hyperparameter, clustering the final embedding representation of the first sample and the final embedding representation of the second sample to obtain a plurality of cluster clusters; Determine the clustering probabilities corresponding to each of the clusters based on the preset clustering weight vectors corresponding to each of the clusters, the final embedding representation of the first sample, and the final embedding representation of the second sample; Based on the preset clustering weight vectors of the clustering clusters and the first sample final embedding representation or the second sample final embedding representation corresponding to the maximum value of the clustering probability, a clustering label of each clustering cluster is generated.
3. The method according to claim 1, characterized in that The generating a first positive sample pair based on the cluster label, the cluster probability, the first sample final embedding representation and the second sample final embedding representation comprises: When the second sample adjacency matrix corresponding to the first sample final embedding representation and the first sample adjacency matrix corresponding to the third sample adjacency matrix corresponding to the second sample final embedding representation are the same, combining the first sample final embedding representation and the second sample final embedding representation to obtain a first sample final embedding representation pair; In a case where the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation contained in the first sample final embedding representation pair are the same, determining the first sample final embedding representation pair as a first positive sample pair; In a case where the cluster labels corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair are different, determining a first cluster distribution consistency score of the first sample final embedding representation pair based on the cluster probabilities respectively corresponding to the first sample final embedding representation and the second sample final embedding representation included in the first sample final embedding representation pair; When the first cluster distribution consistency score is greater than or equal to a first threshold, the first sample final embedding representation pair is determined as a first positive sample pair.
4. The method according to claim 1, characterized in that: The generating a first negative sample pair based on the cluster label, the cluster probability, the first sample final embedding representation and the second sample final embedding representation comprises: Combining the first sample final embedding representation and the second sample final embedding representation to obtain a second sample final embedding representation pair; In a case where the cluster labels respectively corresponding to the first sample final embedding representation and the first sample final embedding representation included in the second sample final embedding representation pair are different, determining a second cluster distribution consistency score of the second sample final embedding representation pair based on the cluster probabilities respectively corresponding to the first sample final embedding representation and the second sample final embedding representation included in the second sample final embedding representation pair; When the second cluster distribution consistency score is less than or equal to a second threshold, the second sample final embedding representation pair is determined as a first negative sample pair; wherein the second threshold is less than the first threshold.
5. The method according to claim 1, characterized in that The determining, based on the first positive sample pair and the first negative sample pair, a contrast loss value of the first graph neural network model includes: Determine, from the first negative sample pairs, second negative sample pairs corresponding to each of the first positive sample pairs; wherein the second negative sample pairs corresponding to the first positive sample pairs contain the same first sample final embedding representation or second sample final embedding representation as the first positive sample pairs; Determining a weight value of the second negative sample pair based on the cosine similarity of the second negative sample pair; Determining a weight normalization coefficient of the second negative sample pair based on the weight value and a preset number of training cycles; Based on the first positive sample pair, the weight value, the weight normalization coefficient and the second negative sample pair, determine the contrast loss value of the first graph neural network model.
6. The method according to claim 1, characterized in that The adjusting the model parameters of the first graph neural network model based on the contrast loss value to obtain a target graph neural network model includes: Based on the clustering probability, determining an overall clustering loss value of the first graph neural network model; Based on the overall clustering loss value and the contrast loss value, the model parameters of the first graph neural network model and the clustering hyperparameters are adjusted to obtain a target graph neural network model.
7. The method according to claim 6, characterized in that The determining, based on the clustering probability, an overall clustering loss value of the first graph neural network model comprises: Using the Sinkhorn-Knopp algorithm to generate a first clustering probability matrix corresponding to the clustering probability; Determine a first clustering loss value of the first graph neural network model based on a second clustering probability matrix formed by the clustering probabilities and the first clustering probability matrix; Determining a second clustering loss value of the first graph neural network model based on a first information entropy of the clustering probability; The first clustering loss value and the second clustering loss value are summed to obtain an overall clustering loss value of the first graph neural network model.
8. The method according to claim 1, characterized in that: The generating a first positive sample pair based on the cluster label, the cluster probability, the first sample final embedding representation and the second sample final embedding representation comprises: Based on the current number of training cycles of the first graph neural network model, the total number of released final embedded representations of the first sample and the total number of released final embedded representations of the second sample are calculated in combination with a first preset increasing function; According to the order of the first information entropies corresponding to the clustering probabilities from large to small, based on the total released number, a third sample final embedded representation of the first released number is determined from the first sample final embedded representation, and a fourth sample final embedded representation of the second released number is determined from the second sample final embedded representation; wherein the first released number of the first sample final embedded representation and the second released number of the second sample final embedded representation are the same, and the total released number is equal to the sum of the first released number and the second released number; A first positive sample pair is generated based on the cluster label, the cluster probability, the third sample final embedding representation, and the fourth sample final embedding representation.
9. The method according to claim 6, characterized in that The adjusting the model parameters and clustering hyperparameters of the first graph neural network model based on the overall clustering loss value and the contrast loss value to obtain a target graph neural network model includes: Determining a balance coefficient corresponding to the overall clustering loss value; Determining a model loss value of the first graph neural network model based on the balance coefficient, the overall clustering loss value, and the contrast loss value; Based on the model loss value, the model parameters of the first graph neural network model and the clustering hyperparameters are adjusted to obtain a target graph neural network model.
10. A contrastive learning device for unsupervised graph neural networks, characterized in that: The device comprises: An adding module, used for adding a noise vector to a first sample adjacency matrix corresponding to the sample graph data, to obtain a second sample adjacency matrix and a third sample adjacency matrix; wherein the noise vectors included in the second sample adjacency matrix and the third sample adjacency matrix are different; and the first sample adjacency matrix is generated based on the connection relationship between each node in the sample graph data; An input-output module, used for inputting the first sample embedding representation and the second sample adjacency matrix corresponding to the sample graph data into the first graph neural network model to obtain the first sample final embedding representation output by the first graph neural network model, and inputting the first sample embedding representation and the third sample adjacency matrix into the first graph neural network model to obtain the second sample final embedding representation output by the first graph neural network model; wherein the first sample embedding representation is generated based on the first node data of each sample node in the sample graph data; A clustering module, configured to cluster the final embedding representation of the first sample and the embedding representation of the second sample based on a clustering hyperparameter, to obtain a plurality of clusters and cluster labels and cluster probabilities corresponding to each of the clusters; wherein the number of the clusters is determined based on the clustering hyperparameter; A generating module, configured to generate a first positive sample pair based on the clustering label, the clustering probability, the first sample final embedding representation, and the second sample final embedding representation, and to generate a first negative sample pair based on the clustering label, the clustering probability, the first sample final embedding representation, and the second sample final embedding representation; A determination module, configured to determine a contrast loss value of the first graph neural network model based on the first positive sample pair and the first negative sample pair; A parameter adjustment module is used to adjust the model parameters of the first graph neural network model based on the contrast loss value to obtain a target graph neural network model; the target graph neural network model is used to output the target final embedding representation of the target user based on the target social record graph data corresponding to the target user.