Method, device and equipment for calculating GW distance between graph objects and training model

By constructing a GW distance estimation model and training it using spectral methods and neural network models, the problem of high computational complexity of GW distance for graph objects was solved, achieving efficient GW distance estimation and processing of large-scale graph objects.

CN121147660APending Publication Date: 2025-12-16THE CHINESE UNIV OF HONG KONG (SHENZHEN) +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511251461.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-01
Publication Date
2025-12-16

AI Technical Summary

Technical Problem

Computing the GW distance between graph objects is highly complex, and existing methods require repeated iterations when computing large-scale graph objects, resulting in high computational costs.

Method used

By obtaining the adjacency matrix and GW distance of multiple sample graph objects, a similarity matrix is ​​calculated. The graph position encoding information is extracted using the spectral method, and a GW distance inference model is constructed. The model is trained using a graph neural network, a Transformer sub-model, and a multilayer perceptron sub-model to reduce computational complexity.

Benefits of technology

It enables direct calculation of the GW distance between graph objects, reducing computational complexity, improving processing efficiency, and is applicable to graph object data in different fields, with high generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121147660A_ABST
    Figure CN121147660A_ABST
Patent Text Reader

Abstract

The invention relates to the field of graph structure data processing, in particular to a calculation and model training method, device and equipment for the GW distance between graph objects, and the method comprises the steps: obtaining an adjacent matrix of a plurality of sample graph objects and the GW distance between any two sample graph objects; calculating a similarity matrix of the sample graph objects based on the adjacent matrix of the sample graph objects; performing spectral decomposition on the similarity matrix of the sample graph object by adopting a spectral method, and extracting graph position coding information of each vertex in the sample graph object; a plurality of training samples are constructed for model training, a trained GW distance calculation model is obtained, each training sample comprises an input variable and supervision information corresponding to the input variable, the input variable comprises an adjacent matrix and graph position coding information of two sample graph objects, and the supervision information comprises the GW distance between the two sample graph objects. According to the technical scheme, the calculation complexity of the GW distance can be reduced, and the method is mainly used for calculating the GW distance between two graph objects.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of graph structure data processing, and particularly relates to a method and device for calculating GW distance between graph objects and model training. BACKGROUND

[0002] Graph structure data exists widely in many fields, such as chemistry, biology, social network, knowledge graph, and computer vision, etc. A graph object is a basic processing unit in graph structure data, which refers to a specific and independent graph instance. In a broad sense, a graph object is composed of vertices and edges, where the vertices represent entities and the edges represent the connection relationship between entities. Machine learning models such as graph search, graph classification, and graph clustering often involve comparing two graph objects. However, due to the complexity of graph structure data such as the unordered nature of vertices, varying number of vertices, and the absence of vertex correspondence, graph object comparison itself is a very challenging task.

[0003] At present, the GW (Gromov-Wasserstein) distance between graph objects is a powerful measure of graph object comparison. The GW distance does not need to assume that the graph objects to be compared should be in the same domain space. In fact, the GW distance only compares the difference in the internal connection relationship between graph objects, and does not directly compare the difference between their vertices. Therefore, the GW distance is particularly suitable for comparing graph objects with different numbers of vertices, inconsistent structures, or even without explicit vertex correspondence.

[0004] However, the inventors have found that calculating the GW distance between graph objects requires solving an iterative optimization problem in a two-dimensional probability measure space, which has very high computational complexity. This brings a large overhead in terms of time and space for GW distance calculation, resulting in high computational cost. Even if some existing methods try to reduce the computational complexity of GW distance by adding a regularization term or sampling method, the existing methods still have to suffer from the cumulative complexity of iterative solution for each calculation when facing large-scale GW distance calculation of graph objects. SUMMARY

[0005] To solve the problems in the related art, the present disclosure provides a method and device for calculating GW distance between graph objects and model training.

[0006] In a first aspect, the present disclosure provides a method for training a model for calculating GW distance between graph objects, comprising:

[0007] obtaining adjacency matrices of a plurality of sample graph objects and GW distances between any two sample graph objects;

[0008] For each sample graph object, a similarity matrix of the sample graph object is calculated based on an adjacency matrix of the sample graph object;

[0009] A spectral method is used to perform spectral decomposition on the similarity matrix of the sample graph object to extract graph position encoding information of each vertex in the sample graph object;

[0010] A plurality of training samples are constructed for model training to obtain a trained GW distance calculation model, wherein each training sample includes an input variable and corresponding supervision information, the input variable includes adjacency matrices and graph position encoding information of two sample graph objects, and the supervision information includes a GW distance between the two sample graph objects.

[0011] In a possible implementation, the similarity matrix of the sample graph object is calculated based on the adjacency matrix of the sample graph object, and includes:

