Two-Stage Contrastive Whole Output Explaination (CWOX-2s)



CWOX-2s (Two-Stage Contrastive Whole-output Explanation) is a novel explanation framework where one can examine the evidence for competing classes, and thereby obtains contrastive explanations for Image Classification (see paper [add link when the paper is released to public] for details and citations). The main part of the codes is based PyTorch, please refer to the requirements.txt for the detailed requirements of package version; The building of hierarchical latent tree model (HLTM) in part A requires Java 11 and Scala 2.12.12. CWOX-2s has a preprocessing step that partitions all class labels into confusion clusters with respect to the classifier to be explained. Classes in each of those clusters (e.g., cello, violin) are confusing to the classifier, and are often competing labels for the same object/region in the input image. CWOX-2s does so by analyzing the co-occurrence of labels in classification results and thereby building a hierarchical latent tree model (HLTM): The codes for learning HLTMs are given in the sub-directory HLTM, along with the structures of the models obtained for ResNet50 and GoogleNet. The HLTM codes output a json file named output_name_fullname.nodes.json, which includes the learned hierarchical latent tree model. The json file is used in the following partition of label confusion clusters. The ResNet50.json in the example code shown below is renamed from the output_name_fullname.nodes.json. When interpreting the output of the classifier on a target image, CWOX-2s obtains a subtree for the top classes by removing from the HLTM all the irrelevant nodes. The top classes are partitioned into Label Confusion Clusters by cutting the subtree at a certain level, the default being the lowest level. This is how the two clusters in Figure 1 are obtained from the tree in Figure 2. For the following discussions, we assume the top classes for an input x are partitioned into clusters: . CWOX-2s requires a base explainer, which can be any existing explanation methods, such as Grad-CAM, MWP, LIME and RISE, that yield nonnegative heatmaps. CWOX-2s first runs the base explainer on the confusion clusters (C_i’s) and the individual classes (c_ij’s), and then combines the base heatmaps to form contrastive heatmaps. A score function is needed in order to produce a base heatmap for a class c. It is usually either the logit of the class (for Grad-CAM and MWP) or the probability of the class (for RISE and LIME). For confusion clusters, the logit is replaced by the generalized logit and the probability is replaced by the probability of the cluster . CWOX.IOX(algo): Produces a base heatmap using explanation method named algo. Currently, algo = “Grad-CAM”, “MWP”, “RISE”, or “LIME” are supported. The following examples illustrate the use of CWOX-2s to explain the results of ResNet50 on one image. The complete code can be found at CWOX_Example.ipynb, and more testing images can be found in the sub-directory eval_image. Application to perform the Contrastive Whole-out Explanation Process. Currently only ResNet50 and GoogleNet for ImageNet Image Classification are supported. See the README page in the sub-directory CWOX_Explainer for the guidelines to use the Application. [summary]


Source link