An image classification method, system and electronic device based on a graph neural network

By inserting pseudo-quantized and randomized nodes into a floating-point graph neural network and utilizing feature alignment and uncertainty loss functions, the low-precision graph neural network is iteratively trained, which solves the problem of unstable performance of low-precision graph neural networks and improves the efficiency and accuracy of image classification.

CN115984628BActive Publication Date: 2026-03-20SHANGHAI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-13
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing low-precision graph neural networks are unstable and inefficient in image classification. Gradient approximation methods suffer from error accumulation, resulting in low classification accuracy.

Method used

The floating-point graph neural network is divided into a backbone network and a graph network. Pseudo-quantized nodes and randomized quantized nodes are inserted. The low-precision graph neural network is optimized through iterative training. Feature alignment and uncertainty loss function are used to enhance network performance.

Benefits of technology

It improves the image classification efficiency and accuracy of low-precision graph neural networks, and enhances the network's stability and feature representation capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115984628B_ABST
    Figure CN115984628B_ABST
Patent Text Reader

Abstract

The application provides a kind of image classification method, system and electronic equipment based on graph neural network, belong to image classification field, method includes: obtaining initial graph neural network;Initial graph neural network includes sequentially connected initial backbone network and initial graph network;Initial backbone network is used to extract the feature of image, initial graph network is used to classify the feature of image;Initial backbone network includes a plurality of sequentially connected computing nodes, and initial graph network includes a plurality of graph nodes;Insert pseudo-quantization node in front of each computing node and each graph node, and insert random quantization node after each graph node, to obtain quantized backbone network and quantized graph network;Obtain training sample set;According to training sample set, iteratively train quantized backbone network and quantized graph network to obtain image classification model;Classify target image based on image classification model.The application enhances the feature expression ability of graph neural network, and then improves the efficiency of image classification.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image classification, and particularly to an image classification method and system based on a graph neural network and an electronic device. BACKGROUND

[0002] At present, the research on enhancing the performance of low-precision graph neural networks is generally based on gradient approximation methods. In order to solve the non-differentiable problem introduced by quantization, these methods artificially design a gradient approximation function to realize back propagation. However, the gradient approximation method has the following disadvantages: (1) the gradient approximation always has errors; (2) the errors of the gradient will gradually accumulate with back propagation. Therefore, the accuracy of enhancing the performance of low-precision graph neural networks is low, which further leads to unstable performance of the graph neural network and low efficiency of image classification using the graph neural network. SUMMARY

[0003] The purpose of the present application is to provide an image classification method and system based on a graph neural network and an electronic device, which can improve the efficiency of image classification using a low-precision graph neural network.

[0004] To achieve the above purpose, the present application provides the following solutions:

[0005] An image classification method based on a graph neural network, comprising:

[0006] obtaining an initial graph neural network; the initial graph neural network is a floating-point graph neural network; the initial graph neural network comprises an initial backbone network and an initial graph network connected in sequence; the initial backbone network is used to extract features of an image, and the initial graph network is used to classify the features of the image; the initial backbone network comprises a plurality of calculation nodes connected in sequence, and the initial graph network comprises a plurality of graph nodes;

[0007] inserting a pseudo-quantization node in front of each calculation node of the initial backbone network and in front of each graph node of the initial graph network, and inserting a random quantization node after each graph node of the initial graph network to obtain a quantized backbone network and a quantized graph network; the pseudo-quantization node is used to quantize the input data of the calculation node or the data on the graph node, and the random quantization node is used to randomly quantize the data on the graph node;

[0008] obtaining a training sample set; the training sample set comprises a plurality of sample images and class labels of each sample image;

[0009] iteratively training the quantized backbone network and the quantized graph network according to the training sample set to obtain an image classification model;

[0010] classifying a target image based on the image classification model to determine the class of the target image.

[0011] Optionally, the initial backbone network is a convolutional neural network; and each computing node of the initial backbone network is a convolutional layer or an activation layer.

[0012] Optionally, the quantized backbone network and the quantized graph network are iteratively trained according to the training sample set to obtain an image classification model, and the training specifically includes:

[0013] For any sample image, the feature extraction of the sample image is performed by the quantized backbone network to obtain implicit full-precision activation values and low-precision activation values of each computing node;

[0014] For any computing node, the feature alignment loss of the computing node is determined according to the implicit full-precision activation values and the low-precision activation values of the computing node;

[0015] The random quantization data of each graph node, the low-precision activation values of each graph node, and the predicted class of the sample image are determined by the quantized graph network according to the low-precision activation values of the Nth computing node; N is the number of computing nodes in the quantized backbone network;

[0016] For any graph node, the uncertainty loss of the graph node is determined according to the random quantization data and the low-precision activation values of the graph node;

[0017] The classification loss is determined according to the predicted class of each sample image and the class label;

[0018] The quantized backbone network and the quantized graph network are iteratively trained based on the feature alignment loss of each computing node, the uncertainty loss of each graph node, and the classification loss, until the feature alignment loss of each computing node, the uncertainty loss of each graph node, and the classification loss are all converged, to obtain an optimal quantized graph neural network; the optimal quantized graph neural network is an image classification model.

[0019] Optionally, the feature extraction of the sample image is performed by the quantized backbone network to obtain implicit full-precision activation values and low-precision activation values of each computing node, and the feature extraction specifically includes:

[0020] For any computing node, the implicit full-precision activation values of the computing node are obtained by performing feature extraction on the input data of the computing node by the computing node based on the implicit weights of the computing node;

[0021] The input data of the computing node and the implicit weights of the computing node are quantized by a pseudo-quantization node connected in front of the computing node to obtain quantized input data and quantized weights;

[0022] based on the quantization weight, the quantization input data is feature extracted by the computing node to obtain a low-precision activation value of the computing node; input data of a first computing node in the quantization backbone network is the sample image, and input data of an nth computing node in the quantization backbone network is a low-precision activation value of an (n-1) th computing node, 1 < n < N.

[0023] Optionally, according to the implicit full-precision activation value and the low-precision activation value of the computing node, a feature alignment loss of the computing node is determined, and specifically includes:

[0024] According to the implicit full-precision activation value of the computing node, a relationship parameter vector of the computing node is determined; the relationship parameter vector includes relationship parameters between each channel dimension of the implicit full-precision activation value and each channel dimension of the low-precision activation value.

[0025] According to the relationship parameter vector, the implicit full-precision activation value and the low-precision activation value of the computing node, a feature alignment loss of the computing node is determined.

[0026] Optionally, the relationship parameter vector is determined by using the following formula:

[0027] α=softmax(MLP(Flatten(BN(A f ))));

[0028] Wherein, α is the relationship parameter vector, softmax() is a normalized exponential function, MLP() is a multi-layer perception, Flatten() represents merging the last two dimensions of a three-dimensional tensor, BN() is batch normalization, A f is the implicit full-precision activation value of the computing node.

[0029] Optionally, the feature alignment loss of the computing node is determined by using the following formula:

[0030]

[0031] Wherein, is the feature alignment loss of the computing node, C is the channel dimension of the implicit full-precision activation value, the channel dimension of the implicit full-precision activation value and the channel dimension of the low-precision activation value are the same, α i is the relationship parameter between the i-th dimension of the implicit full-precision activation value and the i-th dimension of the low-precision activation value, H i () is a composite function of Flatten(BN()), A f is the implicit full-precision activation value of the computing node, A l is the low-precision activation value of the computing node, and |||2 is the 2-norm.

[0032] Optionally, the uncertainty loss of the graph node is determined by using the following formula:

[0033]

[0034] wherein, is the uncertainty loss of the graph node, A d is the random quantization data of the graph node, A t is the low-precision activation value of the graph node, T represents transposition, and |||2 is the 2-norm.

[0035] To achieve the above object, the present application further provides the following schemes:

[0036] An image classification system based on a graph neural network comprises:

[0037] An initial network acquisition unit is configured to acquire an initial graph neural network; the initial graph neural network is a floating-point graph neural network; the initial graph neural network comprises an initial backbone network and an initial graph network connected in sequence; the initial backbone network is configured to extract features of an image, and the initial graph network is configured to classify the features of the image; the initial backbone network comprises a plurality of calculation nodes connected in sequence, and the initial graph network comprises a plurality of graph nodes;

[0038] A network quantization unit is connected with the initial network acquisition unit and is configured to insert a pseudo-quantization node in front of each calculation node of the initial backbone network and in front of each graph node of the initial graph network, and insert a random quantization node behind each graph node of the initial graph network, so as to obtain a quantized backbone network and a quantized graph network; the pseudo-quantization node is configured to quantize input data of the calculation node or data on the graph node, and the random quantization node is configured to randomly quantize the data on the graph node;

[0039] A sample acquisition unit is configured to acquire a training sample set; the training sample set comprises a plurality of sample images and class labels of each sample image;

[0040] A training unit is connected with the network quantization unit and the sample acquisition unit respectively and is configured to iteratively train the quantized backbone network and the quantized graph network according to the training sample set, so as to obtain an image classification model;

[0041] A classification unit is connected with the training unit and is configured to classify a target image based on the image classification model, so as to determine a class of the target image.

[0042] To achieve the above object, the present application further provides the following schemes:

[0043] An electronic device includes a memory for storing a computer program and a processor for running the computer program to cause the electronic device to perform the above-mentioned image classification method based on a graph neural network.

[0044] According to the specific embodiments of the present application, the following technical effects are disclosed.

[0045] The present application divides the floating-point graph neural network into two parts of backbone network and graph network, inserts pseudo-quantization nodes in front of each calculation node and graph node of the backbone network and the graph network by using a pseudo-quantization method, inserts a random quantization node after each graph node, quantizes the input data of the calculation node or the data on the graph node through the pseudo-quantization node, randomly quantizes the data on the graph node through the random quantization node, improves the performance of the graph neural network, and then iteratively trains the quantized backbone network and the quantized graph network using a training sample set to obtain an image classification model for classifying target images and improving the efficiency of image classification. BRIEF DESCRIPTION OF DRAWINGS

[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0047] Figure 1 The flowchart of the image classification method based on the enhanced graph neural network of the present application;

[0048] Figure 2 The calculation process diagram of the implicit full-precision activation value and the low-precision activation value;

[0049] Figure 3 The flowchart of enhancing the feature expression ability of the low-precision graph neural network;

[0050] Figure 4 The module diagram of the image classification system based on the enhanced graph neural network of the present application.

[0051] Symbol explanation:

[0052] Initial network acquisition unit-1, network quantization unit-2, sample acquisition unit-3, training unit-4, classification unit-5. DETAILED DESCRIPTION

[0053] 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.

[0054] The purpose of this invention is to provide an image classification method, system, and electronic device based on graph neural networks. Based on the feature alignment system in knowledge distillation, it distills rich feature knowledge from floating-point feature maps into low-precision feature maps. Furthermore, it enhances the low-precision graph neural network based on an uncertain loss function. It can be used in conjunction with gradient approximation-based methods to further enhance the feature representation capability of the low-precision graph neural network.

[0055] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0056] Example 1

[0057] like Figure 1 As shown, this embodiment provides an image classification method based on an augmented graph neural network, including:

[0058] S1: Obtain the initial graph neural network. The initial graph neural network is a floating-point graph neural network.

[0059] The initial graph neural network comprises an initial backbone network and an initial graph network connected in sequence. The initial backbone network is used to extract features from the image, and the initial graph network is used to classify the features of the image. The initial backbone network includes multiple computational nodes connected in sequence, and the initial graph network includes multiple graph nodes.

[0060] In this embodiment, the initial backbone network is a convolutional neural network. Each computation node of the initial backbone network is a convolutional layer or an activation layer.