[0012] The similarity matrix C of the i-th sample graph object is calculated according to the following formula i :

[0013] C i =A i +I or C i =ShortestPath(A i );

[0014] Wherein, A i is the adjacency matrix of the i-th sample graph object, I is a unit matrix with the same shape as the adjacency matrix A i , and ShortestPath() is a shortest path algorithm.

[0015] In a possible implementation, the spectral method is used to perform spectral decomposition on the similarity matrix of the sample graph object to extract the graph position encoding information of each vertex in the sample graph object, and includes:

[0016] The similarity matrix C of the i-th sample graph object is singular value decomposed according to the following formula i :

[0017]

[0018] Wherein, SVD() is a singular value decomposition function, U i is a matrix composed of left singular vectors, S i is a diagonal matrix with singular values arranged in descending order as the diagonal line, and V i is a matrix composed of right singular vectors;

[0019] The graph position encoding information E of each vertex in the i-th sample graph object is extracted according to the following formula i :

[0020]

[0021] In a possible implementation, the GW distance estimation model comprises a graph neural network submodel, a Transformer submodel, and a multi-layer perceptron submodel.

[0022] The input of the graph neural network submodel is an adjacency matrix and graph position encoding information of two sample graph objects, and the output is first embedding information of the two sample graph objects; the input of the Transformer submodel is the graph position encoding information of the two sample graph objects, and the output is second embedding information of the two sample graph objects; the input of the multi-layer perceptron submodel is multi-kernel maximum mean discrepancy information MMD between augmented embedding information of the two sample graph objects, and the output is a GW distance estimation value, wherein the augmented embedding information comprises the first embedding information and the second embedding information.

[0023] In a possible implementation, the loss function of the GW distance estimation model comprises:

[0024]

[0025] wherein d ij is a GW distance estimation value between an i th and a j th sample graph object output by the GW distance estimation model, is a GW distance between the i th and the j th sample graph object, and N is the number of sample graph objects.

[0026] In a second aspect, the embodiments of the present disclosure provide a method for estimating a GW distance between graph objects, comprising:

[0027] obtaining an adjacency matrix of two target graph objects to be processed;

[0028] calculating a similarity matrix of the target graph objects based on the adjacency matrix of the target graph objects;

[0029] performing spectral decomposition on the similarity matrix of the target graph objects by using a spectral method to extract graph position encoding information of each vertex in the target graph objects;

[0030] inputting the adjacency matrix and the graph position encoding information of the target graph objects into a pre-trained GW distance estimation model, executing the pre-trained GW distance estimation model, and obtaining a GW distance estimation value output by the pre-trained GW distance estimation model;

[0031] The pre-trained GW distance estimation model is trained based on the method in any one of claims 1-5.

[0032] In a third aspect, the embodiments of the present disclosure provide a training device for a graph object GW distance calculation model, comprising:

[0033] a data acquisition module configured to acquire an adjacency matrix of a plurality of sample graph objects and a GW distance between any two sample graph objects;

[0034] a similarity calculation module configured to calculate, for each sample graph object, a similarity matrix of the sample graph object based on the adjacency matrix of the sample graph object;

[0035] an information extraction module configured to perform spectral decomposition on the similarity matrix of the sample graph object using a spectral method to extract graph position encoding information of each vertex in the sample graph object;

[0036] a model training module configured to construct a plurality of training samples for model training to obtain a trained GW distance calculation model, wherein each training sample comprises an input variable and corresponding supervision information, the input variable comprises an adjacency matrix and graph position encoding information of two sample graph objects, and the supervision information comprises a GW distance between the two sample graph objects.

[0037] In a fourth aspect, the embodiments of the present disclosure provide a GW distance calculation device for graph objects, comprising:

[0038] a target acquisition module configured to acquire adjacency matrices of two target graph objects to be processed;

[0039] a similarity calculation module configured to calculate a similarity matrix of the target graph object based on the adjacency matrix of the target graph object;

[0040] a calculation module configured to perform spectral decomposition on the similarity matrix of the target graph object using a spectral method to extract graph position encoding information of each vertex in the target graph object;

[0041] a distance calculation module configured to input the adjacency matrix and the graph position encoding information of the target graph object into a pre-trained GW distance calculation model, execute the pre-trained GW distance calculation model, and obtain a GW distance calculation value output by the pre-trained GW distance calculation model;

[0042] wherein the pre-trained GW distance calculation model is trained based on the method of any one of claims 1-5.

[0043] In a fifth aspect, the embodiments of the present disclosure provide an electronic device comprising a memory and a processor, wherein the memory is configured to store one or more computer instructions, and the one or more computer instructions are executed by the processor to implement the method of any one of the first or second aspect.

