An interpretable method for image classification based on neural support decision trees
By combining Grad-CAM and NBDT methods, a V-NBDT image classification method is constructed, which generates heatmaps and tree structure visual interpretations on the decision-making chain. This solves the problem of the difficulty in interpreting the decision-making process of image classification models and achieves a logically clear and intuitive decision interpretation effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2021-11-09
- Publication Date
- 2026-05-08
AI Technical Summary
The decision-making process of existing image classification models is difficult to explain, especially the decision-making mechanism of convolutional neural networks, which lacks intuitive visualization. Furthermore, existing methods cannot meet the needs of both outcome-based and process-based explanations.
By combining Grad-CAM and NBDT methods, a neural support decision tree-based image classification method (V-NBDT) is constructed. The decision-making process of the image classification task is demonstrated by generating heatmaps on the decision chain and visual interpretations of the tree structure.
It provides a progressive and logically clear visual explanation that can display key decision-making areas when the classification is correct and intuitively find the reasons for decision-making errors when they are incorrect, thereby increasing users' trust and understanding of the model.
Smart Images

Figure CN114037871B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image classification, and in particular relates to an interpretable image classification method, V-NBDT, based on neural support decision trees. Background Technology
[0002] Artificial intelligence (AI) in the context of deep learning has demonstrated significant advantages in handling decision-making related to images, text, and speech, continuously inspiring enterprises and governments to build AI-related systems across various fields. Currently, most AI research still focuses on the accuracy and complexity of model algorithms. Complex models can make precise decisions in specific situations, even surpassing human capabilities, but end-users often struggle to understand the process and reasons behind these decisions, reducing user trust in the models. This end-to-end lack of interpretability hinders the optimization and improvement of intelligent decision-making systems. How to balance model performance with providing explanations of decision results to gain the trust of decision-makers has become a key research direction in the field of AI in recent years—Explainable Artificial Intelligence (XAI). AI interpretability can be broadly categorized into two types: pre-event interpretability and post-event interpretability. Ex-ante interpretability refers to the interpretability of a model existing before training; it is built into the model itself, such as simple logistic regression models or decision tree models. Alternatively, interpretability can be built into the entire model through custom design, such as by incorporating an attention mechanism into the model design. Ex-post interpretability refers to the interpretability of a model existing after training. Given a trained model, different methods such as rule extraction and model distillation are used to explore the internal operating mechanism of the model and provide an explanation. For key fields such as defense, law, finance, and medicine, explainable AI-generated decision explanations can help users understand the reasons for decisions and, to some extent, avoid certain uncontrollable risks. The guidelines for "Big Data-Driven Management and Decision Research" issued by the Management Science Department of the National Natural Science Foundation of China point out that key projects should focus on the theory and methods of big data analysis for management decision-making, including issues such as the interpretability of AI methods, highlighting the importance of this field.
[0003] Convolutional neural networks (CNNs) are widely used in image classification tasks, where inputting an image into the network yields a category determination. To enable users to understand the underlying mechanisms of decision-making from a perceptual perspective, some ex post-hoc interpretable methods, inspired by model structural features, generate saliency maps to explain decisions by visualizing key decision regions. Similar methods using image data itself as the interpreter include local perturbation (local occlusion maps), backpropagation (scatter plots), and activation mapping (heatmaps). These methods tend to provide only a single saliency map for interpretation; in contrast, decision trees possess a structure more aligned with human thought and judgment, effectively helping users understand the hierarchy and process of model decision-making. Image data-driven model decision-making, through iteration, optimization, and fusion of different methods, provides higher-quality explanations for decisions, promoting the development of interpretable artificial intelligence.
[0004] This invention is inspired by two interpretable methods for image classification tasks: visual interpretation methods represented by activation mapping (CAM) and tree-structure interpretation methods represented by neural support decision trees (NBDT). The former, CAM-type methods, first proposed by the MIT team, are characterized by using the decision salient regions of a single image for interpretation. This interpretation, presented as a heatmap, intuitively and clearly shows the image locations that the network focuses on when making classification decisions. The biggest problem with this method is that interpreting decisions solely through heatmaps is too result-oriented; while it reflects the image regions the neural network focuses on, it lacks depth of explanation and a presentation of the decision-making process. The latter, NBDT-type methods, developed by the Berkeley team, borrow from the characteristics of logic trees that align with human thinking, cleverly embedding decision trees into neural networks. This presents the complex model's decision-making process to the user in a tree-like form, generating a hierarchical and process-oriented visual explanation. The problem with this method is that the information in the nodes of the tree structure only contains decision probabilities; behind the clear logic lies a lack of intuitive visual explanation, making it difficult to understand which image information the node focused on during the decision-making process. Therefore, this invention, after recognizing the intuitive visualization of CAM and the hierarchical tree structure of NBDT, as well as the shortcomings of CAM lacking interpretive depth and NBDT lacking visual interpretation, integrates these characteristics. Based on the implementation principles of Grad-CAM and NBDT, it conducts reasoning while taking into account the result-oriented nature of the former and the process-oriented nature of the latter, and designs a V-NBDT visual interpretation that integrates the two methods. "V" stands for Visualization, which means generating a visual interpretation of internal nodes within the Neural Supported Decision Tree (NBDT) framework, thus obtaining a more user-friendly decision interpretation for end users. Summary of the Invention
[0005] The purpose of this invention is to provide a method that can both hierarchically display the decision-making process of image classification tasks in a tree structure and generate intuitive heatmaps on the hierarchical decision-making chain to show the visual interpretation of the important regions that different nodes focus on in their decisions. The method uses NBDT to construct a decision tree embedded in a CNN network, uses CNN to extract feature vectors from the image to be tested and generate classification decision-making chains on the tree structure, and uses Grad-CAM probability weighted mapping feature maps of leaf nodes to generate heatmaps of each node on the decision-making chain, highlighting the important regions on the input image that affect the decision of that node.
[0006] The technical solution adopted in this invention is: an interpretable image classification method based on neural support decision trees, which includes the following steps:
[0007] Step 1) Obtain the trained CNN for the image classification task and extract its fully connected layer parameter vectors;
[0008] Step 2) Treat the parameter vector of the fully connected layer as the representative vector of the leaf node, and use aggregate hierarchical clustering to continuously find similar nodes and generate parent nodes and their representative vectors until the root node, to obtain the neural support decision tree embedded in the CNN.
[0009] Step 3) Input the image to be tested into the CNN model and obtain the feature vector before the fully connected layer as the image feature vector;
[0010] Step 4) Input the image feature vector into the neural support decision tree to obtain a decision link from the root node to the leaf node and the decision discrimination probability of each node;
[0011] Step 5) Use Grad-CAM to calculate the heatmap of all leaf nodes under different intermediate nodes on the link, and weight and superimpose them according to the probability of similar leaf nodes. Finally, output a visual interpretation that combines the heatmap and decision tree.
[0012] Further, step 2) specifically includes:
[0013] CNN network fully connected layer parameters The nodes are split into m d-dimensional vectors, which serve as representative vectors for initializing leaf nodes. Agglomerative hierarchical clustering is then used to find two similar leaf nodes. The calculation process is shown in the following formula:
[0014]
[0015] distance(l i ,l j ) = euclidean(l i ,l j )
[0016] Where, N leaf This represents the set of all initialized leaf node vectors, and the number of leaf nodes is m, which is the number of categories in the classification task. Represents the set of leaf nodes N leaf The leaf node i in the vector, euclidean represents the computation of The Euclidean distance between vectors, as shown in the above formula, indicates that the two leaf nodes with the closest relative distance are selected as the left and right child nodes, sharing the same parent node. After finding two similar leaf nodes, their parent node can be determined, using the left leaf node l. left and right leaf node l right The mean of the representative vectors is used as the representative vector of parent node j; the same method is used to continue clustering all parent nodes, finding the grandparent node of similar parent nodes, and using the mean of the representative vectors of all leaf nodes under the left and right subtrees as the representative vector of the grandparent node. This process is repeated from bottom to top until the root node, resulting in a binary decision tree T where each node contains its representative vector. The calculation process is shown in the following formula:
[0017]
[0018] Where, N j This represents the set of all n leaf nodes contained in the left and right subtrees of the middle node j (a non-leaf node). The representative vector representing the intermediate node j (non-leaf node).
[0019] Furthermore, step 3) specifically includes:
[0020] Input the preprocessed test image image The vectors input into the CNN model before entering the fully connected layer are extracted as image features. The calculation process is shown in the following formula:
[0021] x = CNN(Input) image )
[0022] Wherein, CNN represents the trained convolutional neural network model, and Input... image This represents the preprocessed input image tensor. This represents the feature vector representation after features are extracted by CNN.
[0023] Further, step 4) specifically includes:
[0024] Input the extracted image feature vector x into the neural support decision tree T obtained in step 2). Since entering the decision tree requires passing through the root node, the root node probability is 1. Input the representative vectors w of the two child nodes to the left and right of the root node. left ,wright With feature vectors Perform an inner product to calculate the selection probabilities of the two nodes. Mark the child node with the higher probability as a decision link node and enter that node. Continue to examine the probability values of its left and right child nodes, and repeat the above decision selection process until the bottom leaf node is reached. This generates a decision link (decisions) from the root node to the bottom leaf node, where the i-th node on the link contains the predicted probability value p of that node. i The specific probability p i The calculation process is shown in the following formula:
[0025] [p left ,p right ] = softmax([ <w left ,x>, <w right ,x>])
[0026] in These represent the probabilities of selecting the left and right child nodes of the node being entered. These are the representative vectors of the left and right child nodes of the entering node, respectively. The vector is the feature vector of the image to be tested after feature extraction by CNN, <·> represents the inner product operation of the vectors, and softmax refers to the softmax function calculation.
[0027] Further, step 5) specifically includes:
[0028] Before generating a heatmap for each node in the decision chain, the Grad-CAM method needs to be used to generate class activation mapping feature maps for all leaf nodes. First, calculate the probability p of leaf node c. c For feature map A of the last convolutional layer of the CNN network k The gradient of the feature map A is obtained by averaging the gradient information obtained from different pixels. k The neuron importance weights for leaf node c The k feature maps of the last convolutional layer are weighted using the importance weights of neurons, and positive values on the feature maps are retained to obtain the generation class activation map feature map of leaf node c. The specific calculation process is as follows:
[0029]
[0030]
[0031] in The number of pixels in the feature map. This is a global average pooling operation. Let c be the decision probability of leaf node c. This represents the pixel value at position (r, s) in the k-th feature map. To utilize the gradient information calculated through backpropagation, ReLU is used to correct the linear unit. The class activation map feature maps for all leaf nodes are then calculated. Then, re-enter the root node of decision tree T, and superimpose the class activation map feature maps of all leaf nodes contained in its left and right subtrees to obtain superimposed class activation map feature maps of the left and right subtrees respectively. Then, use the probabilities of the left and right child nodes as weights to perform a second weighted superposition of the two superimposed feature maps, and finally obtain the class activation map feature map of the next decision node of the root node. The important region of focus when making a decision from the root node to the next node is the source of visual interpretation. The process of calculating the feature maps of the left and right subtrees is repeated after entering the next node in the decision chain, until the leaf node, to obtain the category activation mapping feature map for each node in the decision chain. The specific calculation process is shown in the following formula:
[0032]
[0033] in The category activation map feature map representing leaf node c, C left C right These represent the sets of leaf nodes contained in the left and right subtrees of decision node j, respectively. These represent the selection probabilities of entering the left and right child nodes of decision node j, respectively; ReLU refers to the modified linear unit; the feature map is mapped using class activation. A resize operation is performed to generate a heatmap of the same size as the original image. This heatmap can then be used to highlight important regions in the input image that influence the decision of that node. The heatmap and the probability are then embedded into a visualized decision tree to obtain a visual interpretation result.
[0034] The beneficial effects of this invention are:
[0035] This invention addresses the decision-making process in image classification tasks. Combining the results-oriented approach of Grad-CAM with the process-oriented and hierarchical approach of NBDT, it designs the V-NBDT method. This method outputs a class saliency heatmap for each node in the decision chain, which, in conjunction with a decision tree, generates a progressive and logically clear visual interpretation. The proposed method can generate clear visual interpretations of classification decisions in scenarios such as CIFAR10 and aircraft classification datasets. It not only helps understand the key regions that CNNs and NBDTs focus on when classification is correct, but also intuitively and conveniently identifies the reasons for errors in decision-making at specific nodes when classification is incorrect. This information aids in the optimization of the network and dataset, providing a more user-friendly decision interpretation for end users. Attached Figure Description
[0036] Figure 1This is an architectural diagram of the method proposed in this invention.
[0037] Figure 2 , Figure 3 The images show the interpretation effects of the NBDT interpretation method referenced in this invention and the V-NBDT method proposed in this invention on the same input image. The sample images are from the CIFAR10 dataset, and the CNN model is WideResNet28 trained on the CIFAR10 dataset.
[0038] Figure 4 The illustration shows the effect of the proposed method on example images outside the CIFAR100 dataset. The sample images are from the CIFAR100 dataset, and the CNN model is WideResNet28 trained on the CIFAR10 dataset.
[0039] Figure 5 To illustrate the effectiveness of the proposed method in a specific scenario, the sample images are from an aircraft classification dataset constructed by a web crawler, and the CNN model is a ResNet18 trained on this dataset. Detailed Implementation
[0040] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0041] like Figure 1 As shown, this invention provides an interpretable image classification method based on neural support decision trees (V-NBDT), which specifically includes the following steps:
[0042] Step 1) Train a CNN for the image classification task and extract the parameters of the fully connected layers as input.
[0043] Step 2) Treat the fully connected layer as the representative vector of the leaf node, and use hierarchical clustering to continuously find similar nodes and generate parent nodes and their representative vectors until the root node, thus obtaining the neural support decision tree embedded in the CNN; specifically:
[0044] CNN network fully connected layer parameters The nodes are split into m d-dimensional vectors, which serve as representative vectors for initializing leaf nodes. Agglomerative hierarchical clustering is then used to find two similar leaf nodes. The calculation process is shown in the following formula:
[0045]
[0046] distance(l i ,l j ) = euclidean(l i ,l j)
[0047] Where, N leaf This represents the set of all initialized leaf node vectors, and the number of leaf nodes is m, which is the number of categories in the classification task. Represents the set of leaf nodes N leaf In the leaf node i, euclidean represents the computation The Euclidean distance between vectors, as shown in the above formula, represents selecting the two leaf nodes with the closest relative distance as their left and right child nodes, sharing the same parent node. After finding two similar leaf nodes, their parent node can be determined. The average of the representative vectors of the left and right leaf nodes is used as the representative vector of the parent node j. Clustering is then performed on all parent nodes using the same method as above, finding the grandparent node of the similar parent nodes, and using the average of the representative vectors of all leaf nodes under the left and right subtrees as the representative vector of the grandparent node. This process is repeated from bottom to top until the root node, resulting in a binary decision tree T where each node contains its representative vector. The calculation process is shown in the following formula:
[0048]
[0049] Where, N j This represents the set of all n leaf nodes contained in the left and right subtrees of the middle node j (a non-leaf node). The representative vector representing the intermediate node j (a non-leaf node). The representative vector of the leaf node.
[0050] Step 3) Input the image to be tested into the CNN model to obtain the feature vector before the fully connected layer; specifically:
[0051] Input the preprocessed test image image The vectors input into the CNN model before entering the fully connected layer are extracted as image features. The calculation process is shown in the following formula:
[0052] x=CNN(Input image )
[0053] Wherein, CNN represents the trained convolutional neural network model, and Input... image This represents the preprocessed input image tensor. This represents the feature vector representation after features are extracted by CNN.
[0054] Step 4) Input the image feature vector into the decision tree to obtain a decision path from the root node to the leaf node and the decision probability of each node; specifically:
[0055] The extracted image feature vector x is input into the neural support decision tree T obtained in step 2). Since entering the decision tree requires passing through the root node, the root node has a probability of 1. The representative vectors w of the two child nodes to the left and right of the root node are then used. left ,w right With feature vectors Perform an inner product to calculate the selection probabilities of the two nodes. Mark the child node with the higher probability as a decision link node and enter that node. Continue to examine the probability values of its two child nodes to the left and right, and repeat the above decision selection process until a leaf node is reached. This generates a decision link (decisions) from the root node to the bottom leaf node, where each node in the link contains its predicted probability value p. i The specific probability p i The calculation process is shown in the following formula:
[0056] [p left ,p right ] = softmax([ <w left ,x>, <w right ,x>])
[0057] in These represent the probabilities of selecting the left and right child nodes of the node being entered. These are the representative vectors of the left and right child nodes of the entering node, respectively. The vector is the feature vector of the image to be tested after feature extraction by CNN, <·> is the inner product operation of the vectors, and softmax refers to the softmax function calculation.
[0058] Step 5) Calculate the heatmap of all leaf nodes under different intermediate nodes on the link using Grad-CAM, and weight the heatmaps according to the probabilities of the left and right subtrees. The final output is a V-NBDT visual interpretation combining the heatmap and the decision tree; specifically:
[0059] Before generating a heatmap for each node in the decision chain, the Grad-CAM method needs to be used to generate class activation mapping feature maps for all leaf nodes. First, calculate the probability p of leaf node c. c For feature map A of the last convolutional layer of the CNN network k The gradient is calculated, and the gradient information obtained from different pixels is averaged to obtain the feature map A. k The neuron importance weights for leaf node c The k feature maps of the last convolutional layer are weighted using the importance weights of neurons, and positive values on the feature maps are retained to obtain the generation class activation map feature map of leaf node c. The specific calculation process is as follows:
[0060]
[0061]
[0062] in The number of pixels in the feature map. This is a global average pooling operation. Let c be the decision probability of leaf node c. This represents the pixel value at position (r, s) in the k-th feature map. To utilize the gradient information calculated through backpropagation, ReLU is used to correct the linear unit. The class activation map feature maps for all leaf nodes are then calculated. Then, re-enter the root node of decision tree T, and superimpose the class activation map feature maps of all leaf nodes contained in its left and right subtrees to obtain superimposed class activation map feature maps of the left and right subtrees respectively. Then, use the probabilities of the left and right child nodes as weights to perform a second weighted superposition of the two superimposed feature maps, and finally obtain the class activation map feature map of the next decision node of the root node. This refers to the important region that the root node focuses on when making a decision to move to the next node, which is also the source of visual interpretation for the method disclosed in this invention. Continuing to the next node in the decision chain, the above calculation process for the feature maps of the left and right subtrees is repeated until the leaf node, thus obtaining the category activation mapping feature map for each node in the decision chain. The specific calculation process is shown in the following formula:
[0063]
[0064] in The category activation map feature map representing leaf node c, C left C right These represent the sets of leaf nodes contained in the left and right subtrees of decision node j, respectively. and represent the selection probabilities of entering the left and right child nodes of decision node j, respectively. ReLU refers to the modified linear unit. Further, the category activation mapping feature map is utilized. A resize operation is performed to generate a heatmap of the same size as the original image. This heatmap can then be used to highlight important regions in the input image that affect the decision of that node. The heatmap and the probability are then embedded into a visualized decision tree to obtain the V-NBDT visual interpretation results.
[0065] Example:
[0066] A dataset of images of 10 types of passenger and fighter jets obtained through web crawling was constructed. The ResNet18 network structure was fine-tuned and trained on the dataset. The trained network was then embedded into a decision tree. The proposed V-NBDT method was then deployed for specific cases, and the detailed steps are as follows:
[0067] 1) All aircraft images obtained through web scraping were organized and labeled to construct a dataset for specific scenarios. This dataset mainly includes different models of passenger aircraft: A320, A380-800, B707, and B747-300, as well as fighter jets from different countries: Russian MiG-21, French Rafale, American F-22, American F-35, Swedish JAS-39, and Chinese J-20. The training set contains 2442 images, the validation set contains 300 images, and the test set contains 296 images.
[0068] 2) Use Python to load the ResNet-18 network structure that comes with the torchvision.models open source package as the training model, modify the output size of the fully connected layer to 10, keep the rest of the network structure, construct the cross-entropy loss function, and use stochastic gradient descent to iteratively optimize the model parameters.
[0069] 3) Through multiple training iterations on the GPU, the number of training iterations was set to 100, the batch size to 125, and the initial learning rate to 0.001. The batch size was gradually reduced by multiples of 10 every 7 iterations. After each round of training, the loss and accuracy of the test set were calculated, and the model with the highest accuracy (Accuracy = 75.54%) was saved as the optimal model.
[0070] 4) Read and call the parameters of each layer of the model, use Python to load the AgglomerativeClustering method under the sklearn.cluster open source package to perform hierarchical clustering on the weight matrix of the fully connected layer, and use the networkx package to build a decision tree embedded in the network model. Each node of the decision tree records information such as parent node, child node, node representative vector, node code, and node category.
[0071] 5) Re-call the trained model for the purpose of feature extraction, randomly select an image from the database, perform necessary preprocessing (Resize & Normalize), and input it into the model to obtain the vector after feature extraction.
[0072] 6) Input the feature vector into the decision tree and traverse it. Perform an inner product with the node representative vector and select the node with the higher probability as the decision link node to generate the decision link. Each node in the decision link contains records of the selection probabilities of the left and right child nodes under that node, all leaf nodes contained in the left and right subtrees, the previous decision node, the next decision node, etc.
[0073] 7) Traverse the decision chain, call the ResNet18 model again at each node, and register forward and backward hooks for the last convolutional layer to obtain the gradient information of the image during forward computation and backward propagation. At the same time, weight the class loss of the left and right subtrees containing leaf nodes under that node and sum them. The weights are the probability values of the left and right child nodes. Finally, the results are summed to obtain the gradient and feature map information required for Grad-CAM calculation.
[0074] 8) Use the summed gradient information and feature map of each node in the decision chain to generate the Grad-CAM heatmap, obtain an activation feature map of the same size as the feature map, use the resize method in the cv2 open source package in Python to enlarge the 7x7 feature map to the original image size, and overlay it with the original image to obtain the heatmap of the focus of the node in making the decision.
[0075] 9) Visualize the stored decision tree, decision chain, decision probability, and node heatmap on an HTML page. This provides a visual explanation of the classification decision for the input image, completing the V-NBDT instance deployment. To test the classification explanation performance of other images on the same model and dataset, simply start from step 5.
[0076] Figure 2 , Figure 3 The images show the interpretation effects of the NBDT interpretation method referenced in this invention and the V-NBDT method proposed in this invention on the same input image. The sample images are from the CIFAR10 dataset, and the CNN model is a WideResNet28 trained on the CIFAR10 dataset. Overall, the original NBDT method only includes decision links and decision probabilities, and cannot show the important regions that nodes focus on during the decision-making process for specific instances. While both are decision tree methods, the method proposed in this invention can generate corresponding heatmaps for decision link nodes, clearly showing the key points of decision focus, making it more intuitive compared to the original method.
[0077] Figure 4This paper presents the interpretation effect of the proposed method on example images outside the CIFAR-10 dataset. The sample images are from the CIFAR-100 dataset, and the CNN model is WideResNet28 trained on the CIFAR-10 dataset. While both are decision tree interpretation methods, the original NBDT method only provides class probability when the model encounters images outside the CIFAR-10 database categories, which cannot meet the user's need for explanation of classification errors. However, the proposed method can visualize the image region of interest in the classification error through node decision visualization. For example, in the image, if an "elephant" is misclassified as a "cat," the node visualization shows that the decision process focuses on the forelimbs, which are structurally similar to those of a cat.
[0078] Figure 5 To illustrate the effectiveness of the proposed method in a specific scenario, the sample images are from an aircraft classification dataset constructed by a web crawler, and the CNN model is a ResNet18 trained on this dataset. In real-world scenarios, this invention can intuitively demonstrate the reasons for misclassification in certain categories. Due to interfering watermarks in the images, the decision to move upwards to the "J20" parent node is incorrectly guided downwards with a probability of 61.56%. This invention also captures instances where text and noise interference exist in certain images in the training set, providing information support for target users to optimize the network and dataset.
[0079] Therefore, the method proposed in this invention not only surpasses the single NBDT method and Grad-CAM method in terms of explanation effect, but also has significant advantages in practical deployment. It can generate visual explanations based on decision trees and visualize nodes for correct and incorrect judgments, and the explanation effect is more user-friendly for AI developers and users.
[0080] The above embodiments are used to explain and illustrate the present invention, but not to limit the present invention. Any modifications and changes made to the present invention within the spirit and scope of the claims shall fall within the protection scope of the present invention.
Claims
1. An interpretable image classification method based on neural support decision trees, characterized in that, The method includes the following steps: Step 1) Obtain the trained CNN for the image classification task and extract its fully connected layer parameter vectors; Step 2) Treat the parameter vector of the fully connected layer as the representative vector of the leaf node, and use aggregate hierarchical clustering to continuously find similar nodes and generate parent nodes and their representative vectors until the root node, to obtain the neural support decision tree embedded in the CNN. Step 3) Input the image to be tested into the CNN model and obtain the feature vector before the fully connected layer as the image feature vector; Step 4) Input the image feature vector into the neural support decision tree to obtain a decision link from the root node to the leaf node, and obtain the selection probability of each intermediate node on the decision link entering the left child node and entering the right child node. Step 5) Calculate the heatmap of all leaf nodes under different intermediate nodes on the link using Grad-CAM, and weight and superimpose them according to the probability of similar leaf nodes. The final output is a visual interpretation combining the heatmap and the decision tree; specifically: Before generating a heatmap for each node in the decision chain, the Grad-CAM method needs to be used to generate class activation mapping feature maps for all leaf nodes. First, calculate the leaf nodes. probability For the feature map of the last convolutional layer of the CNN network The gradient is calculated, and the gradient information obtained from different pixels is averaged to obtain the feature map. For leaf nodes Neuron importance weights And utilize the importance weights of neurons in the last convolutional layer The feature maps are weighted, and finally, positive values on the feature maps are retained to obtain the leaf nodes. Generate category activation mapping feature map The specific calculation process is as follows: in The number of pixels in the feature map. This is a global average pooling operation. leaf node The decision probability, Representing the Feature map Pixel value at position, In order to utilize the gradient information calculated by backpropagation, Refers to the modified linear unit; Calculate the category activation mapping feature map of all leaf nodes. Then, re-enter the decision tree. The root node is used as the basis for superimposing the class activation map feature maps of all leaf nodes contained in its left and right subtrees. This results in superimposed class activation map feature maps for the left and right subtrees. Then, the probabilities of the left and right child nodes are used as weights to perform a second weighted superposition of the two superimposed feature maps, ultimately yielding the class activation map feature map for the next decision node from the root node. This refers to the important region that is considered when making decisions from the root node to the next node, i.e., the source of visual interpretation. Continuing to the next node in the decision chain, the above calculation process for the feature maps of the left and right subtrees is repeated until the leaf node, obtaining the category activation mapping feature map for each node in the decision chain. The specific calculation process is shown in the following formula: in Representing leaf nodes Category activation mapping feature map, Representing decision nodes The set of leaf nodes contained in the left and right subtrees. These represent entering the decision-making node. The probability of choosing the left and right child nodes Refers to the modified linear unit; Using category activation mapping feature maps A resize operation is performed to generate a heatmap of the same size as the original image. This heatmap can then be used to highlight important regions in the input image that influence the decision of that node. The heatmap and the probability are then embedded into a visualized decision tree to obtain a visual interpretation result.
2. The interpretable image classification method based on neural support decision trees according to claim 1, characterized in that: Step 2) specifically refers to: CNN network fully connected layer parameters Split into indivual A dimensional vector, used as the representative vector for initializing leaf nodes, is used to find two similar leaf nodes using the Agglomerative Hierarchical Clustering algorithm. The calculation process is shown in the following formula: in, Let represent the set of all initialized leaf node representative vectors, and the number of leaf nodes is . That is, the number of categories in the classification task. Represents the set of leaf nodes leaf nodes in The representative vector, Representative calculation The Euclidean distance between vectors, as shown in the above formula, indicates that the two leaf nodes with the closest relative distance are selected as the left and right child nodes, sharing the same parent node; after finding two similar leaf nodes, their parent node can be determined, using the left leaf node. and right leaf node The mean of the representative vector is used as the parent node. The representative vector of the grandfather node is obtained by clustering all parent nodes in the same way, finding the grandfather node of similar parent nodes, and using the average of the representative vectors of all leaf nodes under the left and right subtrees as the representative vector of the grandfather node; repeat the above process from bottom to top until the root node, to obtain a binary decision tree. Each node contains its representative vector, and the calculation process is shown in the following formula: in, Represents intermediate nodes All contained under the left and right subtrees A set of leaf nodes Represents intermediate nodes The representative vector.
3. The interpretable image classification method based on neural support decision trees according to claim 1, characterized in that: Step 3) specifically refers to: The pre-processed test image The vectors input into the CNN model before entering the fully connected layer are extracted as image features. The calculation process is shown in the following formula: Here, CNN represents a trained convolutional neural network model. This represents the preprocessed input image tensor. This represents the feature vector representation after features are extracted by CNN.
4. The interpretable image classification method based on neural support decision trees according to claim 1, characterized in that: Step 4) specifically refers to: Extracted image feature vectors Input the neural support decision tree obtained in step 2). Since entering a decision tree requires passing through the root node, the probability of entering the root node is 1; the representative vectors of the two child nodes to the left and right of the root node are... With feature vectors Perform an inner product to calculate the selection probabilities of the two nodes. Mark the child node with the higher selection probability as a decision link node and enter that node. Continue to examine the probability values of its left and right child nodes, and repeat the above decision selection process until the bottom leaf node is reached, thus generating a decision link from the root node to the bottom leaf node. And the i-th node on the link contains the predicted probability value of that node. ; specific probability The calculation process is shown in the following formula: in These represent the probabilities of selecting the left and right child nodes of the node being entered. These are the representative vectors of the left and right child nodes of the entering node, respectively. The feature vector is the image to be tested after features are extracted by CNN. This is the dot product operation for vectors. This refers to the calculation using the softmax function.