[0061] S2: Insert pseudo-quantized nodes before each computing node of the initial backbone network and before each graph node of the initial graph network, and insert random quantized nodes after each graph node of the initial graph network to obtain a quantized backbone network and a quantized graph network. The pseudo-quantized nodes are used to quantize the input data of the computing nodes or the data on the graph nodes, and the random quantized nodes are used to randomly quantize the data on the graph nodes. That is, the pseudo-quantized nodes perform full quantization on the data of the computing nodes or the data on the graph nodes.

[0062] Specifically, a floating-point full-precision graph neural network is input into a model quantization system, and the graph neural network is divided into a backbone network and a graph network. Based on symmetric quantization, pseudo-quantization nodes are inserted in front of each calculation node and each graph node in the backbone network and the graph network, and the floating-point weights and activation values are converted into low-precision weights and activation values with faster calculation speed and less memory occupation. This operation realizes the preliminary quantization of the graph neural network, that is, a low-precision graph neural network with performance degradation is obtained.

[0063] In the embodiment, the pseudo-quantization node adopts an LSQ pseudo-quantization node, and the quantization process is as follows:

[0064] Q(x)=s*round(clip(x / s,-Q N ,Q P ));

[0065] wherein x is a quantization object, s is a parameter of the pseudo-quantization node, Q N and Q P represent the minimum value and the maximum value of the quantized value respectively (under the current b-bit precision, Q N =-2 b-1 , Q P =2 b-1 -1), clip() is a clipping function, and round() is a rounding function.

[0066] S3: Obtain a training sample set. The training sample set includes multiple sample images and class labels of each sample image.

[0067] S4: Iteratively train the quantized backbone network and the quantized graph network according to the training sample set to obtain an image classification model.

[0068] S5: Classify a target image based on the image classification model to determine the class of the target image.

[0069] Further, S4 specifically includes:

[0070] S41: For any sample image, extract features of the sample image by the quantized backbone network to obtain implicit full-precision activation values and low-precision activation values of each calculation node.

[0071] Specifically, (1) for any calculation node, based on the implicit weights of the calculation node, extract features of the input data of the calculation node by the calculation node to obtain implicit full-precision activation values of the calculation node. Wherein the implicit weights are implicit weights (floating-point type) in the floating-point full-precision graph neural network. The implicit weights are subjected to matrix operation (feature extraction) with the input data to obtain the implicit full-precision activation values: wherein A f is the implicit full-precision activation value of the computing node, W is the implicit weight of the computing node, and X is the input data of the computing node, represents a matrix operation.

[0072] (2) Quantizing the input data of the computing node and the implicit weight of the computing node through the pseudo-quantization node connected in front of the computing node to obtain quantized input data and quantized weight.

[0073] That is, the input data is converted into quantized input data through the pseudo-quantization node, and the implicit weight is converted into quantized weight through the pseudo-quantization node.

[0074] (3) Based on the quantized weight, performing feature extraction on the quantized input data through the computing node to obtain a low-precision activation value of the computing node.

[0075] wherein the input data of the first computing node in the quantized backbone network is the sample image, and the input data of the nth computing node in the quantized backbone network is the low-precision activation value of the (n-1) th computing node, 1 < n < N.

[0076] Specifically, the quantized weight and the quantized input data perform a matrix operation, and the input low-precision activation value is:

[0077]

[0078] wherein A l is the low-precision activation value of the computing node, and Q() is a quantization function of the pseudo-quantization node.

[0079] The process of calculating the implicit full-precision activation value and the low-precision activation value through the computing node and the pseudo-quantization node is as shown in Figure 2 .

[0080] S42: For any computing node, determining a feature alignment loss of the computing node according to the implicit full-precision activation value and the low-precision activation value of the computing node.

[0081] After obtaining the implicit full-precision activation value and the low-precision activation value, relationship recognition is started. Since the implicit full-precision activation value and the low-precision activation value are homologous, and the implicit full-precision activation value contains more abundant information than the low-precision activation value, the relationship between the activation values of two different precisions on different channels can be mined from the implicit full-precision activation value only by using the back propagation of the deep neural network.

[0082] Specifically, according to the implicit full-precision activation value of the computing node, a relationship parameter vector of the computing node is determined. The relationship parameter vector includes relationship parameters of each channel dimension of the implicit full-precision activation value and each channel dimension of the low-precision activation value.