[0044] In a sixth aspect, a computer readable storage medium is provided, and the computer readable storage medium stores computer instructions. The computer instructions, when executed by a processor, implement the method according to any one of the first or second aspect.

[0045] According to the technical scheme provided in the embodiments of the present disclosure, the adjacency matrix of a plurality of sample graph objects and the GW distance between any two sample graph objects can be obtained; for each sample graph object, the similarity matrix of the sample graph object is calculated based on the adjacency matrix of the sample graph object; the spectral method is used to perform spectral decomposition on the similarity matrix of the sample graph object to extract the graph position coding information of each vertex in the sample graph object; a plurality of training samples are constructed for model training to obtain a trained GW distance calculation model, wherein each training sample includes an input variable and corresponding supervision information, the input variable includes the adjacency matrix and the graph position coding information of two sample graph objects, and the supervision information includes the GW distance between the two sample graph objects. In this way, the trained GW distance calculation model can be used to directly calculate the GW distance between two graph objects, reducing the calculation complexity of the GW distance, and avoiding the process of repeatedly solving the iterative optimization problem in the prior art when facing the GW distance calculation of large-scale graph objects, greatly reducing the calculation overhead and improving the processing efficiency. Moreover, the model can be applied to graph object data in different fields, and has high generalization ability.

[0046] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and are not limiting to the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0047] Other features, objects, and advantages of the present disclosure will become more apparent from the following detailed description when read in conjunction with the accompanying drawings. In the drawings:

[0048] Figure 1 A flow chart of a GW distance calculation model training method between graph objects provided by the embodiments of the present disclosure is shown.

[0049] Figure 2 A flow chart of a GW distance calculation method between graph objects provided by the embodiments of the present disclosure is shown.

[0050] Figure 3 A structure block diagram of a GW distance calculation model training device between graph objects provided by the embodiments of the present disclosure is shown.

[0051] Figure 4 A structure block diagram of a GW distance calculation device between graph objects provided by the embodiments of the present disclosure is shown.

[0052] Figure 5A structural block diagram of an electronic device according to an embodiment of the disclosure is shown.

[0053] Figure 6 A structural schematic diagram of a computer system suitable for implementing the method of the embodiments of the disclosure is shown. DETAILED DESCRIPTION

[0054] Hereinafter, exemplary embodiments of the disclosure will be described in detail with reference to the accompanying drawings so as to be easily implemented by those skilled in the art. Also, portions irrelevant to the description of the exemplary embodiments are omitted in the accompanying drawings for the sake of clarity.

[0055] In the disclosure, it should be understood that terms such as "include" or "have" are intended to indicate that there are features, numbers, steps, actions, components, parts or combinations thereof disclosed in the specification, and do not exclude the possibility that one or more other features, numbers, steps, actions, components, parts or combinations thereof exist or are added.

[0056] It should also be noted that the embodiments in the disclosure and the features in the embodiments can be combined with each other without conflict. The disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.

[0057] Figure 1 A flowchart of a GW distance calculation model training method between graph objects provided by an embodiment of the disclosure is shown. As shown in Figure 1 The GW distance calculation model training method between graph objects includes the following steps S101-S104:

[0058] In step S101, the adjacency matrix of a plurality of sample graph objects and the GW distance between any two sample graph objects are obtained.

[0059] In step S102, for each sample graph object, the similarity matrix of the sample graph object is calculated based on the adjacency matrix of the sample graph object.

[0060] In step S103, the similarity matrix of the sample graph object is spectrally decomposed using a spectral method to extract graph position encoding information of each vertex in the sample graph object.

[0061] In step S104, a plurality of training samples are constructed for model training to obtain a trained GW distance calculation model, wherein each training sample includes an input variable and its corresponding supervision information, the input variable includes the adjacency matrix and the graph position encoding information of two sample graph objects, and the supervision information includes the GW distance between the two sample graph objects.

[0062] In one possible implementation, the training method for the graph object GW distance calculation model can be applied to electronic devices such as computers, servers, and computer clusters that are capable of executing the training of the graph object GW distance calculation model.

[0063] In one possible implementation, the adjacency matrix of a graph object uses a two-dimensional array to store information about the vertices and edges of the graph object. The size of the adjacency matrix depends only on the number of vertices, and its rows and columns correspond to the vertices of the graph object. The elements of the adjacency matrix indicate whether there is an edge between two vertices and the weight of the edge.

[0064] In one possible implementation, the GW distance between two sample graph objects is calculated using existing GW distance calculation methods. Those skilled in the art are well aware of the specific calculation process, which will not be elaborated here.

