Introduction
Standard methods for interpreting Convolutional Neural Networks (CNNs) often involve masking regions of an input image to observe changes in model output. However, this approach frequently introduces "missingness bias," where the network reacts to the artificial edges or colors of the mask itself rather than the remaining visual content. This distribution shift—seeing patterns like sharp black squares that were absent during training—can lead models to misidentify features or "cheat" by inferring objects from the mask's shape. While Vision Transformers (ViTs) mitigate this by dropping tokens, CNNs lack a native mechanism to ignore regions without creating distracting artifacts.
Methodology: Layer Masking
To address these issues, we introduce Layer Masking, a technique that integrates the masking process directly into the CNN's internal architecture. Instead of applying a static mask only at the input level, the mask is propagated through every layer of the network.
Intermediate Masking and Propagation
The core of the method involves propagating the mask alongside feature maps. For each convolutional or pooling layer, the model only computes outputs based on "unmasked" regions. The mask itself is downsampled using max-pooling to match the spatial dimensions of the feature maps at each layer, ensuring that if even a single pixel in a receptive field is "visible," the corresponding output is considered unmasked.
Neighbor Padding
A critical component of this approach is Neighbor Padding. Standard zero-padding at mask boundaries creates sharp transitions that trigger edge-detection filters, leading to "ghost" activations. Our method iteratively fills the masked boundary with the average value of its immediate non-zero neighbors. This process "smudges" the edges, maintaining a more natural distribution for the model's internal filters.
Experimental Evaluation
The proposed method was evaluated on ImageNet benchmarks to assess robustness and interpretability.
Robustness and Shape Independence
Layer Masking significantly enhances model robustness. A ResNet-50 equipped with this technique maintained over 70% top-1 accuracy on ImageNet even when 50% of input patches were randomly removed—a scenario where standard black-out masking causes performance to plummet. Furthermore, "broken mask" experiments demonstrated that Layer Masking reduces reliance on the specific geometry of the masked region, effectively blinding the model to the mask's shape.
Interpretability with LIME
When integrated with interpretability tools like LIME, Layer Masking produces explanations that align more closely with human intuition. Quantitatively, the method achieved superior Alignment Scores and Jaccard Similarity compared to traditional black-out or grey-out baselines, indicating that the generated saliency maps more accurately reflect the features the model actually uses for prediction.
Conclusion
Layer Masking bridges the robustness gap between CNNs and ViTs by providing a principled way to handle missing data. By eliminating edge artifacts through neighbor padding and propagating masks through the hierarchy, we reduce missingness bias and improve the reliability of model explanations. Future work may explore using Layer Masking during training as a form of data augmentation to further harden models against spurious correlations.
Summary updated