[0083] First, the implicit full-precision activation value is batch normalized, and then converted into a two-dimensional vector, which is input into a multi-layer perception to identify the relationship parameter vector of the two in different channels:

[0084] α=softmax(MLP(Flatten(BN(A f ))));

[0085] Wherein, α is the relationship parameter vector, used to control the feature alignment strength in different channel dimensions, softmax() is a normalization exponential function, MLP() is a multi-layer perception, Flatten() represents merging the last two dimensions of a three-dimensional tensor, BN() is batch normalization, A f is the implicit full-precision activation value of the computing node.

[0086] According to the relationship parameter vector, the implicit full-precision activation value and the low-precision activation value of the computing node, the feature alignment loss of the computing node is determined.

[0087] The feature alignment loss of the computing node is determined by the following formula:

[0088]

[0089] Wherein, is the feature alignment loss of the computing node, C is the channel dimension of the implicit full-precision activation value, the channel dimension of the implicit full-precision activation value and the channel dimension of the low-precision activation value are the same, α i is the relationship parameter of the i-th dimension of the implicit full-precision activation value and the i-th dimension of the low-precision activation value, α i controls the feature alignment strength in the i-th dimension channel, H i () is a composite function of Flatten(BN()), A f is the implicit full-precision activation value of the computing node, A l is the low-precision activation value of the computing node, and |||2 is the 2-norm.

[0090] In this embodiment, the feature expression capability of the backbone network is enhanced based on the feature alignment, that is, the relationship parameter vector and the feature alignment loss are used to enhance the feature expression capability of the backbone network.

[0091] S43: determining the random quantization data of each graph node, the low-precision activation value of each graph node and the predicted category of the sample image according to the low-precision activation value of the Nth computing node through the quantization graph network; N is the number of computing nodes in the quantization backbone network.

[0092] Specifically, the data on each graph node is quantized by a pseudo-quantization node in front of the graph node to obtain a low-precision activation value A corresponding to each graph node t . The data on each graph node is randomly quantized by a random quantization node behind the graph node to obtain random quantization data A corresponding to each graph node d .

[0093] The random quantization function DropQuant() introduced by the random quantization node is:

[0094]

[0095] The random quantization data is: d A g =DropQuant(A d );

[0096] wherein A g is the random quantization data, A d is the data on the graph node, and p is the random quantization probability. In order to achieve entropy maximization, the present application sets the random quantization probability p to 0.5. The graph node is a tensor, i.e. multi-dimensional data, including multiple elements, and the quantization probability of each element is 50% during random quantization.

[0097] As a specific implementation, the graph nodes in the quantization graph network include a feature node and multiple category nodes, the data on the feature node is the low-precision activation value of the Nth computing node, and the data on the category node is the category of the image. The category of the image can be obtained by calculating the similarity between the feature node and each category node.

[0098] S44: For any graph node, the uncertainty loss of the graph node is determined according to the random quantization data and the low-precision activation value of the graph node.

[0099] The present embodiment enhances the feature expression capability of the graph network based on the uncertainty loss. The random quantization node introduces uncertainty, and the node features after random quantization are first regularized, and then the L2 loss is used as the uncertainty loss to enhance the feature expression capability of the graph network. The uncertainty loss of the graph node is:

[0100]

[0101] wherein, is the uncertainty loss of the graph node, A d is the random quantization data of the graph node, A t is the low-precision activation value of the graph node, T represents transposition, and |||2 is the 2-norm.

[0102] S41 and S42 realize the enhancement of the backbone network through relationship recognition and feature alignment, S43 and S44 realize the enhancement of the graph network through random quantization and uncertainty loss, and under the joint action of the two parts, a high-performance low-precision graph neural network can be obtained.

[0103] S45: According to the predicted category of each sample image and the category label, the classification loss is determined.

[0104] S46: Based on the feature alignment loss of each computing node, the uncertainty loss of each graph node and the classification loss, the quantized backbone network and the quantized graph network are iteratively trained until the feature alignment loss of each computing node, the uncertainty loss of each graph node and the classification loss are all converged, and the optimal quantized graph neural network is obtained. The optimal quantized graph neural network is an image classification model.