[0065] In one possible implementation, N sample graph objects can be obtained, and the adjacency matrix of the i-th sample graph object is denoted as A. i Assume that the i-th sample graph object has N i If there are vertices, then the adjacency matrix A i It can be represented as N i ×N i The matrix. Since the vertices in different graph objects can be high-dimensional data of different domains and types, the number of vertices and feature dimensions of different graph structure objects can be the same or different, and there is no restriction here; that is, when i takes different values, N i The values ​​of can be different or the same, and the vertex feature dimensions can be different or the same. The GW distance between any two sample graph objects, such as the i-th sample graph object and the j-th sample graph object, can be denoted as . This allows us to obtain the adjacency matrix of N sample graph objects. And the GW distance between any two sample graph objects in the N sample graph objects.

[0066] In one possible implementation, the similarity matrix is ​​either a symmetric or asymmetric matrix (depending on the definition of similarity). The similarity matrix of the sample graph objects refers to the matrix representing the pairwise similarity between vertices in the sample graph objects. Here, the similarity matrix of the sample graph objects can be calculated using their adjacency matrix. For the i-th sample graph object, its similarity matrix C... i The elements in the matrix are the similarity weights between two vertices in the i-th sample graph object, and the C-value of the similarity matrix of the i-th sample graph object is... i Also N i ×N i The matrix.

[0067] In one possible implementation, graph positional encoding is a technique for generating structured low-dimensional vectors for vertices in a graph object, representing the topological position or structural role of a vertex within the graph object. Unlike node features, positional encoding focuses on the structural information of the graph object. Spectral methods can utilize eigenvalue decomposition of the similarity matrix to extract graph positional encoding information for each vertex in the graph object. For example, the following formula can be used to express the graph positional encoding information from the similarity matrix C. i The extracted image location encoding information P i :P i =h(C i ), where h is the graph position encoding extraction function.

[0068] In one possible implementation, for multiple sample graph objects, the adjacency matrix and graph position encoding information of two of the sample graph objects can be used as the input data of the model, and the GW distance between the two sample graph objects can be used as the supervision information of the model to construct a training sample. Multiple training samples can be constructed in this way, and the model can be trained using these multiple training samples. The model parameters can be continuously adjusted until the loss function of the model converges or the number of iterations reaches the maximum number, and the training ends, resulting in a trained GW distance estimation model.

[0069] This implementation can obtain the adjacency matrices of multiple sample graph objects and the GW distance between any two sample graph objects. For each sample graph object, a similarity matrix is ​​calculated based on its adjacency matrix. A spectral method is used to perform spectral decomposition on the similarity matrix of the sample graph objects to extract the graph position encoding information of each vertex. Multiple training samples are constructed for model training to obtain a trained GW distance estimation model. Each training sample includes input variables and their corresponding supervision information. The input variables include the adjacency matrices and graph position encoding information of the two sample graph objects, and the supervision information includes the GW distance between the two sample graph objects. Thus, the trained GW distance estimation model can directly estimate the GW distance between two graph objects, reducing the computational complexity of GW distance calculation. Furthermore, when dealing with GW distance calculations for large-scale graph objects, it avoids the need for repeated iterative optimization problems required by existing technologies, significantly reducing computational overhead and improving processing efficiency. Moreover, this model is applicable to graph object data from different domains and has high generalization ability.

[0070] In one possible implementation, calculating the similarity matrix of the sample graph objects based on their adjacency matrix includes:

[0071] The similarity matrix C of the i-th sample image object is calculated using the following formula. i :

[0072] C i =A i +I or C i =ShortestPath(A i );

[0073] Among them, A i Let I be the adjacency matrix of the i-th sample graph object, and let I be the adjacency matrix of the i-th sample graph object. i For identity matrices of the same shape, ShortestPath() is the shortest path algorithm.

[0074] In this implementation, 1s can be directly added to the diagonal of the adjacency matrix, i.e., adjacency matrix A. i The similarity matrix can be obtained by adding the identity matrix I, which is a simple and quick calculation method; alternatively, the corresponding shortest path matrix can be calculated based on the adjacency matrix as the similarity matrix, that is, using ShortestPath(A) = ... i The similarity matrix is ​​calculated using the method described above. The algorithm for calculating the shortest path matrix, namely ShortestPath(), can be either the Floyd algorithm or the Dijkstra algorithm, which will result in a more accurate similarity matrix.

[0075] It should be noted that there are other ways to calculate the similarity matrix of the sample graph objects based on their adjacency matrix, which will not be described in detail here.

[0076] In one possible implementation, the step of performing spectral decomposition on the similarity matrix of the sample graph objects using a spectral method to extract the graph location encoding information of the sample graph objects includes:

[0077] The similarity matrix C of the i-th sample image object is calculated according to the following formula. i Perform singular value decomposition:

[0078]

[0079] Where SVD() is the singular value decomposition function, U i S is a matrix composed of left singular vectors. i V is a diagonal matrix whose singular values ​​are arranged in descending order. i It is a matrix composed of right singular vectors;

[0080] The graph position encoding information E of each vertex in the sample graph object is extracted according to the following formula. i :

[0081]

[0082] In this implementation, the spectral method can be used to analyze the similarity matrix C. i Perform Singular Value Decomposition (SVD), a method that decomposes any matrix into the product of three specific matrices. For the similarity matrix C... i Its singular value decomposition is expressed as: Among them, U i For N i ×N i An orthogonal matrix (left singular vector), whose column vectors form an orthonormal basis, S i For N i ×N i A diagonal matrix, where the diagonal elements are singular values ​​(non-negative and arranged in descending order). For N i ×N i The transpose of an orthogonal matrix (right singular vector). The graph position encoding information E of each vertex in the i-th matrix. i for

[0083] In one possible implementation, the GW distance estimation model includes a graph neural network (GNN) sub-model, a transformer sub-model, and a multilayer perceptron (MLP) sub-model.

[0084] In this implementation, the adjacency matrix and graph position encoding information of the i-th and j-th sample graph objects, i.e. (E i A i ) and (E j A j The inputs are respectively fed into the graph neural network sub-model to obtain the first embedding information of the i-th sample graph object output by the graph neural network sub-model. and the first embedding information of the j-th sample graph object At the same time, the graph position encoding information of the i-th and j-th sample graph objects, i.e., E, can be used. i and E j The inputs are fed into the Transformer sub-model to obtain the second embedding information of the i-th sample graph object output by the Transformer sub-model. and the second embedding information of the j-th sample graph object Then, these embedding information are concatenated to obtain the augmented embedding information of the i-th and j-th sample graph objects, that is, the augmented embedding information of the i-th sample graph object. augmented embedding information of the j-th sample graph object Specifically, this part can be described by the following expression:

[0085]

[0086] In this implementation, the graph neural network sub-model can use GIN (Graph Isomorphism Network) as the backbone network, and the Transformer sub-model can be configured with 1 layer, 4 attention heads, and 1024 hidden dimensions.

[0087] In this implementation, the augmented embedding information Z of the i-th and j-th sample graph objects can be calculated. (i) and Z (j) The multi-core MMD (Maximum Mean Discrepancy) between them, that is...

[0088]

[0089] in, Z is the augmented embedding information of the i-th sample graph object. (i) The p-th line, Z is the augmented embedding information of the j-th sample graph object. (j) The qth line, It is the Gaussian kernel function, n i It is Z (i) The number of rows, n j It is Z (j) number of rows.

[0090] In this embodiment, the augmented embedding information Z of the i-th and j-th sample graph objects is... (i) and Z (j) The multi-kernel MMD can represent the multi-scale structural difference information between the i-th and j-th sample image objects. This multi-kernel MMD can be concatenated into a row vector and used as the input to a multilayer perceptron sub-model. Using this multilayer perceptron model, the GW distance estimation value d output by the multilayer perceptron model can be obtained. ij It can be expressed by the formula:

[0091] d ij =MLP θ ([MMD1,…,MMD s ]), where θ is a learnable parameter of the multilayer perceptron sub-model.

[0092] In this embodiment, the training of the GW distance estimation model is supervised, allowing for comparison of the GW distance estimation values ​​d. ij Distance to GW as monitoring information Calculate the loss function of the GW distance estimation model until the loss function converges or the maximum number of training iterations is reached, and you will get the trained GW distance estimation model.

[0093] In one possible implementation, the loss function of the GW distance estimation model includes:

[0094]

[0095] Where, d ij It is the GW distance estimation value between the i-th and j-th sample graph objects output by the GW distance estimation model. It is the GW distance between the i-th and j-th sample graph objects, and N is the number of sample graph objects.

[0096] Figure 2 A flowchart illustrating a method for calculating the GW distance between graph objects according to an embodiment of this disclosure is shown. Figure 2 As shown, the method for calculating the GW distance between graph objects includes the following steps S201-S204:

[0097] In step S201, the adjacency matrix of the two target graph objects to be processed is obtained;

[0098] In step S202, the similarity matrix of the target graph objects is calculated based on the adjacency matrix of the target graph objects;

[0099] In step S203, the similarity matrix of the target graph object is decomposed using the spectral method to extract the graph position encoding information of each vertex in the target graph object;

[0100] In step S204, the adjacency matrix and graph position encoding information of the target graph object are input into the pre-trained GW distance estimation model, the pre-trained GW distance estimation model is executed, and the GW distance estimation value output by the pre-trained GW distance estimation model is obtained.

[0101] In one possible implementation, the method for calculating the GW distance between graph objects can be applied to electronic devices such as computers, servers, and computer clusters that are capable of performing the calculation of the GW distance between graph objects.

[0102] In one possible implementation, any two graph objects whose GW distance needs to be calculated can be denoted as target graph object X and target graph object Y, and the adjacency matrix of target graph object X can be obtained as A. xThe adjacency matrix of the target graph object Y is A y The number of vertices in the target graph objects X and Y can be the same or different, and the feature dimensions of the vertices can be the same or different; there are no restrictions here.

[0103] In one possible implementation, the adjacency matrix of the target graph object X can be A. x The similarity matrix C of the target image object X is calculated. x The adjacency matrix of the target graph object Y is A. y The similarity matrix C of the target image object Y is calculated. y For example, the similarity matrix can be obtained by directly adding 1 to the diagonal of the adjacency matrix, that is, by adding the identity matrix I to the adjacency matrix. Alternatively, the shortest path matrix can be calculated based on the adjacency matrix as the similarity matrix. The algorithm for calculating the shortest path matrix can be either the Floyd algorithm or the Dijkstra algorithm.

[0104] In one possible implementation, singular value decomposition can be performed on the similarity matrices of target graph objects X and Y first, and then the graph position encoding information of each vertex in target graph objects X and Y can be extracted. Taking target graph object X as an example, the similarity matrix C of target graph object X can be calculated according to the following formula. x Perform singular value decomposition:

[0105]

[0106] Where SVD() is the singular value decomposition function, U x S is a matrix composed of left singular vectors. x V is a diagonal matrix whose singular values ​​are arranged in descending order. x It is a matrix composed of right singular vectors;

[0107] The graph position encoding information E of each vertex in the target graph object X is extracted according to the following formula. x :

[0108]

[0109] In one possible implementation, the GW distance estimation model can be pre-trained using the aforementioned training method for estimating GW distances between graph objects. The adjacency matrices and graph position encoding information of target graph objects X and Y, i.e., (A... x E x ) and (A y E yThe input is fed into a pre-trained GW distance estimation model, and the pre-trained GW distance estimation model is executed to obtain the GW distance estimation value output by the pre-trained GW distance estimation model.

[0110] In one possible implementation, the GW distance estimation model includes a graph neural network sub-model, a Transformer sub-model, and a multilayer perceptron sub-model. In this case, (A) x E x ) and (A y E y The first embedding information of the target graph object X is obtained by inputting the information into the graph neural network sub-model. The first embedding information of the target graph object Y Simultaneously, the graph position encoding information of the target graph objects X and Y, i.e., E, can be obtained. x and E y The information is input into the Transformer sub-model to obtain the second embedding information of the target graph object X output by the Transformer sub-model. The second embedded information of the target graph object Y Then, these embedding information are concatenated to obtain the augmented embedding information of the target graph object X. Augmented embedding information of target graph object Y Then, the augmented embedding information Z of the two target graph objects is calculated. (x) and Z (y) Multi-core MMD between, that is The multi-core MMDs can be concatenated into a row vector and used as the input to a multilayer perceptron sub-model. This multilayer perceptron model can then be used for calculations to obtain the GW distance estimation value d output by the multilayer perceptron model. xy .

[0111] This disclosure also provides a training apparatus for a model to calculate the GW distance between graph objects. Figure 3 This diagram illustrates a structural block diagram of a training device for a graph object GW distance calculation model according to an embodiment of this disclosure. This device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 3 As shown, the training device for the inference model of GW distance between graph objects includes:

[0112] The data acquisition module 301 is configured to acquire the adjacency matrix of multiple sample graph objects and the GW distance between any two sample graph objects.

[0113] The similarity calculation module 302 is configured to calculate the similarity matrix of the sample graph objects based on the adjacency matrix of the sample graph objects for each sample graph object;

[0114] The information extraction module 303 is configured to perform spectral decomposition on the similarity matrix of the sample graph object using a spectral method to extract the graph position encoding information of each vertex in the sample graph object;

[0115] The model training module 304 is configured to construct multiple training samples for model training to obtain a trained GW distance inference model. Each training sample includes input variables and their corresponding supervision information. The input variables include the adjacency matrix of two sample graph objects and graph position encoding information. The supervision information includes the GW distance between the two sample graph objects.

[0116] In one possible implementation, the similarity calculation module is configured as follows:

[0117] The similarity matrix C of the i-th sample image object is calculated using the following formula. i :

[0118] C i =A i +I or C i =ShortestPath(A i );

[0119] Among them, A i Let I be the adjacency matrix of the i-th sample graph object, and let I be the adjacency matrix of the i-th sample graph object. i For identity matrices of the same shape, ShortestPath() is the shortest path algorithm.

[0120] In one possible implementation, the information extraction module is configured as follows:

[0121] The similarity matrix C of the i-th sample image object is calculated according to the following formula. i Perform singular value decomposition:

[0122]

[0123] Where SVD() is the singular value decomposition function, U i S is a matrix composed of left singular vectors. i V is a diagonal matrix whose singular values ​​are arranged in descending order. i It is a matrix composed of right singular vectors;

[0124] The graph position encoding information E of each vertex in the i-th sample graph object is extracted according to the following formula. i :

[0125]

[0126] In one possible implementation, the GW distance estimation model includes a graph neural network sub-model, a Transformer sub-model, and a multilayer perceptron sub-model.

[0127] The graph neural network sub-model takes the adjacency matrix and graph position encoding information of two sample graph objects as input and outputs the first embedding information of the two sample graph objects as output. The Transformer sub-model takes the graph position encoding information of two sample graph objects as input and outputs the second embedding information of the two sample graph objects as output. The multilayer perceptron sub-model takes the multi-kernel maximum average difference information (MMD) between the augmented embedding information of two sample graph objects as input and outputs the GW distance estimation value. The augmented embedding information includes the first embedding information and the second embedding information.

[0128] In one possible implementation, the loss function of the GW distance estimation model includes:

[0129]

[0130] Where, d ij It is the GW distance estimation value between the i-th and j-th sample graph objects output by the GW distance estimation model. It is the GW distance between the i-th and j-th sample graph objects, and N is the number of sample graph objects.

[0131] This disclosure also provides a device for calculating the GW distance between graph objects. Figure 4 This diagram illustrates a structural block diagram of a device for calculating the GW distance between graphical objects according to an embodiment of this disclosure. This device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 4 As shown, the device for calculating the GW distance between the objects in the graph includes:

[0132] The target acquisition module 401 is configured to acquire the adjacency matrix of two target graph objects to be processed.

[0133] The calculation module 402 is configured to calculate the similarity matrix of the target graph objects based on the adjacency matrix of the target graph objects;

[0134] The extraction module 403 is configured to perform spectral decomposition on the similarity matrix of the target graph object using a spectral method to extract the graph position encoding information of each vertex in the target graph object;

[0135] The distance estimation module 404 is configured to input the adjacency matrix and graph position encoding information of the target graph object into a pre-trained GW distance estimation model, execute the pre-trained GW distance estimation model, and obtain the GW distance estimation value output by the pre-trained GW distance estimation model.

[0136] The pre-trained GW distance estimation model can be trained based on the above-mentioned training method for estimating GW distance between graph objects.

[0137] The technical terms and features mentioned in this device embodiment are the same as or similar to those mentioned in the above method embodiment. For explanations and descriptions of the technical terms and features involved in this device, please refer to the explanations of the above method embodiment. They will not be repeated here.

[0138] This disclosure also discloses an electronic device. Figure 5 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0139] like Figure 5 As shown, the electronic device 500 includes a memory 501 and a processor 502, wherein the memory 501 is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor 502 to implement the method according to embodiments of the present disclosure.

[0140] Figure 6 A schematic diagram of the structure of a computer system suitable for implementing the methods of the embodiments of this disclosure is shown.

[0141] like Figure 6 As shown, the computer system 600 includes a processing unit 601, which can execute various processes described in the above embodiments according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage portion 608 into a random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the computer system 600. The processing unit 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0142] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed. The processing unit 601 can be implemented as a CPU, GPU, TPU, FPGA, NPU, etc.

