{'fraction_non_alphanumeric': 0.029098823150088667, 'fraction_numerical': 0.008866677414154442, 'mean_word_length': 4.963229992790195, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
The Weighting Game: Evaluating Quality of Explainability Methods

The objective of this paper is to assess the quality of explanation heatmaps for image classification tasks. To assess the quality of explainability methods, we approach the task through the lens of accuracy and stability. In this work, we make the following contributions. Firstly, we introduce the Weighting Game, which measures how much of a class-guided explanation is contained within the correct class' segmentation mask. Secondly, we introduce a metric for explanation stability, using zooming/panning transformations to measure differences between saliency maps with similar contents. Quantitative experiments are produced, using these new metrics, to evaluate the quality of explanations provided by commonly used CAM methods. The quality of explanations is also contrasted between different model architectures, with findings highlighting the need to consider model architecture when choosing an explainability method.


Introduction
The rise of deep learning in the field of computer vision has seen models become increasingly powerful, however, this has been with the cost of interpretability. Due to this, the field of explainable AI has recently seen a rise into prominence. Several explainability methods have been proposed, which aim to explain what parts of an input image are most relevant to the given output of a model [28,24,3,5,12,9], the output of an explainability method is usually called a saliency map. These methods can be used to evaluate the quality of models' predictions, and especially can be useful when trying to understand incorrect predictions.
Previous works in evaluating saliency maps has found that many explainability methods are independent of the model parameters and labeling of training data, thus rendering them to be simple edge detectors [1]. While it is necessary for an explainability method to be independent of such factors, it does not imply a method is accurate in its explanations, as the sanity checks do not measure how explanations align with input images. Our goal in this paper is to build a    is within the class segmentation mask. Weighting Game aims to better explain, how accurate explanations are by calculating the proportion of the magnitude of the saliency contained within the correct class mask. Class-guided explanations were calculated using ViT-B/32 [6] and Layer-CAM [12] framework for measuring the accuracy and stability of explanations. By accuracy, we refer to the ability of a class-guided explanation to correctly concentrate on the correct class' objects, while with stability we refer to the consistency of explanations when minor transformations are applied to the image.
For assessment of explainability method accuracy, mainly two types of metrics have been presented. Pointing Game [32] measures the accuracy at which a saliency map's highest magnitude pixel is contained within the correct class's segmentation map, thus recording individual instances as either hits or misses. The problem with this method is that the binary nature of the metric does not allow for measuring the quality of hits and misses. An example of the limitations of Pointing Game is shown in Figure.     In both class-guided explanations, Pointing Game counts the explanations as misses, due to barely missing the segmentation mask. Weighting Game is able to correctly identify both explanations as quite accurate. Class-guided explanations were calculated using ViT-B/32 [6] and Layer-CAM [12] equally good, while the one found in Figure 1a seems more concentrated on the correct class compared to the one shown in Figure. 1d.
The second types of methods for measuring explanation accuracy usually operate by removing patches or points from an image, to record how the output changes based on removal of different points [2,13,21]. However, removal based methods tend to introduce unnatural patches into images, which can cause undesired effects into the results, the methods also have the tendency of being more computationally intensive.
In this paper, we extend the idea of Pointing Game and introduce the Weighting Game, which measures how much a saliency map's mass or magnitude is contained within the correct class's segmentation map. The measurement of the distribution of the explanation map allows for more flexibility in assessing the quality of individual explanations, as it is not binary in its nature, such as the Pointing Game. Pointing Game can slightly miss a target and define an expla-nation as a miss, while Weighting Game is able to see the whole picture and give a better representation of the accuracy of the explanation, such as in Figure 2.
For assessing the stability of an explainability method, we introduce two separate methods. Firstly, we create 3D effect videos from an image, and observe the correlation between saliency maps from consecutive frames. With sufficiently small changes between frames, this grants us the ability to assess how minor changes can affect the resulting saliency maps. Secondly, we create a pre-defined zoom and pan transformation on an image, and process saliency maps for the original and transformed images. Then, we measure the correlations between the saliency map for the transformed image and a correspondingly transformed saliency map for the original image. These methods provide a way to assess how consistent explainability methods are, thus giving insights on how well they can function in real-world use cases The main contributions of this work are: (1) The Weighting Game, a novel metric for measuring the accuracy of an explainability method; (2) two novel metrics for assessing the stability of an explainability method; and (3) comparison of several prominent CAM methods using proposed metrics with commonly used image classification architectures.

Related Work
Backpropagation Explainability Methods First methods to visualize network attribution were based on gradients of a model found via backpropagation. These methods include DeConvNet [31], Network Saliency [25], and Guided Backpropagation [28]. The methods have slight difference, however, all are based in the idea of visualizing gradients of a loss function from a forward propagated input image. Later introduced backpropagation methods include SmoothGrad [27], Integrated Gradients [29], and Expected Gradients [7].
Class Activation Explainability Methods The use of class activation maps was first introduced with CAM as a way to visualize the attribution for an output of a network [33]. This was later expanded by Grad-CAM, which used the backpropagated gradients to weight the class activation maps [24]. After Grad-CAM, multiple different methodologies have been introduced to attempt to improve upon Grad-CAM. Notable later CAM methods include, Grad-CAM++ [3], Ablation-CAM [5], Layer-CAM [12], XGrad-CAM [9], and SmoothGrad-CAM++ [19].

Evaluation of Explainability Methods
In 2018, a study into explainability methods was conducted, which determined that most methods were acting as simple edge detectors [1]. The experiments showed that produced saliency maps were mostly independent of the model parameters and labels of the training data, except for notably the saliency maps created using Grad-CAM and DeConvNet. The Pointing Game was introduced as a way to measure the class-sensitivity and Firstly, we obtain the class mask for the image and calculate an explanation for the corresponding class. Then, we dilate the class segmentation mask with the produced explanation, which creates a masked explanation. Finally, the mass of the masked explanation is divided with the mass of the explanation, to obtain the accuracy of an explanation. accuracy of class-guided explainability methods [32]. Finally, ranking methods for pixel importance have been proposed via removal based methods [2,13,21].

Method
We aim to generate methods for assessing how accurate and stable explanations are. For accuracy, the method should be class-specific and concentrated within the segmentation map of an object of the correct class. Stability should be quantified by the consistency of explanations when minor transformations are applied to an image.

The Weighting Game
We defined the Weighting Game as a metric of class-guided explainability method accuracy. The prerequisite for Weighting Game is a dataset, which contains class segmentation masks for the classes that the given model is trained to classify. Thus, object detection datasets, such as Pascal Visual Object Classes 2007 [8] or MS COCO [15], function well for this task.
For calculating one instance of the Weighting Game, we begin with an image and a corresponding class segmentation mask for a class contained within the image. The class segmentation mask is the union of all corresponding class' object segmentation masks found within the image. After obtaining the class segmentation mask, it is dilated using a simple 2D convolution defined with the following equation: where M is the binary class segmentation mask to be dilated, K is a 9 × 9 convolution kernel, and D is the resulting mask. As the resulting mask D is binary, all parts of the mask M that overlap with the convolutional kernel K, will be included in the dilated mask D. The dilation provides the method with more robustness, as outer edges of the desired objects may also be relevant to the classification of the objects. Then, using the class corresponding to the segmentation mask, the classguided explanation is calculated for the image. The resulting explanation is a saliency map, which is either produced in the resolution of the input image or upscaled to it.
The dilated class segmentation mask is then used to measure, how much of the magnitude or mass of the saliency map is contained within the segmentation mask. This gives a measure of how much of the saliency map is contained within the relevant class' area in the image, thus providing a value for the accuracy of an explainability method. One class/image combination of Weighting Game can be formulated with the following equation: where S is the class-guided saliency map and D is the corresponding class' dilated segmentation mask. As Equation.
2 provides the accuracy of one class within an image, it will be used to calculate the accuracy of all class/image combinations in the chosen dataset. The final result of Weighting Game is the mean accuracy of all class/image combinations. A diagram of the process of calculating Weighting Game accuracy is visualized in Figure. 3.

Explanation Stability
Stability of an explainability method can be assessed via the consistency of saliency maps when minor transformations are applied to an image. Thus, this factor is important when, e.g. producing class-guided explanations for videos. Stability can characterize the reliability of an explainability method, as when given similar information to an explainability method, it should produce a similar saliency map. Stability of an explanation method will be assessed via two separate metrics. Firstly, we simulate camera motion by creating 3D effect zoom and pan videos using 3D Ken Burns effect [18]. Artificially created videos are used, as they can Fig. 4: Diagram of explanation stability using a zoom and pan transformation. First, a random resized crop is calculated, which is visualized as red borders in the original image. Then, a class-guided explanation is calculated for the original image, which is then cropped with the same calculated crop. After that, the original image is cropped and a class-guided explanation is calculated for the cropped image. Finally, the correlation between the resulting two saliency maps is calculated. Explanations were processed with class-guided Grad-CAM [24] and ResNet50 [11] using the class 'cat'.
provide a diverse set of videos with a consistent level of motion between frames. This also provides the opportunity to stay within the same distribution of data as in training, as the validation split of the training dataset can be used to generate the videos. The created videos will have 150 frames, of which, the first half consists of a zoom in with ratio 1.5, with the second half consisting of a zoom back to the first frame. Using these videos, we calculate explanations for five pairs of consecutive frames in the video.
The explanations will be processed using class-guided methods, with the chosen class being the highest probability class for the first frame of the video. Then, the correlation between these saliency maps is calculated, to produce a measure for the stability of an explanation method. If the difference between frames is small enough, where the placement of objects is practically the same, the correlation between the saliency maps should be high. The correlations between saliency maps are calculated using Spearman's rank-order correlation [17], as in other literature where correlation between saliency maps is evaluated [23,30]. Thus, the equation used to calculate the stability of a method will be as follows: where M i is the ith frame of a video, c is the highest probability class for frame M 0 , corr is the Spearman rank-order correlation, and e is the class-guided explanation function that takes in an image and a class. The second method for assessing explanation stability is by calculating a zoom, pan, and upscaling (back to original resolution) transformation on an image. After this, saliency maps are calculated for both images. Then, the saliency map for the original image is transformed in the same manner as the transformed image, as the transformation is greater than those seen with the earlier method using consecutive frames of a video. Finally, the correlations are calculated between the saliency map for the transformed image and the transformed saliency map for the original image. Using the same transformation on the original image and the corresponding saliency map, we can align the saliency maps for the original and transformed images. Therefore, the contents are should be the same, however, with different scale in the image. The stability can be expressed with: where t is the zoom/pan transformation function, M is the input image, c is the highest probability class for M , corr is the Spearman rank-order correlation, and e is the class-guided explanation function. A diagram of the stability metric is shown in Figure. 4.

Experiments
In this section, we describe the evaluation of various class-guided explanation methods using our accuracy and stability frameworks. Code to reproduce the experiments is available at https://github.com/lassiraa/weighting-game.

Models and Dataset
The chosen model architectures for experiments are ResNet50 [11], VGG16-BN [26], ViT-B/32 [6], and Swin-T [16]. The models represent some of the most popular architectures from both convolutional and transformer based image classification architectures. The inference times of all models are also comparable, which is why they are desirable to compare to each other. Pre-trained versions of all models were obtained from Torchvision's available models [20]. As all the chosen models are trained on the ImageNet [4] dataset, they need to be fine-tuned in order to be used for the Weighting Game. Thus, the COCO dataset is chosen for fine-tuning the models to a multi-label classification task. The fine-tuning procedure is similar to that of the one implemented in the Pointing Game [32].
Only the weights of the last layer are adjusted in the fine-tuning procedure, using binary cross entropy loss. For the training procedure, random resized crop and horizontal flips are used for data augmentation. For validation, images are center cropped and resized to 224 × 224 resolution. The Adam optimizer [14] is First and third columns processed with ResNet50 [11], Grad-CAM [24], and class 'person', while second and fourth columns were processed with ViT-B/32 [6], Layer-CAM [12], and class 'elephant' used for optimization, using learning rates of 0.001 and 0.002 for the convolutional and transformer models respectively. Exponential learning rate scheduler was used with 0.95 gamma. All models were trained for 50 epochs, at which point the validation losses had plateaued for all models.
For consistency in models and datasets, the COCO validation set is used in all explanation accuracy and stability evaluations. This way, the distribution of the data remains similar in training and evaluation environments, as we are not attempting to measure the out-of-distribution performance of the models or explanation methods. Examples of produced 3D effect videos can be found in the supplementary materials with saliency maps overlaid on the video, such as in Figure 5.

Saliency Methods
The chosen saliency methods to assess in this study were Guided Backpropagation [28], Grad-CAM [24], Grad-CAM++ [3], Layer-CAM [12], XGrad-CAM [9], and Ablation-CAM [5]. All methods have implementations available in the Pytorch Grad-CAM package [10], which provides consistence in implementations. All methods except Ablation-CAM only require one pass through a model, making them computationally efficient, and interesting to determine whether the added computational cost of Ablation-CAM is worth it. Guided Backpropagation provides a baseline for comparison. All methods also satisfy the requirement of being class-guided.
The target layers for the methods are chosen to be from either the last convolutional or transformer block. For ResNet50, the chosen target layers are the layers of the last identity block, while VGG16-BN has the last max pooling layer used as the target layer. Both the ViT-B/32 and Swin-T models have the last transformer block's first layer normalization as the target layer. All saliency maps are upscaled to the input image's resolution using bilinear interpolation. Transformer models' saliency maps are also reshaped from the flattened patches to the shape of the input image.

Results
Weighting Game After calculating the results of the Weighting Game, we obtain mean accuracy results displayed in Table. 1. The table contains results for the Weighting Game using all objects and only objects that are under 10% of the size of the image. Pointing Game [32] scores are also included for comparison.
When results of Weighting Game are compared to the ones of Pointing Game, we can immediately see that the values of Pointing Game are higher, implying that the task of Pointing Game is generally easier. When relative values are compared, it appears that generally CNNs tend to perform better with the chosen explainability methods, when using Pointing Game as the metric. This could be due to the very low resolution of CAM methods when using late layers of CNNs. This is emphasized with for example Figure 5, where saliency maps produced with ResNet50 are much more spread out, when compared to the ones produced by ViT-B/32. Pointing Game fails to quantify this loss in fidelity of saliency maps, as the accuracy values are binary.
Pointing Game is more prone to errors in measuring the accuracy of a saliency map. In cases where the saliency map is mostly concentrated around one point, there is a possibility to narrowly miss the correct segmentation mask, such as in Figure 2. Simultaneously, it fails to quantify cases where the saliency map is distributed all over the image, such as in Figure 6. In these cases, the classification of an explanation as either a hit or a miss is reductive to the quality of the explanation. Additional Pointing Game and Weighting Game visualizations are provided in the supplementary materials. From observing the results of the Weighting Game, it shows that model architecture affects the results significantly, with Grad-Cam/XGrad-CAM functioning the best with CNN-based architectures, while Layer-CAM/Grad-CAM++ show great results with ViT-B/32. Swin-T shows poor results with all saliency methods, except for Ablation-CAM and Layer-CAM. Grad-CAM and Grad-CAM++ show results worse than randomly distributed saliency using Swin-T, which shows that the selection of the target layer could be poor or that the saliency methods simply do not function well with the architecture.
While CAM methods were initially designed for CNNs, they do show promise with vision transformers, as ViT-B/32 has the best results with three out of the five CAM methods. The results highlight the need to consider the model (c) Weighting Game with acc = 19.2%. Fig. 6: Example of Pointing Game's limitations, when saliency map is not concentrated around one central point. Explanation was processed with class-guided XGrad-CAM [9] and Swin-T [16] architecture in the process of choosing a saliency method, as even within the same family of architectures (CNN/ViT), the results vary significantly.
When only small objects (>10% of the size of the image) are considered, the results of the Weighting Game change significantly. Notably, the relative accuracy of Layer-CAM with transformer models improves significantly when compared to other methods. Results of Ablation-CAM can also be seen deteriorating significantly for all model architectures. CNNs perform comparatively better in the Pointing Game, which highlights the lack of the full picture of explanation accuracy when using the Pointing Game as a metric. It does not properly capture, how the explanations are distributed, which can lead to results favoring certain method/model combinations over others.
Explanation Stability Using 3D-Effect Videos Table. 2 shows results of explanation stability using 3D-effect videos and zoom/pan transformations. Ablation-CAM was omitted from the stability experiments due to the high inference time of the method. The results of the video stability show that Grad-CAM++/Layer-CAM are most stable for CNNs, slightly ahead of Grad-CAM/ XGrad-CAM, which are the most accurate in the results of the Weighting Game. This shows that stability does not necessarily result in greater accuracy. However, high stability does seem like a prerequisite for good quality explanations, as all methods with clearly worse stability show poor results in explanation accuracy. Interestingly, ViT-B/32 also shows worse stability with Layer-CAM when contrasted to the CNN models, while the accuracy of the method is significantly superior with ViT-B/32.
Explanation Stability Using Zoom and Pan Transformation Pan and zoom effect transformations were created using a random resized crop with crop scale 0.75-0.9, 1:1 aspect ratio, and bilinear interpolation. For every image in COCO validation split, a random resized crop is applied, and saliency maps for the highest probability class are processed for both images. Then, the same crop is applied for the source image's saliency map. Finally, the correlation is calculated between the cropped saliency map and the cropped image's saliency maps, as the saliency maps should align at this point. Table. 2 shows the mean correlations for the method/model combinations.
The mean correlations are significantly lower than those found in the consecutive frames approach, which is sensible as the step taken in this method is far greater. However, the ranks of results also change significantly. Notably, the relative stability of transformer models drops clearly. This effect is especially seen with Layer-CAM and Guided Backpropagation, however, it is present with all other methods. The reason for this behavior could be explained via how the receptive fields operate within transformer based models. This is due to transformer receptive fields being more concentrated locally, when contrasting ViT-B/32 and ResNet50 receptive fields at later layers [22]. More concentrated receptive field could yield to results that are less stable, but perhaps more capable of correctly explaining smaller objects, as seen in results of the Weighting Game with small objects in Table. 1.

Conclusion
We introduced a new method for more comprehensively assessing the accuracy of a class-guided saliency method, which calculates how much of the weight is contained within the correct class' segmentation mask. We also introduced two ways of assessing an explanation method's stability via transforming an image, either by a sufficiently small transformation or by a slightly larger zoom and pan operation. Our experiments show that, generally, sufficient stability is a prereq-uisite for accurate saliency maps. However, better stability does not always yield better results in explanation accuracy, as especially small objects are not always detected well with highly stable methods. We also highlight the importance of considering model architecture when choosing a saliency method, as the choice of model architecture can significantly affect which saliency methods give the best results.