[0105] In the iterative training process of the quantized backbone network and the quantized graph network, the weights of each computing node, the weights of each graph node and the parameters s of each pseudo-quantization node are adjusted.

[0106] Compared with the existing technology, the present application innovatively uses the rich feature knowledge distillation in the implicit floating-point feature map to give the low-precision feature map based on the feature alignment system in knowledge distillation. In addition, the enhancement of the low-precision graph neural network is realized based on the uncertainty loss function, which can be used together with the method based on gradient approximation, further enhancing the feature expression ability of the low-precision graph neural network.

[0107] In order to better understand the scheme of the present application, the following will be further described in combination with specific embodiments.

[0108] This embodiment takes the mini-Imagenet classification data set as the training data, and expects to quantize the DPGN (distribution propagation graph network) in the graph neural network to b-bit precision. Given a pre-trained floating-point graph neural network, i.e. a pre-trained distribution propagation graph network DPGN under the mini-Imagenet training set.

[0109] (1) Follow the traditional symmetric quantization framework, and insert a pseudo-quantization node in front of each computing node of the pre-trained floating-point distribution propagation graph network. This operation will output a low-precision distribution propagation graph network with poor performance.

[0110] (2) Identify the relationship parameter vector between the implicit full-precision activation value and the low-precision activation value in different channel dimensions in the backbone network of the low-precision distribution propagation graph network, and deploy the L2 feature alignment loss; at the same time, insert a random quantization node after each graph node, and deploy the uncertainty loss.

[0111] (3) Start training for the improved network. The mini-Imagenet training data is input into the network, and after forward propagation, the network outputs the feature alignment loss and the uncertainty loss. The feature expression ability of the low-precision graph neural network is optimized for the two losses using backpropagation and stochastic gradient descent.

[0112] (4) After several iterations, the training converges, and a high-performance low-precision graph neural network is finally obtained.

[0113] In summary, as shown in Figure 3 , the present application first inputs a floating-point full-precision graph neural network; then inserts a pseudo-quantization node based on symmetric quantization, identifies the relationship between implicit full-precision activation values and low-precision activation values in different channels; then enhances the feature expression ability of the backbone network based on feature alignment; then inserts a random quantization node after the graph node, and enhances the feature expression ability of the graph network based on the uncertainty loss; the model is trained and the parameters are updated based on backpropagation and stochastic gradient descent, and finally a high-performance low-precision graph neural network is output.

[0114] Example two

[0115] In order to perform the method corresponding to the above-mentioned embodiment one, to realize the corresponding function and technical effect, the following provides a kind of image classification system based on graph neural network.

[0116] As shown in Figure 4 , the image classification system based on graph neural network provided by the present embodiment includes: initial network acquisition unit 1, network quantization unit 2, sample acquisition unit 3, training unit 4 and classification unit 5.

[0117] Wherein, initial network acquisition unit 1 is used to obtain initial graph neural network.

[0118] The initial graph neural network is a floating-point graph neural network. The initial graph neural network includes an initial backbone network and an initial graph network connected in sequence. The initial backbone network is used to extract the features of the image, and the initial graph network is used to classify the features of the image. The initial backbone network includes a plurality of calculation nodes connected in sequence, and the initial graph network includes a plurality of graph nodes.

[0119] Network quantization unit 2 is connected with the initial network acquisition unit 1, and network quantization unit 2 is used to insert a pseudo-quantization node in front of each calculation node of the initial backbone network and in front of each graph node of the initial graph network, and a random quantization node is inserted after each graph node of the initial graph network to obtain a quantized backbone network and a quantized graph network; the pseudo-quantization node is used to quantize the input data of the calculation node or the graph node, and the random quantization node is used to randomly quantize the graph node.

[0120] The sample acquisition unit 3 is configured to acquire a training sample set. The training sample set includes a plurality of sample images and a category label of each sample image.