[0143] In particular, according to embodiments of this disclosure, the methods described above can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising computer instructions that, when executed by a processor, implement the steps of the methods described above. In such embodiments, the computer program product can be downloaded and installed from a network via communication section 609, and / or installed from removable media 611.

[0144] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0145] The units or modules described in the embodiments of this disclosure can be implemented in software or programmable hardware. The described units or modules can also be located in a processor, and the names of these units or modules do not necessarily constitute a limitation on the unit or module itself.

[0146] In another aspect, this disclosure also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the electronic device or computer system described above; or it may be a standalone computer-readable storage medium not assembled into a device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to perform the methods described in this disclosure.

[0147] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

Claims

1. A method for training a model to infer the GW distance between graph objects, characterized in that, include: Obtain the adjacency matrix of multiple sample graph objects and the GW distance between any two sample graph objects; For each sample graph object, a similarity matrix of the sample graph object is calculated based on the adjacency matrix of the sample graph object; The similarity matrix of the sample graph objects is decomposed using a spectral method to extract the graph position encoding information of each vertex in the sample graph objects; Multiple training samples are constructed for model training to obtain a trained GW distance inference model. Each training sample includes input variables and their corresponding supervision information. The input variables include the adjacency matrix of two sample graph objects and graph position encoding information. The supervision information includes the GW distance between two sample graph objects.

