TL;DR
Network Dissection is a method for measuring what one hidden unit inside a convolutional network responds to. It runs labelled photographs through the network, turns each unit's activity into a binary mask, and scores the mask's overlap with each human-labelled concept (an object, a part, a scene, a texture, or a colour) using IoU. The best-scoring concept becomes the unit's name, which turns a vague question about a network's internals into a number you can compare across networks.
Builds on: Image Segmentation, Intersection over Union, Bilinear Interpolation · Leads to: Network Dissection: Quantifying Interpretability of Deep Visual Representations
Where it's used
Checking what a vision model has learned. A team that wants to know whether a trained image classifier has internal units for meaningful things, such as wheels, faces or water, can dissect the network instead of reading a few hand-picked pictures. Bau and colleagues ran the method on AlexNet, VGG, GoogLeNet and ResNet models. In their human study of AlexNet trained on scenes, 247 of 384 units in conv3 and 258 of 384 in conv4 were judged interpretable, and 194 of 256 in conv5 were.
Comparing training data. Two networks can have the same design and be trained on different images. Dissection gives a count of distinct concepts for each. The paper finds that networks trained on scene data (Places) show more object and part detectors at the higher layers than networks trained on object data (ImageNet), which is a concrete reason to weigh training data for interpretability as well as for accuracy.
Judging a training technique. Batch normalisation, a common layer that rescales activations inside a network, raised top-1 accuracy slightly in the paper's experiment (50.5 percent against 50.0 percent for the baseline) but the paper says that it "seems to decrease interpretability significantly". A team that needs readable internal units can use dissection to see that trade-off before shipping a design.
How it works
Take one unit and one tiny picture. The picture is a single row of three pixels. A concept label called "dog" covers the last two pixels. Here is the whole method, one step at a time.
-
Run the labelled images through the network and record the unit. Each image goes through the network once with no training and no backpropagation. For the unit, we keep its activation map, a small grid of numbers, one per location. In our toy, the map is the two numbers 0.2 and 0.8. Check: the map has one value per location in the layer, not per pixel of the image.
-
Set a threshold from the whole dataset. Across all the activations of this unit in the dataset, find the value T such that only the top 0.5 percent of activations are above it. In our toy we use T = 0.6 for clarity. Check: a high threshold means only the strongest responses count.
-
Stretch the map to the size of the label. The activation map is small and the label is at image resolution, so we resize the map with bilinear interpolation. Our two values 0.2 and 0.8 become three values across three pixels: 0.2, 0.5, 0.8. The middle value is the average of its neighbours, 0.5. Check: the middle pixel sits halfway between the two map values, so it gets their average.
-
Turn the stretched map into a mask. Keep each pixel whose value is at least T and set the others to zero. The values 0.2, 0.5 and 0.8 become the mask 0, 0, 1, because only 0.8 reaches 0.6. Check: the mask has a 1 only where the unit is strongly active.
-
Compare the mask with the label. The "dog" label is the mask 0, 1, 1. Count the pixels in both masks (the intersection): there is one, the third pixel. Count the pixels in either mask (the union): there are two, the second and third. The score is 1 divided by 2, which is 0.5. Check: the score is 1 for a perfect match and 0 for no overlap.
-
Add up over the dataset and name the unit. Repeat steps 3 to 5 for every image, add the intersections and the unions separately, then divide. The paper counts a unit as a detector for a concept when this score is above 0.04. If a unit matches several concepts, the top-ranked one is its name.
flowchart LR A["Trained CNN"] --> B["Activation map for each image"] B --> C["Bilinear upscale to label size"] C --> D["Threshold at T from top 0.5 percent"] D --> E["Binary mask for the unit"] E --> F["IoU with each labelled concept"] G["Broden labelled images"] --> F F --> H["Top-ranked concept names the unit"]
The math
Step 2 in symbols: the threshold
Let a be an activation of unit k taken at a random location in the dataset. The threshold T is defined by
Here is a probability, the chance that a random activation exceeds T. So only the top 0.5 percent of activations are above it. In the paper's words, this is the "top quantile level".
Step 3 in symbols: the upscaled map
Let A(x) be the activation map of unit k for image x. Bilinear interpolation gives S(x), the map resized to the resolution of the label mask L(x). The paper anchors each interpolation point at the centre of the unit's receptive field, which is the region of the image that the unit can see. This is why the map can be aligned with pixels.
Step 4 in symbols: the mask
The mask M(x) is 1 where the upscaled activation reaches the threshold and 0 elsewhere.
Step 5 and 6 in symbols: the score
Here |·| counts pixels. The sums run only over images that have at least one label from the same category as c, because some label types are missing from some images. Summing before dividing means a large image with many labelled pixels counts for more than a small one. The paper notes that its qualitative results are insensitive to the detector threshold of 0.04: other thresholds change how many units count as detectors, but not their relative order.
Worked examples
We have a unit mask M = (1, 0, 0, 1) and a concept mask L = (1, 1, 0, 0) on four pixels.
- Intersection: pixels where both are 1. Only pixel 1 is 1 in both, so the intersection has size 1.
- Union: pixels where either is 1. Pixels 1, 2 and 4 are 1 in at least one mask, so the union has size 3.
- IoU = 1 divided by 3, which is about 0.33.
- Interpretation: 0.33 is well above the paper's 0.04 cut-off, so this unit counts as a detector for the concept. The overlap is partial, so the unit matches the concept only roughly.
Two images contribute to one unit and one concept.
- Image A: intersection 30 pixels, union 60 pixels. Its own IoU would be 30 divided by 60, which is 0.5.
- Image B: intersection 10 pixels, union 50 pixels. Its own IoU would be 10 divided by 50, which is 0.2.
- The dataset score adds the intersections: 30 plus 10 is 40.
- It adds the unions: 60 plus 50 is 110.
- IoU = 40 divided by 110, which is about 0.36.
- Interpretation: averaging the two per-image scores would give 0.35. The summed score is slightly higher because image A has more labelled pixels, and the paper's definition gives that image its natural weight.
The paper's human study asks whether a unit's named concept describes the image patches that activate it. For AlexNet trained on Places205, the first convolutional layer (conv1) has 96 units, and 57 of them were judged interpretable by agreement with the human ground truth. The conv5 layer has 256 units, and 194 were judged interpretable.
- Interpretable units: 57.
- Total units: 96.
- Fraction: 57 divided by 96, which is about 0.594.
- Interpretation: about 59 percent of the first-layer units match a human-recognisable concept. The paper notes that colour and texture concepts dominate the lower layers, so most matches at this depth are simple concepts.
Try it: the conv5 layer has 256 units, and 194 of them were judged interpretable. What fraction is that, to two decimal places?
Answer: 194 divided by 256 is 0.7578, so about 0.76, or 76 percent.
Common mistakes and tradeoffs
It is tempting to think that a unit which fires strongly on dogs is a dog detector. In fact a strong response is not enough. The unit's mask must overlap the labelled dog pixels across the dataset, measured by IoU, and the score is compared across all concepts. Because a unit can respond to dog fur, grass and dog-shaped edges all at once, only the overlap score settles the name.
It is tempting to think that a named unit has one meaning. In fact the method measures alignment between one unit and one concept, and the paper says that concepts often align with combinations of several units. The paper's rotation experiment shows that the names depend on the axes of the representation. Rotating conv5 of AlexNet trained on Places with a random orthogonal matrix reduced the number of unique detectors by 80 percent, even though the rotated network has exactly the same discriminative power.
It is tempting to think that a network with good accuracy has interpretable units, or the reverse. In fact the two properties are separate. The paper shows that interpretability is a different quality that must be measured on its own. The batch normalisation experiment makes this concrete: accuracy rose slightly while the paper says that it "seems to decrease interpretability significantly".
It is tempting to think that a unit with no label has no meaning. In fact the method can only name a unit with a concept that is in its dataset. A unit that responds to something absent from Broden will score poorly, and the paper says that the method works only as well as the underlying dataset.
When to use it: you want per-unit names, you have densely labelled images for your domain, and you want scores that compare networks. It needs no training.
When not to use it: you have no labelled images for the concepts you care about, or you want to know what a group of units does together. Then look at the alternatives. Visualising image patches that maximally activate a unit, as in Zeiler and Fergus (2014), gives pictures to read by eye. Linear probes, as in Alain and Bengio (2016), test whether information is linearly available at a layer. Intervening on the network, as in Mechanistic Interpretability, tests whether a unit causes an output.
History
Earlier researchers noticed that units in convolutional networks often seemed to respond to recognisable things, but the evidence was mostly by eye. Zhou and colleagues (2015) used human evaluation to show that object detectors emerge inside a network trained to recognise places.
Bau and colleagues (2017) replaced the human matching with an automatic score. They built Broden, a dataset that merges several densely labelled image collections into one set of English-named concepts, and they used IoU to score every unit. Their rotation experiment tests whether a unit's meaning belongs to the network's chosen axes, and the paper concludes that it does.
Recap
- A hidden unit in a convolutional network produces an activation map: one number per location.
- The map is upscaled to label resolution with bilinear interpolation, thresholded at the top 0.5 percent of activations, and turned into a binary mask.
- The mask is scored against each labelled concept with IoU, summed over the dataset, and a score above 0.04 makes the unit a detector for that concept.
- Scores are comparable across networks, so the number of unique detectors in a layer measures its interpretability.
- Interpretability depends on the axes of the representation: a random rotation removed 80 percent of the unique detectors in the paper's test.
Next, read the paper's own walkthrough in Network Dissection: Quantifying Interpretability of Deep Visual Representations, and for the wider field see Mechanistic Interpretability.
Check yourself
QuestionRecall: what does the threshold T_k satisfy in Network Dissection?Show answer
QuestionCompute: a unit mask is (0, 1, 1, 0) and a concept label is (1, 1, 0, 0). What is their IoU?Show answer
QuestionWhy: why does the paper add intersections and unions across the dataset before dividing, instead of averaging the per-image IoU values?Show answer
QuestionApplied: a researcher finds that one unit scores 0.03 for the concept red and 0.50 for the concept wheel, using the paper's threshold of 0.04. What name should the unit get?Show answer
Sources
- Bau, Zhou, Khosla, Oliva and Torralba, "Network Dissection: Quantifying Interpretability of Deep Visual Representations", arXiv:1704.05796 (2017). https://arxiv.org/abs/1704.05796
- "Explainable artificial intelligence", Wikipedia. https://en.wikipedia.org/wiki/Explainable_artificial_intelligence