[0121] The training unit 4 is connected with the network quantization unit 2 and the sample acquisition unit 3 respectively. The training unit 4 is configured to perform iterative training on the quantized backbone network and the quantized graph network according to the training sample set, so as to obtain an image classification model.

[0122] The classification unit 5 is connected with the training unit 4. The classification unit 5 is configured to perform classification on a target image based on the image classification model, so as to determine a category of the target image.

[0123] Compared with the prior art, the image classification system based on the graph neural network provided in the embodiment has the same beneficial effects as the image classification method based on the graph neural network provided in the embodiment one, and thus the detailed description is omitted here.

[0124] Embodiment three

[0125] The embodiment provides an electronic device, including a memory and a processor, the memory is used for storing a computer program, and the processor runs the computer program to make the electronic device execute the image classification method based on the graph neural network in the embodiment one.

[0126] Optionally, the electronic device can be a server.

[0127] In addition, the embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the image classification method based on the graph neural network in the embodiment one.

[0128] In the specification, each embodiment is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts of each embodiment can be referred to each other.

[0129] The principles and implementation manners of the present application are described by using specific examples in the present application. The above description of the embodiments is only used to help understand the method and core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manner and application range can be changed. In conclusion, the content of the specification should not be understood as a limitation of the present application.

Claims

1. An image classification method based on graph neural networks, characterized in that, The image classification method based on graph neural networks includes: An initial graph neural network is obtained; the initial graph neural network is a floating-point graph neural network; the initial graph neural network includes an initial backbone network and an initial graph network connected in sequence; the initial backbone network is used to extract features from the image, and the initial graph network is used to classify the features of the image; the initial backbone network includes multiple computing nodes connected in sequence, and the initial graph network includes multiple graph nodes. Pseudo-quantized nodes are inserted before each computing node of the initial backbone network and before each graph node of the initial graph network, and random quantized nodes are inserted after each graph node of the initial graph network to obtain a quantized backbone network and a quantized graph network. The pseudo-quantized nodes are used to quantize the input data of the computing nodes or the data on the graph nodes, and the random quantized nodes are used to randomly quantize the data on the graph nodes. Obtain a training sample set; the training sample set includes multiple sample images and the category labels of each sample image; The quantization backbone network and the quantization graph network are iteratively trained based on the training sample set to obtain an image classification model; Based on the image classification model, the target image is classified to determine its category.

2. The image classification method based on graph neural networks according to claim 1, characterized in that, The initial backbone network is a convolutional neural network; each computing node of the initial backbone network is a convolutional layer or an activation layer.

3. The image classification method based on graph neural networks according to claim 1, characterized in that, The quantized backbone network and the quantized graph network are iteratively trained based on the training sample set to obtain an image classification model, specifically including: For any sample image, the quantization backbone network is used to extract features from the sample image to obtain the implicit full-precision activation value and low-precision activation value of each computing node. For any computing node, the feature alignment loss of the computing node is determined based on the implicit full-precision activation value and low-precision activation value of the computing node. According to the quantization graph network, based on the first N The low-precision activation values ​​of each computing node are used to determine the random quantized data of each graph node, the low-precision activation values ​​of each graph node, and the predicted category of the sample image. N To quantify the number of computing nodes in the backbone network; For any graph node, the uncertainty loss of the graph node is determined based on the random quantization data and low-precision activation value of the graph node. The classification loss is determined based on the predicted category and category label of each sample image; Based on the feature alignment loss of each computing node, the uncertainty loss of each graph node, and the classification loss, the quantized backbone network and the quantized graph network are iteratively trained until the feature alignment loss of each computing node, the uncertainty loss of each graph node, and the classification loss all converge, thus obtaining the optimal quantized graph neural network; the optimal quantized graph neural network is an image classification model.