2. The method according to claim 1, characterized in that, The step of calculating the similarity matrix of the sample graph objects based on their adjacency matrix includes: The similarity matrix C of the i-th sample image object is calculated using the following formula. i : C i = A i + I or C i = ShortestPath(A i ); Among them, A i Let I be the adjacency matrix of the i-th sample graph object, and let I be the adjacency matrix of the i-th sample graph object. i For identity matrices of the same shape, ShortestPath() is the shortest path algorithm.

3. The method according to claim 1, characterized in that, The step of performing spectral decomposition on the similarity matrix of the sample graph objects using spectral methods to extract the graph position encoding information of each vertex in the sample graph objects includes: The similarity matrix C of the i-th sample image object is calculated according to the following formula. i Perform singular value decomposition: Where SVD() is the singular value decomposition function, U i S is a matrix composed of left singular vectors. i V is a diagonal matrix whose singular values ​​are arranged in descending order. i It is a matrix composed of right singular vectors; The graph position encoding information E of each vertex in the i-th sample graph object is extracted according to the following formula. i :

4. The method according to claim 1, characterized in that, The GW distance estimation model includes a graph neural network sub-model, a Transformer sub-model, and a multilayer perceptron model; The graph neural network sub-model takes the adjacency matrix and graph position encoding information of two sample graph objects as input and outputs the first embedding information of the two sample graph objects as output. The Transformer sub-model takes the graph position encoding information of two sample graph objects as input and outputs the second embedding information of the two sample graph objects as output. The multilayer perceptron sub-model takes the multi-kernel maximum average difference information (MMD) between the augmented embedding information of two sample graph objects as input and outputs the GW distance estimation value. The augmented embedding information includes the first embedding information and the second embedding information.

