Occlusion sensitivity

Also known as: occlusion analysis

On this page 7

Occlusion sensitivity is a perturbation-based explanation method that measures how much a model output changes when parts of the input are systematically hidden. In explainable AI, it produces a heatmap in which each region is scored by the drop in the predicted class score caused by masking that region, so the brightest areas are those the model relies on most.

The technique, also called occlusion analysis, was popularized for convolutional image classifiers in 2014 and is model-agnostic: it needs only the ability to run the model forward and read its outputs. It works for images, text, tabular records and time series, although images remain its most common use.

How occlusion sensitivity is computed

Occlusion sensitivity is computed by sliding a masking window across the input, replacing the covered values with a baseline, and recording the change in the target output at each position. The procedure involves no gradients and treats the model as a black box.

  1. Run the model on the original input and record the score for the class of interest, usually the predicted class or a class chosen for investigation.
  2. Place a patch of fixed size, for example 16 by 16 pixels, at the first position and fill it with a baseline value.
  3. Run the model again and store the score difference for that position.
  4. Move the patch by the stride and repeat until the whole input is covered.
  5. Average overlapping differences per pixel to produce the sensitivity map.

A positive difference means the hidden region supported the prediction; a negative difference means hiding it actually raised the score, which suggests the region contained counter-evidence. Reporting both signs gives a more honest picture than showing only positive importance.

Key parameters and their effects

The result of occlusion sensitivity depends heavily on three settings: patch size, stride and baseline. The table below summarizes typical values and the trade-off each one controls.

ParameterTypical range for imagesEffect of increasing it
Patch size8 to 64 pixels per sideSmoother map, lower spatial detail
Stride25 to 100 percent of patch sizeFewer model calls, coarser map
Baseline valueZero, dataset mean or blurChanges what absence means
Target outputLogit or softmax probabilityLogits avoid saturation effects
Main occlusion parameters

The choice of baseline is the most underestimated setting. A black square is itself a strong visual feature that the network never saw during training, so the score may drop because of the artificial pattern rather than the missing content. Blurred, mean-filled or inpainted baselines reduce this out-of-distribution effect, though none removes it completely.

Occlusion sensitivity compared with other attribution methods

Occlusion sensitivity belongs to the family of feature attribution methods, and it is best understood next to gradient-based and sampling-based alternatives. The table below contrasts the main properties.

MethodModel access neededRelative costMain weakness
Occlusion sensitivityForward passes onlyHigh, one pass per positionBaseline and patch size bias
Gradient × inputGradientsLow, one backward passNoisy, local linear view
Grad-CAMGradients and feature mapsLowCoarse, convolutional layers only
LIMEForward passes onlyMedium to highUnstable across random samples
KernelSHAPForward passes onlyVery highApproximation and independence assumptions
Occlusion versus related explanation methods

Its main advantage is direct interpretability: the score directly answers the question of what happens to the prediction if this region is removed, in the same units as the model output, which makes the result easy to communicate to domain experts and auditors. Gradient methods describe infinitesimal changes, which may not reflect what happens when a whole object disappears. Occlusion, however, tests one patch at a time and therefore misses interactions between distant regions that only matter together.

Applying occlusion beyond images

The same principle extends to other data types by redefining what counts as a patch and what counts as absence. The following table shows common adaptations.

Data typeOcclusion unitCommon baseline
ImagesSquare pixel windowBlur, mean color or zeros
TextToken, word or sentenceMask token or deletion
Tabular dataSingle feature or feature groupTraining mean or median
Time seriesTime window across channelsLinear interpolation
Audio spectrogramsTime-frequency blockSilence or noise floor
Occlusion units by data type

For text classifiers, leave-one-out occlusion of each token is a standard sanity check, but deleting words can create ungrammatical inputs, which raises the same distribution shift concern as black patches in images. For tabular models, occluding correlated features as a group gives more stable results than occluding each column separately, because a model can often recover the missing information from a correlated neighbor.

Limitations and practical cautions

Occlusion sensitivity is intuitive, yet its maps can mislead when the settings are chosen carelessly. Practitioners should keep the following cautions in mind.

  • Computational cost scales with the number of positions; a 224 by 224 image with an 8-pixel stride requires roughly 780 forward passes per class.
  • Patch size changes the story: small patches highlight textures, while large patches highlight whole objects.
  • Redundant evidence hides importance: if two regions each suffice for the prediction, occluding either one alone shows little effect.
  • Explanation faithfulness must be tested, for example with deletion and insertion curves, instead of judged by visual plausibility.

Because of these issues, experienced teams run occlusion at several patch sizes and compare the results with at least one gradient-based method before drawing conclusions about model behavior.

The simple explanation

Occlusion sensitivity asks a simple question. What happens if the model cannot see this part? You cover one small area of a picture and ask the model again. If its answer gets much weaker, that area mattered.

Imagine guessing an animal from a photo while a friend covers parts with a card. When the card hides the face, you hesitate. When it hides the grass, you do not. Repeating this everywhere builds a map of the important spots.

How it is used in practice

A hospital research team validates a chest X-ray classifier that detects pneumonia with high accuracy on its test set. Before deployment, the team runs occlusion sensitivity with a 32-pixel blurred patch and a 16-pixel stride on 200 positive cases.

The maps reveal that for many images the largest score drops occur not over the lungs but over a hospital marker in the corner of the film, which correlated with patients from an intensive care unit. Hiding the marker reduces the pneumonia score by up to 40 percent on those cases. The team crops the markers from all training images, retrains the model and repeats the analysis. The new maps concentrate on lung tissue, and accuracy on an external hospital dataset rises noticeably, showing that occlusion exposed a shortcut the model had learned.