4. The image classification method based on graph neural networks according to claim 3, characterized in that, The sample image is feature extracted using the quantized backbone network to obtain the implicit full-precision activation value and low-precision activation value of each computing node, specifically including: For any computing node, based on the implicit weights of the computing node, feature extraction is performed on the input data of the computing node through the computing node to obtain the implicit full-precision activation value of the computing node. The input data of the computing node and the implicit weights of the computing node are quantized by the pseudo-quantization node connected in front of the computing node to obtain quantized input data and quantization weights. Based on the quantization weights, feature extraction is performed on the quantized input data through the computing nodes to obtain the low-precision activation values ​​of the computing nodes; the input data of the first computing node in the quantization backbone network is the sample image, and the input data of the second computing node in the quantization backbone network is the sample image. n The input data for the _th computing node is the _th n -1 low-precision activation value of computing nodes, 1< n < N .

5. The image classification method based on graph neural networks according to claim 3, characterized in that, Based on the implicit full-precision activation value and low-precision activation value of the computing node, the feature alignment loss of the computing node is determined, specifically including: Based on the implicit full-precision activation value of the computing node, the relational parameter vector of the computing node is determined; the relational parameter vector includes the relational parameters between each channel dimension of the implicit full-precision activation value and each channel dimension of the low-precision activation value. The feature alignment loss of the computing node is determined based on the relational parameter vector, implicit full-precision activation value, and low-precision activation value of the computing node.

6. The image classification method based on graph neural networks according to claim 5, characterized in that, The relation parameter vector is determined using the following formula: ; in, For relational parameter vectors, softmax () is the normalized exponential function. MLP () represents a multilayer perceptron. Flatten () indicates merging the last two dimensions of a three-dimensional tensor. BN () represents batch normalization. A f This is the implicit full-precision activation value for the compute node.

7. The image classification method based on graph neural networks according to claim 5, characterized in that, The feature alignment loss for computation nodes is determined using the following formula: ; in, To calculate the feature alignment loss of the nodes, C This represents the channel dimension of the implicit full-precision activation value. The channel dimension of the implicit full-precision activation value is the same as that of the low-precision activation value. The first of the implicit full-precision activation values i The first dimension and low-precision activation value i dimensional relational parameters, H i ()for Flatten ( BN The composite function of ()). A f represents the implicit full-precision activation value of the computation node. A l Let |||2| be the low-precision activation value of the compute node, and |||2| be the 2-norm.

8. The image classification method based on graph neural networks according to claim 3, characterized in that, The uncertainty loss of graph nodes is determined using the following formula: ; in, For the uncertainty loss of graph nodes, A d For the random quantized data of graph nodes, A t These are the low-precision activation values ​​for graph nodes. T This indicates transpose, and || ||2 is the 2-norm.

9. An image classification system based on graph neural networks, characterized in that, The image classification system based on graph neural networks includes: An initial network acquisition unit is used to acquire an initial graph neural network; the initial graph neural network is a floating-point graph neural network; the initial graph neural network includes an initial backbone network and an initial graph network connected in sequence; the initial backbone network is used to extract features from an image, and the initial graph network is used to classify the features of the image; the initial backbone network includes multiple computing nodes connected in sequence, and the initial graph network includes multiple graph nodes. A network quantization unit, connected to the initial network acquisition unit, is used to insert pseudo-quantization nodes before each computing node of the initial backbone network and before each graph node of the initial graph network, and to insert random quantization nodes after each graph node of the initial graph network, to obtain a quantized backbone network and a quantized graph network; the pseudo-quantization nodes are used to quantize the input data of the computing nodes or the data on the graph nodes, and the random quantization nodes are used to randomly quantize the data on the graph nodes. A sample acquisition unit is used to acquire a training sample set; the training sample set includes multiple sample images and category labels for each sample image; The training unit is connected to the network quantization unit and the sample acquisition unit respectively, and is used to iteratively train the quantization backbone network and the quantization graph network according to the training sample set to obtain an image classification model. A classification unit, connected to the training unit, is used to classify the target image based on the image classification model to determine the category of the target image.

10. An electronic device, characterized in that, The device includes a memory and a processor, the memory being used to store a computer program, and the processor running the computer program to cause the electronic device to perform the image classification method based on a graph neural network as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Hypergraph neural network classification method and device

    CN113792768A

  • Image classification model training method and device and electronic equipment

    CN114972877A