5. The method according to claim 4, characterized in that, The loss function of the GW distance estimation model includes: Where, d ij It is the GW distance estimation value between the i-th and j-th sample graph objects output by the GW distance estimation model. It is the GW distance between the i-th and j-th sample graph objects, and N is the number of sample graph objects.

6. A method for calculating the GW distance between graph objects, characterized in that, include: Obtain the adjacency matrix of the two target graph objects to be processed; Calculate the similarity matrix of the target graph objects based on their adjacency matrix; The similarity matrix of the target graph object is decomposed using a spectral method to extract the graph position encoding information of each vertex in the target graph object; The adjacency matrix and graph position encoding information of the target graph object are input into the pre-trained GW distance estimation model, the pre-trained GW distance estimation model is executed, and the GW distance estimation value output by the pre-trained GW distance estimation model is obtained. The pre-trained GW distance estimation model is trained based on the method described in any one of claims 1-5.

7. A training device for a model to calculate the GW distance between graph objects, characterized in that, include: The data acquisition module is configured to acquire the adjacency matrix of multiple sample graph objects and the GW distance between any two sample graph objects. The similarity calculation module is configured to calculate the similarity matrix of each sample graph object based on the adjacency matrix of the sample graph object. The information extraction module is configured to perform spectral decomposition on the similarity matrix of the sample graph object using a spectral method to extract the graph position encoding information of each vertex in the sample graph object; The model training module is configured to construct multiple training samples for model training to obtain a trained GW distance inference model. Each training sample includes input variables and their corresponding supervision information. The input variables include the adjacency matrix of two sample graph objects and graph position encoding information. The supervision information includes the GW distance between the two sample graph objects.

8. A device for calculating the GW distance between objects in a graph, characterized in that, include: The target acquisition module is configured to acquire the adjacency matrix of two target graph objects to be processed. The calculation module is configured to calculate the similarity matrix of the target graph objects based on the adjacency matrix of the target graph objects; The extraction module is configured to perform spectral decomposition on the similarity matrix of the target graph object using a spectral method to extract the graph position encoding information of each vertex in the target graph object; The distance estimation module is configured to input the adjacency matrix and graph position encoding information of the target graph object into a pre-trained GW distance estimation model, execute the pre-trained GW distance estimation model, and obtain the GW distance estimation value output by the pre-trained GW distance estimation model. The pre-trained GW distance estimation model is trained based on the method described in any one of claims 1-5.

9. An electronic device, characterized in that, The method includes a memory and a processor, the memory being used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method of any one of claims 1 to 6.

10. A readable storage medium, characterized in that, It stores computer instructions that, when executed by a processor, implement the method described in any one of claims 1 to 6.