Interpretable neural network based on dynamic hierarchical structure
By adopting dynamic hierarchical structure and early exit and layer skip methods in neural networks, combined with visualization technology, the problem of difficult to balance the interpretability and efficiency of neural networks in the existing technology is solved, and an efficient and stable interpretability neural network is achieved.
Patent Information
- Application Number
- CN202311294336.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-09
- Publication Date
- 2025-04-11
AI Technical Summary
The prior art is difficult to achieve a balance between realizing interpretability and efficiency of neural networks, and the structural complexity of dynamic neural networks makes its interpretability needs not fully met.
An interpretable neural network based on a dynamic hierarchical structure is adopted to layer the backbone network through a lightweight policy network, and the early exit method is deployed at the shallow level and the skip method at the deep deployment layer are visualized and presented with visualization technology.
On the basis of ensuring the interpretability of the neural network, the computing efficiency of the network is improved, computing resources are saved, and an interpretability method with good and stable results is realized.
Smart Images

Figure CN119810466A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and mainly to the field of dynamic neural networks and interpretable image recognition. Specifically, the present invention provides an interpretable neural network based on a dynamic hierarchical structure. Background Art
[0002] The rise of artificial intelligence generated content technology (AIGC), represented by ChatGPT and many other large-scale artificial intelligence models, has led to more extensive research and use of artificial intelligence around the world, and artificial intelligence has entered a new era of "big data, big computing power, and big models". The emergence of large-scale artificial intelligence models has promoted major breakthroughs in research directions such as natural language processing (NLP), computer vision (CV), and image generation. The excellent performance of ChatGPT has left a deep impression on users and has quickly been widely used in various industries.
[0003] As an inevitable task related to security issues in the process of studying and applying deep learning models, interpretability technology has been a hot topic in the research of artificial intelligence technology in recent years. Guestrin et al. proposed the LIME model, which uses interpretable models (such as linear models, decision trees, etc.) to simulate the output results of the target model. By slightly perturbing the input of the target model, a mapping relationship between input perturbation and output prediction changes is established, thereby achieving the interpretation of model predictions, which is a pioneering contribution to interpretability research. However, the implementation of this method is a process of seeking causes from results, and it does not change the essence of the target model as a black box, and there is still a huge room for improvement. The SHAP model proposed by Scott Lundberg et al. is also a very classic work in time interpretation, which uses game theory to explain the output of machine learning models. The core concept of the SHAP model is the Shapley value, which calculates the marginal contribution of each feature (that is, the difference between the contribution of each feature added to the input and the contribution when it is not added), so as to attribute the decision results of the model to features with different contributions, and explain the decision of the model in a way that quantifies the importance of features. The Saliency method proposed by Simonyon et al. based on back propagation maps the features and gradients that are dependent on the network decision process, thereby expressing the importance of a certain area of the input image to the prediction result. Bach et al. proposed the LRP method to calculate the pixel correlation between different layers of the network. This method uses back propagation to calculate the contribution of each neuron layer by layer to generate a heat map.
[0004] With the development of brain science and artificial intelligence technology, studies have shown that the brain processes information dynamically. The same is true for neural networks. When processing input samples, they dynamically analyze which components of the model are activated and calculate the contribution of the activated components to the decision. The structure of a dynamic neural network is similar to the mechanism of the human brain, so the dynamic structure is inherently interpretable. Influenced by the cascade idea, Eunhyeok Park et al. proposed the Big / LittleNet model, which combines two neural networks of different depths and decides whether to continue to execute the large model based on the prediction score of the small model, thereby achieving early exit. Kung et al. improved the shortcomings of the cascade method and proposed the BranchyNet method. The main idea of this method is to introduce early exit points at different depths of the network and encourage predictions at the middle early exit point through the loss function. Zhou et al. proposed an early exit method based on the Patience value. When the prediction of the early exit point is correct, the Patience value is increased until the Patience value reaches the specified threshold, thereby ensuring the accuracy of early exit. Yu et al. proposed the SkipNet method, which adds a gating module to the residual block of ResNet. The gating module makes binary decisions based on the output of the residual block to achieve dynamic layer skipping. The BlockDrop method proposed by Wu et al. builds a lightweight policy network that generates skip decisions for all residual blocks at once before the backbone network. Based on the idea of the BlockDrop method, Chen et al. proposed the GaterNet method to skip certain channels, which also uses a lightweight policy network that precedes the backbone network.
[0005] In artificial intelligence interpretable tasks, most of the existing methods are intended to explain the final results of the model. Another very important direction is to explain the network model, and the network structure of the dynamic neural network model needs to be explained more than the static model. At present, there is a consensus in the field of artificial intelligence research: shallow networks extract low-level information (such as image color, texture, edges, etc.), and deep networks extract high-level information (such as more abstract information, semantic information, etc.). In order to solve the problem of achieving both interpretability and efficiency improvement, the present invention proposes a method for distinguishing between the shallow and deep layers of a deep learning model, and deploys an early exit method in the shallow layer and a layer skipping method in the deep layer according to the different features extracted by the shallow and deep layers. Summary of the invention
[0006] The present invention aims to make up for the deficiencies of the existing technology in the trade-off between the interpretability and efficiency of neural networks. With scientific thinking and rigorous attitude, the present invention proposes an interpretable neural network based on a dynamic hierarchical structure. The present invention hierarchizes the backbone network according to different input images, and deploys an early exit method in the shallow network and a layer skip method in the deep network, and uses visualization technology to visualize the attention of the network. On the basis of ensuring interpretability, the network's computing efficiency is improved, and the network's computing resources are saved, thereby creating a good and stable interpretability method.
[0007] The technical solution of the present invention is as follows:
[0008] An interpretable neural network based on a dynamic hierarchical structure first uses a lightweight policy network to hierarchize the backbone network to distinguish the shallow and deep layers of the backbone neural network. According to the differences in the features extracted from the shallow and deep layers, an early exit method is deployed in the shallow layer and a layer skipping method is deployed in the deep layer.
[0009] Shallow features of images mainly include features such as contours, edges, colors, textures, and shapes that can reflect the content of the image; deep features of images mainly tend to be semantic features that can be understood by computers, and no longer rely more on location information. For simple images, it is not necessary to completely extract features through the network. The low-level features extracted by the shallow network are sufficient for correct prediction. At this time, continuing to extract features from the deep layer of the network will waste computing resources and overfitting, so it should be exited from the network in time to obtain correct predictions. For complex images, although features extracted by the deep network are needed, not all features extracted by all layers are helpful for the final prediction. At this time, skipping unnecessary layers in the deep network will improve the network's computing efficiency and prevent overfitting.
[0010] This method first preprocesses the images of the dataset through the policy network, divides the network into layers according to different images, and generates binary vectors for layering. The policy network consists of three convolutional layers, and uses a 3×3 convolution kernel for feature extraction. The features after convolution operation are reduced in dimension, and the binary vectors of the backbone network layers are obtained through a fully connected layer. The vectors are passed to the backbone network to activate the early exit discriminator and the layer skipping discriminator, respectively.
[0011] Then, the early exit discriminator and layer skip discriminator are used to judge the features of the image and whether to exit early or skip the layer. The early exit discriminator and layer skip discriminator are lightweight networks with the same network structure. The features are first extracted by three convolutional layers. The convolutional layer uses a 3×3 convolution kernel, and then the discrimination results are obtained through the feature dimension reduction layer and the fully connected layer. The early exit discriminator obtains the probability vectors of different categories obtained by the sigmoid function. The category with the highest probability is the prediction obtained by the current early exit discriminator. When the prediction takes a higher value, it exits early. The layer skip discriminator obtains a binary vector of whether to skip the current layer. When the current layer is skipped, the feature value passed by the previous residual block in the ResNet network will be directly passed to the next residual block.
[0012] The second is the incentive module, which performs back-propagation optimization based on the predictions generated by the early exit discriminator or the final fully connected layer, and uses the idea of reinforcement learning to reward and punish the policy network, thereby ensuring that the stratification of the policy network is based on shallow and deep features, and the stratification results help the network to make correct predictions.
[0013] The last module is the visualization module, which mainly performs weighted summation of the feature maps extracted from each residual block and fuses them with the original input image to generate an attention map of the original image, indicating where the model focuses on in the prediction decision process, thus realizing the explanation of the prediction results.
[0014] The present invention has the following beneficial effects:
[0015] The present invention provides an interpretable neural network based on a dynamic hierarchical structure. Based on the different characteristics of the shallow and deep layers in the network, different dynamic structure deployments are performed on the network respectively, and the characteristics of different levels are reasonably utilized. On the basis of ensuring the accuracy and interpretability of the network, the network's computing efficiency is improved to a certain extent, and the network's computing resources are saved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 Interpretable neural network based on dynamic hierarchical structure;
[0017] Figure 2 The structural diagram of the early exit discriminator of the present invention;
[0018] Figure 3 The structural diagram of the layer skipping discriminator of the present invention; DETAILED DESCRIPTION
[0019] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0020] This example is conducted on an Ubuntu 18.04 system, with an Intel Xeon E5-1650 CPU, an NVIDIA RTX 3090 GPU (24GB video memory), and 32GB memory. The model is implemented based on the Pytorch framework (pytorch 1.5 version, cuda 10 version), and the Adam optimizer and SGD optimizer (stochastic gradient descent optimizer) are used to optimize the model training process. The parameters used for training are a batch_size of 256, 100 epochs, and the initial learning rate is set to 0.1. During the training process, a strategy of dynamically adjusting the learning rate is adopted. When the model performance (verification accuracy) does not improve, the learning rate is automatically reduced with a strategy of learning_rate*0.9. It takes 4 hours to complete the training task of the entire model, and 1 hour to train only the policy network and dynamic structure.
[0021] This example provides an interpretable neural network based on a dynamic hierarchical structure. The workflow diagram is as follows: Figure 1 As shown, the images of the dataset are first preprocessed through the policy network, and the network is layered according to different images to generate binary vectors for layering. The policy network obtains a confidence vector containing the confidence score of each residual block at one time based on the input sample. The value in the confidence vector represents the importance of each residual block in ResNet (which can be understood as the probability that each block will be retained in the end). This example uses the following criteria to layer the network: take the layer with the minimum value between the layer with the maximum importance trend before the middle layer and the layer with the maximum importance trend after the middle layer.
[0022] Then, use the early exit discriminator and the layer skipping discriminator to judge the features of the image and whether to exit early or skip the layer. The early exit discriminator and the layer skipping discriminator are lightweight networks with the same network structure. The features are first extracted by three convolutional layers. The convolutional layer uses a 3×3 convolution kernel, and then the discrimination results are obtained through the feature dimension reduction layer and the fully connected layer. For the early exit discriminator, the feature dimension reduction layer first uses a function to reduce the dimension of the features generated by the residual block and reconstructs the size of the feature map. The fully connected layer uses the reconstructed feature map as input to generate a probability distribution vector. Then multiple early exit discriminators are cascaded. In the process of generating classification results by any early exit discriminator, not only the feature map provided by the residual block is used, but also the classification result of the previous early exit discriminator is used. If the probability value of the predicted result is large enough, the early exit mechanism is triggered. The process of internal prediction and exit of the early exit discriminator can be referred to. Figure 2For the layer skipping discriminator, the discriminator decides whether to keep or discard the operation results of each residual block in the deep layer of the network, that is, the discriminator finally generates a binary decision. Before generating the result of the binary decision, it is similar to the process of early exiting the discriminator. This process can be referred to Figure 3 .
[0023] Secondly, the stratification results generated by the policy network for the input image in this example are crucial, that is, the criterion for division depends on the contribution of each layer to the final prediction result. Therefore, this example introduces the incentive module of reinforcement learning to encourage contribution vectors that are conducive to stratification and accurate prediction. When the model can accurately predict the results, the policy network is positively incentivized by the maximum weighted average confidence value minus the minimum weighted average confidence value; when the prediction result of the model is wrong, the policy network is penalized by the -γ value (this value can be set according to the actual situation). This incentive function essentially encourages the confidence of each layer generated by the policy network to be more representative, that is, the confidence of the layer that is helpful for prediction is close to 1, and the confidence of the layer that is not helpful for prediction is close to 0. In this way, the policy network can generate a more convincing stratification strategy while ensuring accurate prediction.
[0024] Finally, this example generates an explanation for the prediction results of this method through a visualization module. This module mainly performs weighted summation on the feature maps extracted from each residual block and fuses them with the original input image to generate an attention map of the original image, indicating the position that the model focuses on during the prediction decision process, thereby realizing the explanation of the prediction results.
[0025] Obviously, the described embodiment is only one possible embodiment of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative work are within the scope of protection of the present invention.
Claims
1. An interpretable neural network based on a dynamic hierarchical structure, which first uses a lightweight strategy network to hierarchize the backbone network to distinguish between the shallow and deep layers of the backbone neural network. According to the different features extracted in the shallow and deep layers, an early exit method is deployed in the shallow layer and a layer skipping method is deployed in the deep layer. Shallow features of images mainly include features such as contours, edges, colors, textures, and shapes that can reflect the content of the image; deep features of images mainly tend to be semantic features that can be understood by computers, and no longer rely more on location information. For simple images, it is not necessary to completely extract features through the network. The low-level features extracted by the shallow network are sufficient for correct prediction. At this time, continuing to extract features from the deep layer of the network will waste computing resources and overfitting, so it should be exited from the network in time to obtain correct predictions. For complex images, although features extracted by the deep network are needed, not all features extracted by all layers are helpful for the final prediction. At this time, skipping unnecessary layers in the deep network will improve the network's computing efficiency and prevent overfitting. The specific steps include: First, the images of the dataset are preprocessed through the policy network, and the network is layered according to different images to generate binary vectors for layering. The policy network consists of three convolutional layers, and uses a 3×3 convolution kernel for feature extraction. The features after convolution operation are reduced in dimension, and the binary vectors of the backbone network layers are obtained through a fully connected layer. The vectors are passed to the backbone network to activate the early exit discriminator and the layer skipping discriminator, respectively. Then, the early exit discriminator and layer skip discriminator are used to judge the features of the image and whether to exit early or skip the layer. The early exit discriminator and layer skip discriminator are lightweight networks with the same network structure. The features are first extracted by three convolutional layers. The convolutional layer uses a 3×3 convolution kernel, and then the discrimination results are obtained through the feature dimension reduction layer and the fully connected layer. The early exit discriminator obtains the probability vectors of different categories obtained by the sigmoid function. The category with the highest probability is the prediction obtained by the current early exit discriminator. When the prediction takes a higher value, it exits early. The layer skip discriminator obtains a binary vector of whether to skip the current layer. When the current layer is skipped, the feature value passed by the previous residual block in the ResNet network will be directly passed to the next residual block. The second is the incentive module, which performs back-propagation optimization based on the predictions generated by the early exit discriminator or the final fully connected layer, and uses the idea of reinforcement learning to reward and punish the policy network, thereby ensuring that the stratification of the policy network is based on shallow and deep features, and the stratification results help the network to make correct predictions. The last module is the visualization module, which mainly performs weighted summation of the feature maps extracted from each residual block and fuses them with the original input image to generate an attention map of the original image, indicating where the model focuses on in the prediction decision process, thus realizing the explanation of the prediction results.
2. The interpretable neural network based on a dynamic hierarchical structure according to claim 1, characterized in that: Based on the different characteristics of the shallow and deep layers of the network, different dynamic structures are deployed for the network respectively, and the characteristics of different levels are reasonably utilized. On the basis of ensuring the accuracy and interpretability of the network, the network's computing efficiency is improved to a certain extent, and the network's computing resources are saved.