A method for constructing a multi-layer perceptron-based graph classification model and a graph classification method
By using the knowledge distillation method to pass the topological information of the graph neural network to the multilayer perceptron, the problem of high computational complexity of graph neural networks is solved, and efficient graph classification in large-scale graph data is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIDIAN UNIV
- Filing Date
- 2023-10-30
- Publication Date
- 2026-06-26
Smart Images

Figure CN117473315B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence, specifically relating to a graph classification model construction method and a graph classification method based on a multilayer perceptron. Background Technology
[0002] Graph data is a widely existing data structure in the real world. It consists of nodes and edges, used to describe the relationships or connections between nodes. For example, users in a social network can be seen as nodes, and their interactions can be seen as edges. The complexity and irregularity of graph data structures make them rich in information, but they also bring challenges to algorithm design and implementation.
[0003] In recent years, research on graph data has become a hot topic. Currently, research on graph classification methods mainly includes methods based on similarity calculation and methods based on Graph Neural Networks (GNNs). Similarity calculation-based methods classify graphs by calculating the similarity of paired graphs, including graph kernel methods and graph matching methods. Graph kernel methods primarily calculate graph similarity based on the definition of a graph kernel. Their common idea is to decompose the graph into some substructure and calculate the similarity of different graph substructures to perform graph classification. Graph matching methods consider calculating similarity scores between graphs based on cross-graph factors. Graph Neural Networks (GNNs) are deep learning algorithms for graph data. They can perform classification tasks by learning the feature representations of nodes and edges. Specifically, GNN-based methods use deep learning to model graph data, extracting and summarizing the graph's features using structural and node feature information to obtain a representation of the entire graph for classification.
[0004] Currently, graph neural networks have wide applications in various fields, including social networks. For example, in social networks, they can be classified based on user behavior, interests, and characteristics to help social network platforms better understand user needs and provide personalized content and services.
[0005] However, due to the massive scale of graph data in the real world, graph neural network algorithms are difficult to run. This is because graph data is sparse and irregular, leading to high computational complexity. Therefore, in large-scale industrial applications, multilayer perceptrons (MLPs) are still the primary deployment method. MLPs are a classic neural network model capable of extracting and classifying high-dimensional features from input data. While MLPs offer high computational efficiency, they cannot utilize the structural information of graph data, resulting in lower accuracy compared to graph neural networks. Therefore, a low-complexity and fast graph classification method is urgently needed. Summary of the Invention
[0006] To address the aforementioned problems in the prior art, this invention provides a graph classification model construction method based on a multilayer perceptron, a graph classification method based on a multilayer perceptron, an apparatus, an electronic device, and a storage medium. The technical problem to be solved by this invention is achieved through the following technical solutions:
[0007] In a first aspect, embodiments of the present invention provide a method for constructing a graph classification model based on a multilayer perceptron, the method comprising:
[0008] For a classification task in the required application scenario, a training set is constructed by acquiring several graph data; wherein, at least some of the graph data in the training set has category labels;
[0009] The selected graph neural network is trained using the training set, and the trained graph neural network is used as the teacher network. The classification results corresponding to the graph neural network are saved.
[0010] The selected multilayer perceptron is used as the student model. Based on the training set, the teacher network, and the corresponding classification results, the student model is trained using the knowledge distillation method. The trained student model is then used as a graph classification model to classify the remaining graph data for the required application scenario.
[0011] In one embodiment of the present invention, the desired application scenario includes:
[0012] Social scenarios.
[0013] In one embodiment of the present invention, the selected graph neural network includes:
[0014] GraphSAGE and GIN.
[0015] In one embodiment of the present invention, the selected multilayer perceptron includes:
[0016] A multi-layered, fully connected network.
[0017] In one embodiment of the present invention, training the student model using a knowledge distillation method based on the training set, the teacher network, and the corresponding classification results includes:
[0018] The input dataset is composed of feature data from the graph data in the training set;
[0019] Based on the input dataset, the category labels of the data in the input dataset, the classification results corresponding to the graph neural network, and the preset loss function, the student model is trained using the knowledge distillation method until the student model converges, thus obtaining the trained student model.
[0020] In one embodiment of the present invention, the preset loss function is:
[0021]
[0022] Where v represents the graph data; V represents the training set; V L This refers to the set of graph data with category labels in the training set; This represents the classification result of the student model corresponding to the graph data v; y v Represents the category label of the graph data v; z v This represents the classification result of the teacher model corresponding to the graph data v; L label L represents the loss between the true class label and the classification result of the student model; teacher λ represents the loss between the classification results of the student model and the classification results of the teacher model; λ represents the weight parameter.
[0023] Secondly, embodiments of the present invention provide a graph classification method based on a multilayer perceptron, the method comprising:
[0024] Obtain target image data to be classified in social scenarios;
[0025] The feature data in the target graph data is input into a pre-trained graph classification model to obtain the corresponding classification result; wherein the graph classification model is obtained by the graph classification model construction method based on multilayer perceptron described in the first aspect.
[0026] Thirdly, embodiments of the present invention provide a graph classification device based on a multilayer perceptron, the device comprising:
[0027] The graph data acquisition module is used to acquire target graph data to be classified in social scenarios.
[0028] The classification module is used to input the feature data in the target graph data into a pre-trained graph classification model to obtain the corresponding classification result; wherein the graph classification model is obtained according to the graph classification model construction method based on multilayer perceptron described in the first aspect.
[0029] Fourthly, embodiments of the present invention provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0030] The memory is used to store computer programs;
[0031] When the processor executes the program stored in the memory, it implements the steps of the graph classification method based on a multilayer perceptron provided in the embodiments of the present invention.
[0032] Fifthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the graph classification method based on a multilayer perceptron provided in the embodiments of the present invention.
[0033] The beneficial effects of this invention are as follows: Graph neural networks (GNNs) perform excellently when processing complex graph data and structures, but the irregularity and dynamism of graph structures make computation and optimization of GNNs on large-scale or dynamic graphs more complex. While multilayer perceptron (MPB) models are more efficient and easier to use when processing traditional Euclidean data, their capabilities are limited when dealing with complex graph relationships and topologies. The graph classification model provided in this invention combines the advantages of both MPBs and GNNs. It uses knowledge distillation to transfer topological, feature, and other useful information extracted from graph data by the GNN to the MPB. Since the MPB trained using knowledge distillation is used for classification, it is free from graph dependency during inference, allowing it to maintain competitive accuracy. Simultaneously, it reduces data dependency issues in the GNN inference process, significantly reducing computational complexity and increasing inference speed while maintaining high accuracy. Therefore, it can perform prediction and generalization like traditional neural networks. Furthermore, through offline knowledge distillation, the parameters of the student model are optimized, achieving higher accuracy and faster inference speed, similar to a GNN used as a teacher model. This makes it easier to deploy in production environments and suitable for time-constrained engineering deployments.
[0034] The graph classification model provided in this embodiment of the invention can be used to classify graph data to be classified in social scenarios, which can simultaneously ensure classification accuracy and classification speed. Attached Figure Description
[0035] Figure 1 This is a flowchart illustrating a graph classification model construction method based on a multilayer perceptron provided in an embodiment of the present invention.
[0036] Figure 2 Example diagram of data structure for graph data;
[0037] Figure 3 This is a flowchart illustrating a graph classification method based on a multilayer perceptron provided in an embodiment of the present invention.
[0038] Figure 4 This is a schematic diagram of the structure of a graph classification device based on a multilayer perceptron provided in an embodiment of the present invention;
[0039] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] Currently, in research on graph classification methods, Borgwardt et al. proposed using the Floyd-Warshall algorithm to obtain the shortest path graph in the paper "Borgwardt KM, Kriegel HP. Shortest-path kernels on graphs. In: Proc. of the Fifth IEEE Int'l Conf. on Data Mining (ICDM'05). Houston: IEEE, 2005.8. [doi:10.1109 / ICDM.2005.132]". The more shortest paths of the same length there are, the higher the similarity of the graph. In the paper "Li YJ, Gu CJ, Dullien T, Vinyals O, Kohli P. Graph matching networks for learning the similarity of graph structured objects. In: Proc. of the 36th Int'l Conf. on Machine Learning. California: PMLR, 2019. 3835-3845.", Li et al. proposed the Graph Matching Network (GMN) model. This model considers not only the information of nodes within each graph but also the information of nodes across graphs, which can ensure that when the matching degree of two graphs is high, the learned representations are more similar and the similarity score is higher. Bai et al. proposed a fast graph similarity computation model, SimGNN, in the paper "Bai YS, Ding H, Bian S, Chen T, Sun YZ, Wang W. SimGNN: A neural network approach to fast graph similarity computation. In: Proc. of the 12th ACM Int'l Conf. on Web Search and Data Mining. Phoenix: ACM, 2019. 384-392. [doi:10.1145 / 3289600.3290967]". This model not only calculates the node similarity vector across graphs, but also the similarity vector between two graph representations, and then uses these two similarity vectors to calculate the similarity score between the two graphs.Gilmer et al., in their paper "Gilmer J, Schoenholz SS, Riley PF, Vinyals O, Dahl GE. Neural message passing for quantum chemistry. In: Proc. of the 34th Int'l Conf. on Machine Learning. Sydney: JMLR, 2017. 1263-1272.", proposed a general framework for message-passing neural networks (MPNNs), formalizing the convolution process into two functions: message passing and node information updating. Xu et al., in their paper "Xu K, Hu W, Leskovec J, Jegelka S. How powerful are graph neural networks?. In: Proc. of the Int'l Conf. on Learning Representations (ICLR). NewOrleans: OpenReview.net, 2019.", pointed out that any message-passing graph convolutional neural network based on 1-WL will not have stronger expressive power than 1-WL, and 1-WL itself has limited expressive power and cannot accurately classify many non-isomorphic graphs. Ma et al. proposed the EigenPooling model in the paper "Ma Y, Wang SH, Aggarwal CC, Tang JL. Graph convolutional networks with eigenpooling. In: Proc. of the 25th ACM SIGKDD Int'l Conf. on Knowledge Discovery & Data Mining. Singapore: ACM, 2019. 723-731. [doi:10.1145 / 3292500.3330982]". This model uses spectral clustering to obtain a hard allocation matrix and then partitions the subgraph based on this matrix.The differentiable pooling (DiffPool) model proposed by Ying et al. in the paper "Ying R, You JX, Morris C, Ren X, Hamilton WL, Leskovec J. Hierarchical graph representation learning with differentiable pooling. In: Proc. of the 32nd Int'l Conf. on Neural Information Processing Systems. Montréal: Curran Associates Inc., 2018. 4805-4815" obtains a soft clustering assignment matrix through parameter learning for graph classification.
[0042] Because graph data is often enormous, containing a vast number of nodes and edges, processing large-scale graph data is a very challenging problem. Current graph classification techniques are still limited in their ability to handle large-scale graph data. Existing techniques typically require extensive computational operations, such as similarity calculation, node feature extraction, graph convolution, and graph attention. The high complexity of these computational operations often results in slow training and inference speeds for graph classification techniques, which is unacceptable for latency-constrained applications.
[0043] Moreover, in large-scale industrial applications, multilayer perceptrons (MPBs) are still the primary deployment method. While MPBs offer high computational efficiency, they cannot utilize the structural information of graph data, resulting in lower accuracy compared to graph neural networks. Therefore, improving the accuracy of MPBs to enable graph data classification would be of significant importance. Based on this, this invention provides a method for constructing graph classification models based on MPBs, which can be used to construct and train graph classification models for desired application scenarios. Furthermore, for the specific application scenario of social networking, a method, device, electronic device, and storage medium based on MPBs for graph classification are proposed. The following provides a detailed description of the embodiments of this invention.
[0044] In a first aspect, embodiments of the present invention provide a method for constructing a graph classification model based on a multilayer perceptron, such as... Figure 1 As shown, the method may include the following steps:
[0045] S1, For the classification task of the required application scenario, obtain several graph data to form a training set;
[0046] In this training set, at least some of the graph data has category labels;
[0047] Graph data is a data structure that represents relationships between objects. It consists of nodes and edges. Nodes represent objects, and edges represent relationships between objects, such as... Figure 2 As shown. Nodes can represent various entities, such as people, objects, events, etc., while edges represent connections or associations between nodes. Due to different application scenarios and needs, graph data can be used to describe various complex relationship networks. In this embodiment of the invention, the application scenario can include a social scenario, and the corresponding relationship network is a social network. Accordingly, the classification task of graph data can be:
[0048] Community Classification: Graph classification can be used to identify communities or groups within social networks. Community classification aims to divide interconnected nodes in a network into groups with similar attributes or shared interests. Through graph classification algorithms, nodes in a network can be divided into different communities, thus helping people understand the organizational structure of social networks and the relationships between users.
[0049] User segmentation: Graph classification can be used to categorize users within social networks. By analyzing user behavior, relationships, and interests within a social network, users can be divided into different categories or groups. This is extremely useful for tasks such as personalized recommendations, social advertising targeting, and user relationship analysis.
[0050] Sentiment Classification: Graph classification can be used to classify the sentiment of text or user-generated content on social networks. By analyzing textual information such as posts, comments, or tweets published by users on social networks, their sentiment orientation can be determined, such as positive, negative, or neutral. This is of great significance for public opinion analysis, sentiment monitoring, and brand reputation management.
[0051] Of course, the graph data in this embodiment can describe relationship networks that are not limited to social networks, but can also include transportation networks, knowledge graphs, molecular structures, biochemical networks, etc. Graph data can capture the interactions and dependencies between objects, providing a rich data representation. In graph data, the attributes of nodes and edges can contain various information. Node attributes describe the characteristics of nodes, such as a person's age or an object's color. Edge attributes describe the relationship characteristics between nodes, such as friend relationships in a social network or chemical bonds in a molecular structure.
[0052] In this embodiment of the invention, for classification tasks in the required application scenarios, it is necessary to acquire a number of graph data, and to acquire the category label of each graph data, that is, the true category label of the graph data, together with the acquired unlabeled graph data to form a training set.
[0053] S2, the selected graph neural network is trained using the training set, the trained graph neural network is used as the teacher network, and the classification results corresponding to the graph neural network are saved.
[0054] In this embodiment of the invention, appropriate graph neural networks and multilayer perceptrons are selected based on the type, scale, and characteristics of the data in the training set.
[0055] In one optional implementation, the selected graph neural network may include:
[0056] GraphSAGE and GIN.
[0057] Those skilled in the art will understand that GraphSAGE (SAmple and aggreGatE) and GIN (Graph Isomorphism Network) are two existing graph neural networks. Of course, the graph neural networks in the embodiments of this invention are not limited to these.
[0058] In S2, the selected graph neural network is trained using the training set. This can be achieved using existing graph neural network training methods, which will not be described in detail here. After training, a trained graph neural network with good classification performance for the required application scenario classification task can be obtained. The trained graph neural network can accurately classify graph data by extracting useful features from the data, including graph topology information and feature information.
[0059] Furthermore, in S2, the classification results obtained by the graph neural network for training the training set can be retained, including the confidence of each graph data in the training set belonging to each category, the intermediate features of the graph neural network, and the parameters obtained after training, for use in the subsequent knowledge distillation process.
[0060] S3, using the selected multilayer perceptron as the student model, and based on the training set, the teacher network, and the corresponding classification results, the student model is trained using the knowledge distillation method to obtain the trained student model as a graph classification model, which is used to classify the remaining graph data of the required application scenario.
[0061] Optionally, in this embodiment of the invention, the selected multilayer perceptron may include:
[0062] A multi-layered, fully connected network.
[0063] Of course, the multilayer perceptron selected in the embodiments of the present invention is not limited to this; for example, it can also be a related lightweight neural network, etc., and no limitation is made here.
[0064] Those skilled in the art will understand that a "teacher model" refers to a complete model that can provide guidance information for the model to be trained, typically a model with high structural complexity and good performance; in contrast, a "student model" is typically a model with low complexity but relatively poor performance. In this embodiment of the invention, the trained graph neural network is used as the teacher model, and the selected multilayer perceptron is used as the student model. "Knowledge distillation" refers to utilizing the "teacher model's" ability to process complex data and extract features to "distill" the key information of the "teacher model" into a smaller, more efficient "student model" to guide the training and learning of the "student model," including its prediction and internal feature representation, thereby achieving performance similar to a larger model, but at the cost of fewer computational resources and faster processing speed.
[0065] In this embodiment of the invention, the knowledge distillation process of a multilayer perceptron (MLP) using a graph neural network enables a small MLP to learn knowledge from a large graph neural network, thereby improving the MLP's ability to represent and classify graph data. Through distillation training, the student model learns feature-related knowledge from the input dataset, while the teacher model "transmits" the topological structure, feature information, and other useful information of the graph it has learned to the student model.
[0066] Specifically, in S3, training the student model using knowledge distillation based on the training set, the teacher network, and the corresponding classification results may include:
[0067] 1) The input dataset is composed of the feature data of the graph data in the training set;
[0068] Those skilled in the art will understand that graph data may include structural data and feature data, where feature data represents the features corresponding to nodes.
[0069] In this embodiment of the invention, the data for the student model still comes from the training set used to train the graph neural network, but only the structured data is used.
[0070] 2) Based on the input dataset, the category labels of the data in the input dataset, the classification results corresponding to the graph neural network, and the preset loss function, the student model is trained using the knowledge distillation method until the student model converges, thus obtaining the trained student model.
[0071] The training process for this step can be understood by referring to the existing knowledge distillation training process. In this step, the same training data is used to transmit the relationship and interaction information between the nodes of the "teacher model" as knowledge to the "student model". Since the teacher model can extract useful information such as topological information and feature information, while the input of the student model only contains the feature information of the nodes and does not contain the topological structure information of the graph, the student model does not have the dependency on the graph and can use the structural information of the graph data without having to use it. However, it can still use the useful information transmitted by the graph neural network as the teacher model. Therefore, it can improve the accuracy of the multilayer perceptron and make it have a faster inference speed.
[0072] It is understood that the training process requires the use of a loss function. In this embodiment of the invention, the preset loss function is:
[0073]
[0074] Where v represents the graph data; V represents the training set; V L This refers to the set of graph data with category labels in the training set; This represents the classification result of the student model corresponding to the graph data v; y v Represents the category label of the graph data v; z v This represents the classification result of the teacher model corresponding to the graph data v; L label The loss representing the difference between the true class label and the classification result of the student model can be achieved using common loss functions such as cross-entropy, to ensure consistency between the student model's classification result and the true class label; L teacher The loss represents the difference between the classification results of the student model and the classification results of the teacher model. Methods such as KL divergence can be used to ensure the consistency between the classification results of the student model and the features extracted by the graph neural network. λ represents the weight parameter, which can be used to adjust the ratio of the two losses.
[0075] During the training process described above, the parameters of the student model are updated using the backpropagation algorithm and preset optimization methods, such as stochastic gradient descent. The student model is trained through continuous optimization until it converges, thus completing the training of the student model.
[0076] For details on the specific process of training the student model using the knowledge distillation method based on the training set, the teacher network, and the corresponding classification results, please refer to relevant technologies; it will not be described in detail here.
[0077] Through the above steps S1 to S3, a trained student model can be obtained as a graph classification model. Optionally, the method for constructing the graph classification model based on a multilayer perceptron may further include:
[0078] The graph classification model is deployed to computing devices in the desired application scenarios.
[0079] The computing devices include computers, servers, and other devices with computing functions.
[0080] Optionally, the graph classification model can be deployed to a specific device in a real production environment. The specific device can have both graph data acquisition and classification calculation functions. For example, the specific device can be an embedded device such as a router or sensor, thereby outputting classification results for graph data in the real production environment.
[0081] In this embodiment of the invention, after constructing a graph classification model for a specific application scenario, if the input graph data differs significantly from the original graph data in the application scenario during the actual graph data classification process, it is considered as new data. When the proportion of new data to the current input graph data exceeds a preset proportion (e.g., 20%), the current graph classification model cannot guarantee a good classification result for the new data, and its accuracy may decrease. In this case, it is necessary to retrain the classification model using the new data, that is, to execute steps S1 to S3 again using all graph data containing the new data to obtain a new classification model.
[0082] In the graph classification model construction method based on multilayer perceptron provided in this embodiment of the invention, firstly, for the classification task of the required application scenario, a training set is formed by acquiring several graph data with category labels; then, the selected graph neural network is trained using the training set, and the trained graph neural network is used as the teacher network, and the classification results corresponding to the graph neural network are saved; finally, the selected multilayer perceptron is used as the student model, and the student model is trained using the knowledge distillation method based on the training set, the teacher network, and the corresponding classification results, to obtain the trained student model as a graph classification model, which is used to classify the remaining graph data of the required application scenario. Graph neural networks (GNNs) excel at handling complex graph data and structures, but the irregularity and dynamism of graph structures make computation and optimization of GNNs on large-scale or dynamic graphs more complex. While multilayer perceptrons (MPBs) are more efficient and easier to use when processing traditional Euclidean data, their capabilities are limited when dealing with complex graph relationships and topologies. This invention combines the advantages of both MPBs and GNNs, employing knowledge distillation to transfer topological, feature, and other useful information extracted from graph data by the GNN to the MPB. Because the MPB trained using knowledge distillation is free from graph dependencies during inference, it maintains competitive accuracy while reducing data dependencies in the GNN's inference process. This significantly reduces computational complexity and increases inference speed while maintaining high accuracy, allowing for prediction and generalization like traditional neural networks. Furthermore, offline knowledge distillation optimizes the parameters of the student model, enabling it to achieve higher accuracy and faster inference speed, similar to a GNN used as a teacher model. This makes it easier to deploy in production environments and suitable for time-constrained engineering deployments.
[0083] To facilitate understanding of the concept and effects of the method of the present invention, it is briefly described below by comparing it with relevant prior art.
[0084] In existing technologies, most research using similar methods focuses on node classification tasks. Node classification emphasizes classifying each node in a graph, primarily focusing on how to aggregate and transfer node features and information from neighboring nodes to generate a node-level representation. Graph classification, on the other hand, requires classifying the entire graph, which necessitates considering how to aggregate and integrate the structure and features of the entire graph to generate a graph-level representation.
[0085] Specifically, for the teacher model (graph neural network) in this embodiment of the invention, data for both node classification and graph classification tasks can be directly fed into the network model for training. However, for the student model (multilayer perceptron) in this embodiment of the invention, since its input data only contains feature data and the input and output dimensions are fixed, the processing of these two tasks differs: In the node classification task, each node has an independent label, so the input data can be divided at the node level and directly fed into the student model for batch training; in the graph classification task, the input data is divided at the graph level, and the sizes of different graphs may vary, making it impossible to determine the model parameters, so the data cannot be directly fed into the student model for batch training. Furthermore, in the node classification task, the node label information can be directly used as the target between the teacher model and the student model for knowledge distillation training. However, in the graph classification task, there are no direct graph-level labels available for defining the distillation target.
[0086] To overcome the aforementioned difficulties, this invention introduces aggregation operations, such as summation and averaging, into the training process of the student model. This method captures global information of the graph, generating a graph-level representation. Using a designed loss function, the aggregated graph representation data is backpropagated before training the model. Thus, after the aggregation operation, the entire graph can be analogized to a single node, making subsequent processing similar to node classification tasks.
[0087] The following experiments illustrate the effectiveness of the graph classification model constructed in the embodiments of the present invention.
[0088] 1. Experimental conditions
[0089] This invention was tested using the deep learning framework PyTorch on a system with an Intel(R) Xeon(R) Gold 6226R CPU @ 2.90GHz, an NVIDIA GeForce RTX 3090, and an Ubuntu 20.04.1 operating system. The data used in the experiments came from the TUDatasets dataset, a widely used collection of graph datasets containing multiple different graph classification and graph regression tasks.
[0090] The comparison methods used in the experiment are as follows:
[0091] One type is a graph neural network based on an attention mechanism, recorded as GAT in experiments, and the reference is [reference missing]. P,Cucurull G,Casanova A,et al.Graph attention networks[J].arXiv preprintarXiv:1710.10903,2017.
[0092] Another type is the graph neural network that can generalize to unknown nodes, denoted as SAGE in the experiment. The reference is Hamilton W, Ying Z, Leskovec J. Inductive representation learning on large graphs[J]. Advances in neural information processing systems, 2017, 30.
[0093] MLP stands for Multilayer Perceptron without knowledge distillation, while this invention is a Multilayer Perceptron with knowledge distillation.
[0094] 2. Experiment Content
[0095] Based on the above content, a graph classification model was obtained. The accuracy and inference time of the graph classification task were calculated and compared with the accuracy and inference time of the GAT and SAGE methods. The results are shown in Table 1.
[0096] Table 1 Comparison of experimental results
[0097]
[0098]
[0099] As shown in Table 1, training the multilayer perceptron using knowledge distillation can make the accuracy of the student model comparable to that of the teacher model, while reducing inference time, thus verifying the effectiveness of the present invention.
[0100] In summary, this invention improves the accuracy of multilayer perceptrons through knowledge distillation while significantly reducing inference time compared to graph neural networks. This improves the inference speed of graph classification tasks and solves the problem that graph neural networks cannot be deployed in latency-constrained applications due to the large size of industrial-scale graphs. It is better suited to real-world industrial application scenarios.
[0101] Secondly, embodiments of the present invention provide a graph classification method based on a multilayer perceptron, such as... Figure 3 As shown, the method may include the following steps:
[0102] S01, Obtain the target graph data to be classified in the social network;
[0103] The structural data of the target graph represents the nodes in a social network and the connections between them. Nodes can represent users, content, or events, and edges represent the relationships between nodes, such as friend relationships, follow relationships, and retweet relationships.
[0104] For the feature data of the target graph, node features can include user personal attributes such as gender, age, and region; user social behaviors such as number of followers and number of fans; or content attributes such as text features and image features. Edge features can include the strength of social relationships and interaction frequency.
[0105] The classification task for target image data and the categories in the classification results depend on the specific application scenario and requirements. For example, classification tasks may include, but are not limited to, the following:
[0106] 1. Community Classification: Dividing users or nodes in a social network into different communities or groups. Categories can be different interest groups, social circles, or user types.
[0107] 2. User behavior classification: Classify users in social networks according to their behavior, such as active users, inactive users, potential users, etc.
[0108] 3. Content Classification: Classify content on social networks (such as posts, comments, tweets, etc.) into categories such as positive content, negative content, advertising content, media reports, etc.
[0109] S02, input the feature data in the target graph data into the pre-trained graph classification model to obtain the corresponding classification result;
[0110] The graph classification model is obtained based on the graph classification model construction method based on multilayer perceptron provided in the first aspect. For details regarding the graph classification model, please refer to the preceding description; it will not be repeated here.
[0111] The graph classification method based on a multilayer perceptron provided in this invention is implemented based on an obtained graph classification model. The graph classification model is obtained by training a multilayer perceptron using a graph neural network trained as a teacher model and then training the multilayer perceptron using a knowledge distillation method. The graph classification model does not have graph dependency when reasoning about graph data to be classified in social networks, and can maintain competitive accuracy. At the same time, it can reduce the data dependency problem in the graph neural network reasoning process. While ensuring high accuracy, it can significantly reduce the computational complexity of the model, improve the reasoning speed, and has a faster reasoning speed.
[0112] Thirdly, corresponding to the above method embodiments, this invention also provides a graph classification device based on a multilayer perceptron, such as... Figure 4 As shown, the device includes:
[0113] Graph data acquisition module 401 is used to acquire target graph data to be classified in social networks;
[0114] The classification module 402 is used to input the feature data in the target graph data into a pre-trained graph classification model to obtain the corresponding classification result; wherein, the graph classification model is obtained according to the graph classification model construction method based on multilayer perceptron provided in the first aspect.
[0115] For details on the specific processing procedures of each module of the device, please refer to the relevant content in the second part, which will not be elaborated here.
[0116] Fourthly, embodiments of the present invention also provide an electronic device, such as... Figure 5 As shown, it includes a processor 501, a communication interface 502, a memory 503, and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0117] The memory is used to store computer programs;
[0118] When the processor executes the program stored in the memory, it implements the steps of the graph classification method based on a multilayer perceptron provided in the second aspect of the present invention.
[0119] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0120] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0121] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0122] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0123] The graph classification method based on a multilayer perceptron provided in this invention can be applied to electronic devices. Specifically, the electronic device can be a desktop computer, a portable computer, a smart mobile terminal, a server, etc. No limitation is made herein; any electronic device that can implement this invention falls within the protection scope of this invention.
[0124] Fifthly, corresponding to the graph classification method based on a multilayer perceptron provided in the second aspect, this embodiment of the invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the graph classification method based on a multilayer perceptron provided in the second aspect of this invention.
[0125] For the embodiments of the device / electronic device / storage medium, since they are basically similar to the corresponding method embodiments, the description is relatively simple, and relevant parts can be referred to in the description of the corresponding method embodiments.
[0126] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method for constructing a graph classification model based on a multilayer perceptron, which can be used for community classification, user classification, and sentiment classification, characterized in that... include: For the classification task of the required application scenario, a training set is formed by acquiring several graph data; wherein, the required application scenario includes: social scenario; at least some of the graph data in the training set has category labels; the graph data represents the nodes in the social network and the connections between them, the nodes represent users, content or events, and the edges represent the relationships between the nodes; the feature data of the graph data is text features or image features; The selected graph neural network is trained using the training set, and the trained graph neural network is used as the teacher network. The classification results corresponding to the graph neural network are saved. The selected graph neural network includes GraphSAGE and GIN. The selected multilayer perceptron is used as the student model, and the input dataset is composed of the feature data of the graph data in the training set. Based on the input dataset, the category labels of the data in the input dataset, the classification results corresponding to the graph neural network, and the preset loss function, the student model is trained by the knowledge distillation method until the student model converges. The trained student model is used as a graph classification model to classify the remaining graph data of the required application scenario. The preset loss function is as follows: ; in, Represents graph data; This refers to the training set; This refers to the set of graph data with category labels in the training set; Representing graph data The classification results of the corresponding student model; Representing graph data Category tags; Representing graph data The corresponding classification results of the teacher model; This represents the loss between the true category label and the classification result of the student model; This represents the loss between the classification results of the student model and the classification results of the teacher model; This represents the weighting parameter.
2. The graph classification model construction method based on multilayer perceptron according to claim 1, characterized in that, The selected multilayer perceptron includes: A multi-layered, fully connected network.
3. A graph classification method based on a multilayer perceptron, characterized in that, include: Obtain target image data to be classified in social scenarios; The feature data in the target graph data is input into a pre-trained graph classification model to obtain the corresponding classification result; wherein, the graph classification model is obtained according to the graph classification model construction method based on multilayer perceptron as described in claim 1 or 2.
4. A graph classification device based on a multilayer perceptron, characterized in that, include: The graph data acquisition module is used to acquire target graph data to be classified in social scenarios. The classification module is used to input the feature data in the target graph data into a pre-trained graph classification model to obtain the corresponding classification result; wherein, the graph classification model is obtained according to the graph classification model construction method based on multilayer perceptron as described in claim 1 or 2.
5. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used to store computer programs; When the processor executes the program stored in the memory, it implements the steps of the method described in any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-3.