Graph neural network transfer learning method, apparatus and device, and storage medium
By pre-training the graph neural network with multi-domain graph topology and fine-tuning the target domain features, the problem of poor transfer performance of the GNN model on different graph data is solved, and effective task inference on unseen graph data is achieved, improving the model's transfer performance and computational efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-20
- Publication Date
- 2026-04-14
AI Technical Summary
Existing graph neural network (GNN) models have poor transfer performance when faced with new and unseen graph data, and are difficult to effectively adapt to the structural and node features of different graph data.
By acquiring graph topology information from multiple domains for unsupervised pre-training, a target network containing two initial GNN models is constructed. Feature encoding and fine-tuning are performed using real and pseudo adjacency matrices to achieve task inference in the target domain.
It improves the transfer performance of GNN models on unseen graph data, reduces dependence on target domain datasets, and enhances computational efficiency and task inference capabilities.
Smart Images

Figure CN121859949A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of deep learning technology, specifically relating to a transfer learning method, apparatus, device, and storage medium for graph neural networks. Background Technology
[0002] In today's digital age, graph data is becoming increasingly important due to its unique expressive power and wide range of applications. Graph data, through nodes and edges, effectively represents the complex relationships and interactions between entities, enabling the modeling of various aspects of the real world. This structure is reflected in numerous real-world scenarios, such as social networks, e-commerce systems, knowledge graphs, the Internet of Things, bioinformatics, and financial networks. In social networks, social relationships between individuals can be modeled as graph data, which can then be used to analyze social behavior and propagation patterns. In e-commerce systems, the relationships between users and products, and between products and merchants, can be modeled as graph data; the topological relationships between products and users can be used to build recommendation systems. In bioinformatics, the interactions between proteins can be modeled as graph data, helping scientists understand disease mechanisms and drug action pathways. In the financial sector, graph data can reveal market dynamics and risk diffusion processes. Therefore, the analysis and processing of graph data not only drives technological progress but also plays a vital role in the socio-economic landscape.
[0003] Graph Neural Networks (GNNs), as a deep learning framework specifically designed for processing graph data, have developed rapidly in recent years and demonstrated powerful performance. However, despite their remarkable achievements on single graph datasets, GNNs often exhibit poor transfer performance when faced with new or unseen graph data, due to the different structural features and node attributes that different graph datasets may possess. Summary of the Invention
[0004] To address the poor transfer learning performance of existing GNN models, this invention provides a method, apparatus, device, and storage medium for transfer learning of graph neural networks.
[0005] To achieve the above objectives, the present invention provides the following technical solution: A transfer learning method for graph neural networks, comprising: The first graph data containing graph topology information from multiple domains is obtained, and the GNN model is pre-trained in an unsupervised structure based on the first graph data to obtain the initial GNN model. Construct a target network containing two initial GNN models; The process involves acquiring second graph data containing node feature information within the target domain, constructing a true adjacency matrix based on the adjacency relationships of nodes in the second graph data, and constructing a pseudo adjacency matrix based on the node feature information; the target domain can be any one of multiple domains. The first feature vector is obtained by inputting the real adjacency matrix into the first initial GNN model of the target network, and the second feature vector is obtained by inputting the pseudo adjacency matrix into the second initial GNN model of the target network. The first and second feature vectors are summed to obtain the final output of the target network. The final output is compared with the real label of the second graph data, and the parameters of the second initial GNN model are fine-tuned. The finely tuned target network is applied to the target domain for task inference.
[0006] Optionally, the first graph data includes multiple subgraphs. An initial GNN model is obtained by performing unsupervised structure pre-training on the GNN model based on the first graph data, including: Each subgraph is input into the GNN encoder and encoded to obtain the representation vector of each subgraph. For each input subgraph, calculate the similarity with the corresponding positive sample and the similarity with the negative sample based on the obtained representation vector; The loss value is calculated based on similarity using the InfoNCE loss function. The parameters of the GNN encoder are then updated based on the loss value to obtain the initial GNN model.
[0007] Optionally, an initial GNN model is obtained by performing unsupervised structure pre-training on the GNN model based on the first graph data, including: Randomly select some nodes in the first image data to mask them; The first image data after occlusion is used as the input of the GNN model. The feature representation of the node is obtained by encoding through the GNN encoder, and the feature representation of the occluded node is restored through the GNN decoder. The feature representation restored by the GNN decoder is compared with the original features of the occluded node. The loss value is calculated using an autoregressive loss function. Based on the loss value, the parameters of the GNN encoder and GNN decoder are optimized to obtain the initial GNN model.
[0008] Optionally, a pseudo-adjacency matrix is constructed based on the feature information of the nodes, including: Calculate the similarity score between nodes based on the feature information of the nodes in the second graph data; A similarity matrix is constructed based on the similarity scores, and the similarity matrix is discretized by a preset threshold to obtain a pseudo-adjacency matrix.
[0009] Optionally, the target network further includes two alignment encoders: a first alignment encoder for aligning the features of the inputs of the first initial GNN model and the inputs of the second initial GNN model; and a second alignment encoder for aligning the features of the outputs of the first initial GNN model and the outputs of the second initial GNN model.
[0010] The present invention also provides a transfer learning apparatus for graph neural networks, comprising: The first acquisition module is used to acquire first graph data containing graph topology information in multiple domains, and to perform unsupervised structure pre-training on the GNN model based on the first graph data to obtain an initial GNN model. The building block is used to construct the target network, which contains two initial GNN models; The second acquisition module is used to acquire second graph data containing node feature information in the target domain, construct a true adjacency matrix based on the adjacency relationship of nodes in the second graph data, and construct a pseudo adjacency matrix based on the feature information of nodes; the target domain can be any one of multiple domains. The fine-tuning module is used to encode the first initial GNN model of the target network with the real adjacency matrix to obtain the first feature vector, and to encode the second initial GNN model of the target network with the pseudo adjacency matrix to obtain the second feature vector; the first feature vector and the second feature vector are vector-summed to obtain the final output of the target network; the final output is compared with the real label of the second graph data to fine-tune the parameters of the second initial GNN model. The application module is used to apply the finely tuned target network to the target domain for task inference.
[0011] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described transfer learning method.
[0012] The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described transfer learning method.
[0013] The transfer learning method for graph neural networks provided by this invention has the following beneficial effects: This invention pre-trains a GNN model on first graph data containing graph topology information from multiple domains, resulting in a general initial GNN model that learns the structural features of graph data and is applicable to multiple domains. Further, a target network comprising two initial GNN models is constructed. The first initial GNN model identifies the structural features of the target domain graph data, and the second initial GNN model identifies the node features. Node features are unique to each node, reflecting its inherent characteristics. Since the two initial GNN models are trained based on graph topology information, and the target domain can be any of the multiple domains, no fine-tuning of the first initial GNN model is needed to identify the structural features of the target domain graph data. Because the second initial GNN model identifies node features by converting node feature information into a pseudo-adjacency matrix, fine-tuning the second initial GNN model based on the difference between the target network's output and the true labels allows it to adapt to the characteristics of the nodes in the target domain dataset. The outputs of the first and second initial GNN models are vector-summed to obtain the total output, enabling the target network to adapt to the features of the target domain data and extract structural and node features, thereby performing task inference in the target domain. In summary, this invention obtains a general model through structural pre-training using graph data from multiple domains, and fine-tunes the general model for identifying node features using graph data from the target domain. This enables the GNN model to perform target domain task inference well even when faced with unseen graph data, thus improving the transfer performance of the GNN model. Attached Figure Description
[0014] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1 A schematic flowchart illustrating a transfer learning method for graph neural networks provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of a structure pre-training process provided in an embodiment of the present invention; Figure 3 A schematic diagram illustrating a model fine-tuning process provided in an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the application of a finely tuned target network to various downstream tasks, as provided in an embodiment of the present invention. Detailed Implementation
[0016] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.
[0017] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing the technical solution of this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0018] Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. In the description of this invention, it should be noted that, unless otherwise explicitly specified or limited, the terms "connected" or "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances. In the description of this invention, unless otherwise stated, "a plurality of" means two or more, which will not be elaborated further here.
[0019] To address the poor transfer learning performance of existing GNN models, this invention provides a transfer learning method for graph neural networks, such as... Figure 1 As shown, the method includes the following steps: S1: Obtain first graph data containing graph topology information from multiple domains, and perform unsupervised structure pre-training on the GNN model based on the first graph data to obtain the initial GNN model.
[0020] The graph topology information includes nodes and edges connecting nodes. Generally, graph data naturally presents the structure of nodes and edges. Nodes represent entities, and edges represent the relationships between entities. For example, in a social network, individuals are nodes, and interactions between individuals (such as friendships, private messages, or following each other) form edges.
[0021] Below, in conjunction with Figure 2 The pre-training process of the GNN model is introduced.
[0022] For example, such as Figure 2As shown, the data sources are first identified. These data sources can be product relationship graphs, social network graphs, or molecular graphs. The data sources come from various fields (e.g., e-commerce systems, social networks, bioinformatics, etc.). Then, this graph data is obtained through database queries, web crawling techniques, or application programming interfaces (APIs). The collected graph data can be stored and processed using graph processing frameworks (such as NetworkX, GraphX, etc.). These frameworks not only efficiently manage large-scale graph data but also provide rich graph algorithm libraries to support the training and evaluation of deep learning models.
[0023] Furthermore, graph topology information is extracted from graph data from multiple domains to obtain the first graph data. Specifically, the original graph data is parsed into a set of nodes and edges, and then the parsed node and edge information is used to construct the internal representation of the graph, which can be an adjacency matrix, and then feature information is filtered.
[0024] It should be understood that for large-scale graph data, directly training a model on the entire graph is usually not feasible. Therefore, it is advisable to first sample subgraphs from the large-scale graph data in each domain, that is, to extract representative small graphs or subgraphs, and then extract the topological structure information of each subgraph to obtain the first graph data, in order to reduce computational complexity and memory requirements. Therefore, the first graph data can contain multiple subgraphs.
[0025] Optionally, the subgraph sampling strategy can be random sampling, degree-based sampling, or community-structure-based sampling, etc. It should be understood that a suitable subgraph sampling strategy can help preserve key structural features of graph data, improving the learning efficiency and effectiveness of the model.
[0026] It should be understood that the diversity of graph data can improve the generalization performance of GNN models.
[0027] Furthermore, an unsupervised structural pre-training of the GNN model based on the first graph data is performed to obtain an initial GNN model for extracting graph structure information.
[0028] It should be understood that the goal of the structure pre-training phase is to learn general graph structure features from a large amount of unlabeled first-hand graph data. These features are not only applicable to specific graph datasets or tasks, but also generalizable to unseen graph data. Graph structure features include node connectivity, graph topology, and potential relationships between nodes, revealing the position and role of nodes in the network. Through structure pre-training, the initial GNN model can capture the core structural information of the graph data, providing a solid foundation for subsequent transfer learning.
[0029] In other words, a mapping function is learned through structural pre-training. This mapping function can map the structural features of nodes in graph data to a low-dimensional vector space, and these vectors can reflect the local network topological similarity of the nodes. It should be understood that this mapping function should satisfy the following two properties: (1) Structural similarity - nodes with similar local network topologies should be close to each other in the feature space. (2) Transferability - the learned feature representations should be applicable to new graphs and new nodes not seen during training.
[0030] Structural pre-training typically employs subgraph instance discrimination as its core task. The idea behind this task is to sample subgraphs for each node in the graph using strategies such as random walks, and treat each subgraph as an independent category. The goal is to learn to distinguish subgraph instances from different nodes.
[0031] Alternatively, the structure of the GNN model can be pre-trained using a contrastive learning method.
[0032] Contrastive learning is an unsupervised learning method that learns data representations by comparing the similarities and differences between data points. Within this learning framework, the model is trained to bring the representations of similar data points closer together (i.e., reduce the distance between them) while simultaneously pushing apart the representations of dissimilar data points (i.e., increase the distance between them).
[0033] For example, the process of model pre-training using a contrastive learning method is as follows: A1: Input each subgraph into the GNN encoder, and encode it to obtain the representation vector of each subgraph.
[0034] First, select a suitable GNN encoder, such as a Graph Isomorphism Network (GIN), to encode the input subgraph and obtain the corresponding graph representation vector.
[0035] A2: For each input subgraph, calculate the similarity with the corresponding positive sample and the similarity with the negative sample based on the obtained representation vector.
[0036] Positive samples of the input subgraph are graph data instances that are similar to or related to the input subgraph to some extent. They are usually subgraphs that come from the same original graph as the input subgraph but are obtained by sampling from different subgraphs. Since the two subgraphs come from the same original graph, they retain most of the structural information of the original graph and should have a close distance or high similarity in the representation space.
[0037] Negative samples of the input subgraph refer to graph data instances that are dissimilar or unrelated to the input subgraph. These are usually graph data that come from different original graphs or are completely unrelated to the input subgraph. These graph data are structurally significantly different from the input subgraph, and they should be far apart or have low similarity in the representation space.
[0038] For example, for each input subgraph, the similarity between its representation vector and its positive sample representation vector, as well as the similarity between its negative sample representation vector, are calculated. In this invention, the dot product is used to measure the similarity between two representation vectors. The larger the result of the dot product, the more similar the two vectors are.
[0039] A3: Calculate the loss value based on similarity using the InfoNCE loss function, update the parameters of the GNN encoder based on the loss value, and obtain the initial GNN model.
[0040] In this embodiment of the invention, the InfoNCE loss function is used to optimize the contrastive learning task. The InfoNCE loss function is used to measure the similarity and difference of representation vectors between different graph data. The formula for the InfoNCE loss function is as follows: ; in, This represents the loss function for contrastive learning. It is an exponential function. This represents the representation vector of the current input sample. The representation vector of a positive sample. Indicates temperature. This represents the representation vector of all samples, including both positive and negative samples.
[0041] Furthermore, the similarity is substituted into the InfoNCE loss function to obtain the loss value. Based on the loss value, the parameters of the GNN encoder are updated using an optimization algorithm (such as Adam). The goal of the optimization is to make the representation vectors of positive sample pairs closer and the representation vectors of negative sample pairs further apart. The process of iterative encoding and loss calculation is used to optimize the performance of the GNN encoder.
[0042] It should be understood that since the input to a GNN is not the feature information of the nodes, structural features need to be created as the embeddings of each node in order to be input into the GNN.
[0043] Alternatively, node features can be initialized using the degree of a node or its relative position in the subgraph (calculated via the Laplacian eigenvectors of the graph).
[0044] The Laplace matrix of a graph is defined as follows: ; Where I represents the identity matrix, Degree matrix, Let U represent the adjacency matrix of the graph, and U represent the eigenvector matrix of the graph's Laplacian matrix. This represents the transpose of the eigenvector matrix of the graph Laplacian matrix.
[0045] It should be understood that the eigenvectors of the Laplacian matrix carry structural information of the graph, and therefore can be used as embeddings of nodes.
[0046] Alternatively, autoregressive learning can be used for unsupervised structural pre-training of the GNN model. This method introduces an autoregressive loss function, allowing the model to learn valuable, semantically rich features by having nodes reconstruct their own information. The specific method is as follows:
[0047] In the first graph data, a portion of nodes are randomly masked and then encoded using a GNN encoder. The GNN encoder learns the interactions between nodes and the structural information of the graph to generate a low-dimensional embedding vector (i.e., feature representation) for each node. The feature representation learned by the GNN encoder is input into the GNN decoder, which then reconstructs the feature representation of the masked nodes. The decoder output is compared with the original features of the masked nodes, and the loss value is calculated using an autoregressive loss function to optimize the parameters of the GNN encoder and GNN decoder, thus obtaining the initial GNN model.
[0048] It should be understood that only those hidden nodes are considered in the autoregressive phase, and the autoregressive loss function is as follows: ; in, This represents the autoregressive loss function. This represents the set of nodes that are obscured. This represents the original node features, such as the Laplacian matrix mentioned above. This represents the node features that are restored by the decoder.
[0049] The embodiments of the present invention employ an unsupervised learning method for structural pre-training, which can extract effective graph structural features without relying on external annotations.
[0050] S2: Construct a target network containing two initial GNN models.
[0051] like Figure 3As shown, the target network contains two initial GNN models: a first initial GNN model with frozen parameters and a second initial GNN model with updatable parameters. The branches of the second initial GNN model also include a first alignment encoder and a second alignment encoder. The first alignment encoder aligns the input features of the first and second initial GNN models, and the second encoder aligns the output features of the first and second initial GNN models. It should be understood that the two alignment encoders are initialized to 0 during the model parameter initialization phase to better avoid cold start scenarios.
[0052] S3: Obtain the second graph data containing node feature information in the target domain, construct the true adjacency matrix based on the adjacency relationship of nodes in the second graph data, and construct the pseudo adjacency matrix based on the node feature information.
[0053] The target domain can be any of the following: e-commerce systems, social networks, bioinformatics, etc., and should belong to one of the multiple domains of the structure pre-training.
[0054] In graph data, an adjacency matrix is a matrix used to represent the connection relationships between vertices in the graph. It consists of 1s and 0s, where 1 indicates that there is a connection between nodes and 0 indicates that there is no connection between nodes. Generally, the actual adjacency matrix A can be directly obtained from graph data.
[0055] The characteristic information of a node is its attribute information, such as the category of the product, the properties of different atoms, and the occupation, gender, and age of a social network user.
[0056] pseudo-adjacency matrix It is a similarity matrix derived from the feature information of the nodes, which is then discretized. In other words, the node feature information is transformed into a representation with the same structure as the adjacency matrix.
[0057] Specifically, the similarity score between nodes is calculated based on the feature information of the nodes in the second image data. The formula is as follows: ; in, Represents a node and nodes Similarity score between them Represents a node Feature information, Represents a node The characteristic information.
[0058] Based on similarity scores, the degree of matching between each node in the graph can be obtained, thus allowing the construction of a similarity matrix. The similarity matrix Threshold discretization is used to obtain a pseudo-adjacency matrix. If the value is higher than a preset threshold, it is considered that two nodes in the pseudo-adjacency matrix are connected by an edge. The formula is as follows: ; in, Represents a node and nodes Similarity score between them This indicates a preset threshold.
[0059] S4. Input the real adjacency matrix into the first initial GNN model of the target network to encode the first feature vector, and input the pseudo adjacency matrix into the second initial GNN model of the target network to encode the second feature vector; sum the first feature vector and the second feature vector as the final output of the target network; compare the final output with the real label of the second graph data, and fine-tune the parameters of the second initial GNN model.
[0060] It should be understood that a general GNN model has been obtained through the pre-training step of S1. The next step is to fine-tune the target network constructed in S2 using a second initial GNN model. The target network can then perform inference on downstream tasks and achieve good results.
[0061] This invention uses the concept of conditional injection to incorporate feature information of the target domain graph data. It utilizes a conditional control mechanism to integrate the feature information of the graph data into the pre-trained model and fine-tunes the model parameters to adapt to the specific node features of the target domain.
[0062] Specifically, such as Figure 3 As shown, the true adjacency matrix A of the second graph data is input into the first initial GNN model, and the pseudo adjacency matrix is... The second initial GNN model is input, and the inputs of both are aligned by the first alignment encoder. The first initial GNN model encodes the true adjacency matrix A to obtain the first feature vector, and the second initial GNN model encodes the pseudo adjacency matrix A. The first feature vector is encoded to obtain the second feature vector. The outputs of the two are aligned by the second alignment encoder. Then, the first feature vector and the second feature vector are summed as the final output of the target network, so as to integrate the feature information of the target domain graph data into the pre-trained model.
[0063] Furthermore, the final output of the target network is compared with the true labels of the second graph data, and the parameters of the second initial GNN model and the two aligned encoders are fine-tuned. That is, the loss value is calculated through the loss function, and the parameters are updated by backpropagation based on the loss value until the preset performance standard is reached, thus obtaining the fine-tuned target network.
[0064] S5: Apply the finely tuned target network to the target domain for task inference.
[0065] Through S4, the target network has been fine-tuned in the target domain. Downstream task inference is the process of using the target network to perform specific tasks, such as node classification, link prediction, graph classification, and graph clustering.
[0066] like Figure 4 As shown, different tasks can be transformed into subgraph encoding tasks. For example, graph classification tasks can take the entire graph as input, link prediction tasks take the subgraph obtained by random walks between two nodes to be predicted as input, and graph clustering tasks are similar to graph classification tasks.
[0067] The following introduces four commonly used tasks and their reasoning methods: Node classification aims to predict the label or category of individual nodes in a graph. During the inference phase, the input nodes are first sampled from a subgraph centered on the inference node, then processed by the target network to output the probability of each node belonging to each category. Common applications include user role classification in social networks, article topic classification in literature networks, and node anomaly detection. It should be understood that a node's category depends not only on its own features but also on its neighboring nodes and the overall network structure. Therefore, node classification requires considering both node features and structural features simultaneously.
[0068] Link prediction aims to predict whether an edge should exist between any two nodes in a graph. This is very useful in fields such as recommender systems and social network analysis. During inference, node pairs are typically sampled from a subgraph, encoded, and then the probability of a link existing between these node pairs is predicted through the target network. It should be understood that predicting whether a link exists between two nodes requires considering their structural relationships (such as path length, number of common neighbors, etc.) and the similarity between node features.
[0069] Graph classification determines the category of an entire graph and is primarily used in scientific computing fields such as molecular structure recognition. During the inference phase, the entire graph serves as input, and the target network outputs the probability that the graph belongs to each category. Graph classification tasks typically require the model to capture the global structural features of the entire graph.
[0070] Graph clustering aims to group nodes in a graph into multiple groups or communities based on their characteristics and connection patterns, and is a common need in network analysis and data mining. The reasoning process involves using a model to evaluate the similarity between nodes, and then clustering the nodes based on these similarities.
[0071] During the entire model transfer process, the main bottleneck limiting speed lies in model fine-tuning. To address the issue of long latency, an inference acceleration method is adopted. First, an initial GNN model is used to infer the structural features of a given input subgraph. Taking a node classification task as an example, if the pre-trained initial GNN model for the current structure already achieves good classification performance, model fine-tuning will not be performed, thus accelerating inference. The judgment mechanism uses the classification confidence—entropy—between the current and trained models for evaluation.
[0072] The formula is as follows: ; in, Represents information entropy. Indicates the predicted probability of the current category. Represents a logarithmic function.
[0073] If the entropy of the current object is lower than a manually set threshold, there is no need to fine-tune the model. This approach significantly reduces computational overhead, thereby achieving low inference latency and high throughput.
[0074] In the above embodiments, the present invention obtains a general model through structural pre-training using graph data from multiple domains, and fine-tunes the general model for identifying node features using graph data from the target domain. This enables the GNN model to perform target domain task inference well even when faced with unseen graph data, thus improving the transfer performance of the GNN model. In addition, by fine-tuning the second initial GNN model, the present invention reduces the need for retraining, effectively improves computational efficiency, and greatly reduces the dependence on labeled data.
[0075] Based on the same inventive concept, embodiments of the present invention also provide a transfer learning apparatus for graph neural networks, exemplarily comprising: The first acquisition module is used to acquire first graph data containing graph topology information from multiple domains, and to perform unsupervised structure pre-training on the GNN model based on the first graph data to obtain the initial GNN model.
[0076] The building block is used to construct the target network, which contains two initial GNN models.
[0077] The second acquisition module is used to acquire second graph data containing node feature information in the target domain, construct a true adjacency matrix based on the adjacency relationship of nodes in the second graph data, and construct a pseudo adjacency matrix based on the feature information of nodes; the target domain can be any one of multiple domains.
[0078] The fine-tuning module is used to encode the first initial GNN model of the target network with the real adjacency matrix to obtain the first feature vector, and to encode the second initial GNN model of the target network with the pseudo adjacency matrix to obtain the second feature vector; the first feature vector and the second feature vector are vector-summed to obtain the final output of the target network; the final output is compared with the real label of the second graph data to fine-tune the parameters of the second initial GNN model.
[0079] The application module is used to apply the finely tuned target network to the target domain for task inference.
[0080] The modules in the aforementioned graph neural network transfer learning device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0081] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps in the embodiment of the graph neural network transfer learning method. Specific implementation methods can be found in the method embodiments, and will not be repeated here.
[0082] Furthermore, the present invention also provides a non-transitory computer-readable storage medium containing instructions on which a computer program is stored. For example, a memory containing instructions that can be executed by a processor of a computer device to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc. When the computer program is executed by the processor, it can implement the steps in the transfer learning method embodiment of the graph neural network. Specific implementation methods can be found in the method embodiments, which will not be repeated here.
[0083] Those skilled in the art will understand that embodiments of the present invention can provide methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0084] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0085] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0086] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0087] It should be noted that the specific embodiments described above enable those skilled in the art to more fully understand the present invention, but do not limit the present invention in any way. Therefore, although the present invention has been described in detail in this specification and embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention; and all technical solutions and improvements that do not depart from the spirit and scope of the present invention are covered within the protection scope of the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims. Any simple variations or equivalent substitutions of technical solutions that can be readily obtained by those skilled in the art within the scope of the technology disclosed in the present invention are within the protection scope of the present invention.
Claims
1. A transfer learning method for graph neural networks, characterized in that, include: The first graph data containing graph topology information from multiple domains is obtained, and the GNN model is pre-trained in an unsupervised structure based on the first graph data to obtain the initial GNN model. Construct a target network containing two initial GNN models; Obtain second graph data containing node feature information in the target domain, construct a true adjacency matrix based on the adjacency relationship of nodes in the second graph data, and construct a pseudo adjacency matrix based on the node feature information; The target domain can be any one of multiple domains; The first feature vector is obtained by inputting the real adjacency matrix into the first initial GNN model of the target network, and the second feature vector is obtained by inputting the pseudo adjacency matrix into the second initial GNN model of the target network. The first and second feature vectors are summed to obtain the final output of the target network. The final output is compared with the real label of the second graph data, and the parameters of the second initial GNN model are fine-tuned. The finely tuned target network is applied to the target domain for task inference.
2. The transfer learning method for graph neural networks according to claim 1, characterized in that, The first graph data includes multiple subgraphs. An initial GNN model is obtained by performing unsupervised structure pre-training based on the first graph data, including: Each subgraph is input into the GNN encoder and encoded to obtain the representation vector of each subgraph. For each input subgraph, calculate the similarity with the corresponding positive sample and the similarity with the negative sample based on the obtained representation vector; The loss value is calculated based on similarity using the InfoNCE loss function. The parameters of the GNN encoder are then updated based on the loss value to obtain the initial GNN model.
3. The transfer learning method for graph neural networks according to claim 1, characterized in that, Based on the data in the first graph, an unsupervised structured pre-training of the GNN model is performed to obtain an initial GNN model, including: Randomly select some nodes in the first image data to mask them; The first image data after occlusion is used as the input of the GNN model. The feature representation of the node is obtained by encoding through the GNN encoder, and the feature representation of the occluded node is restored through the GNN decoder. The feature representation restored by the GNN decoder is compared with the original features of the occluded node. The loss value is calculated using an autoregressive loss function. Based on the loss value, the parameters of the GNN encoder and GNN decoder are optimized to obtain the initial GNN model.
4. The transfer learning method for graph neural networks according to any one of claims 1-3, characterized in that, Construct a pseudo-adjacency matrix based on the node's feature information, including: Calculate the similarity score between nodes based on the feature information of the nodes in the second graph data; A similarity matrix is constructed based on the similarity scores, and the similarity matrix is discretized by a preset threshold to obtain a pseudo-adjacency matrix.
5. The transfer learning method for graph neural networks according to any one of claims 1-3, characterized in that, The target network also includes two alignment encoders. The first alignment encoder is used to align the features of the inputs of the first initial GNN model and the inputs of the second initial GNN model. The second alignment encoder is used to align the features of the outputs of the first initial GNN model and the second initial GNN model.
6. A transfer learning device for graph neural networks, characterized in that, include: The first acquisition module is used to acquire first graph data containing graph topology information in multiple domains, and to perform unsupervised structure pre-training on the GNN model based on the first graph data to obtain an initial GNN model. The building block is used to construct the target network, which contains two initial GNN models; The second acquisition module is used to acquire second graph data containing node feature information in the target domain, construct a real adjacency matrix based on the adjacency relationship of nodes in the second graph data, and construct a pseudo adjacency matrix based on the feature information of nodes. The target domain can be any one of multiple domains; The fine-tuning module is used to encode the first initial GNN model of the target network with the real adjacency matrix to obtain the first feature vector, and to encode the second initial GNN model of the target network with the pseudo adjacency matrix to obtain the second feature vector; the first feature vector and the second feature vector are vector-summed to obtain the final output of the target network; the final output is compared with the real label of the second graph data to fine-tune the parameters of the second initial GNN model. The application module is used to apply the finely tuned target network to the target domain for task inference.
7. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the transfer learning method of the graph neural network according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the transfer learning method of the graph neural network according to any one of claims 1 to 5.