6.3.11 · D4Interpretability & Explainability

Exercises — Concept-based explanations

2,910 words13 min readBack to topic

The two tools, from zero

Before any exercise, look at the picture below. Everything on this page is this one geometry: a concept arrow , a steepest-uphill arrow (the gradient), and the single question "do they point to the same side of the fence?"

Figure — Concept-based explanations

Figure s01 — how to read it. The cyan arrow is the concept direction . The dashed white line through the origin is the fence where the dot product equals (every arrow on it is perpendicular to ). The amber arrow lands on the same side as : its dot product is positive → a YES vote. The plain white arrow lands on the far side: negative dot product → a NO vote. TCAV only ever asks: which side of this fence did the gradient fall on?


Level 1 — Recognition

Exercise 1.1

Match each phrase to the right symbol: (a) concept direction, (b) how to increase the zebra score, (c) the raw class score. Choices: , , .

Recall Solution

(a) concept direction . (b) how to increase the zebra score (the steepest-uphill arrow). (c) the raw class score (the logit) .

Exercise 1.2

A TCAV score of means the model does WHAT with respect to the concept? Pick one: (i) strongly uses it, (ii) ignores/opposes it, (iii) it is the random baseline.

Recall Solution

(ii). Since TCAV counts the fraction of positive dot products, a score of means no example had the gradient pointing toward the concept — the model ignores or actively opposes it. The random baseline is (see the symmetry argument above), not .

Exercise 1.3

Fill in the clozes. The CAV points in the concept direction in activation space. TCAV measures concept usage (causal influence), not concept presence.

Recall Solution

concept ::: direction of "more of this concept" usage ::: does the model actually rely on it to decide presence ::: whether the concept merely appears in the image


Level 2 — Application

Exercise 2.1

For one zebra image, and . Does this image vote yes? Compute the dot product.

Recall Solution

, so : it votes yes — nudging activations toward "striped" would raise the zebra logit.

Exercise 2.2

Out of 100 zebra images, 87 have positive directional derivative w.r.t. . What is the TCAV score?

Recall Solution

The model uses "striped" for the vast majority of zebra examples.

Exercise 2.3

The gradient is and the CAV is . Using the same-direction meter, find the angle between them and say whether the vote is yes. (Note: the sign of the dot product does not depend on either arrow's length, so we can read off the vote directly from these raw coordinates without first rescaling to unit length.)

Figure — Concept-based explanations

Figure s02 — how to read it. The amber arrow is , the cyan arrow is . The small white square marks the corner between them. Because they meet at a right angle the dot product is exactly — the gradient sits on the fence, not on either side, so it does not count as a yes vote.

Recall Solution

Dot product: . Since and the product is with non-zero lengths, . The arrows are perpendicular: this example sits exactly on the fence. Since the vote requires strictly , it is not a yes vote (a boundary example counts as no).


Level 3 — Analysis

Exercise 3.1

You run 20 random CAVs on the zebra class. Their TCAV scores have mean and standard deviation . Your real "striped" CAV scores . Expressing the gap in units of the random spread, how many standard deviations () above the random mean is it, and is that convincing?

Recall Solution

We measure the gap in units of the random distribution's own spread (a z-score): . Caveat on interpretation: turning into a tiny -value assumes the random scores are roughly bell-shaped (Gaussian) — a convenient approximation, not a proven fact. But the gap is so large that even without that assumption it dwarfs the observed spread, so the conclusion is safe: the concept is genuinely used, not a fluke of high-dimensional geometry. (Ex 3.2 shows the assumption-free way to get a -value by direct counting.)

Exercise 3.2

A different concept scores . Among your random trials, random CAVs scored . Compute the significance . Does it pass ?

Recall Solution

, so this concept fails the significance test — is well within random reach. Reject the claim that the model uses it. (This count-based needs no Gaussian assumption — it just asks how often random directions matched or beat you.)

Exercise 3.3

A model trained only on zebras photographed in grassland gives and . What has the model actually learned, and what does this reveal about the dataset?

Recall Solution

The gradient rarely points toward stripes ( baseline ) but almost always points toward grass (). The model is classifying zebras largely by their background — a spurious shortcut. This is a dataset bug: every zebra image shared the grassland context, so "grass" was a perfectly predictive but semantically wrong cue. This is exactly the kind of shortcut surfaced in Adversarial Examples and repairable via Model Editing.


Level 4 — Synthesis

Exercise 4.1

Design a TCAV experiment to test whether a medical X-ray classifier for "pneumonia" secretly relies on a hospital watermark in the corner. List (a) your P and N sets, (b) the layer choice reasoning, (c) the class , and (d) what a high TCAV would prove.

Recall Solution

(a) Sets: P = image patches containing the watermark (crop many corners bearing it); N = random patches without the watermark, matched in count. (b) Layer : a mid-to-late convolutional layer, where features are abstract enough to encode a small textural mark but before the final logits so a gradient still flows meaningfully. Fix this for the whole experiment. (c) Class: "pneumonia". (d) A high, significant proves the gradient of the pneumonia logit consistently points toward the watermark direction — i.e. the model uses the watermark to decide, a catastrophic shortcut (some hospitals watermarked mostly sick patients). This connects to Probing Classifiers: probing would only tell you the watermark is encoded; TCAV tells you it is used.

Exercise 4.2

ACE clusters activation patches with k-means to discover concepts automatically. You get a cluster whose TCAV for "cow" is , but inspecting the patches shows they are all green grass. Combine ideas: is ACE broken, and what does this teach you?

Recall Solution

ACE is working correctly — it faithfully found a direction the model uses. The finding itself is the alarm: the model classifies "cow" partly via grass background. ACE's strength is discovering concepts you never thought to test (you would likely have hand-tested "hooves", "horns", "cow-body", never "grass"). The lesson: automated discovery + TCAV together surface hidden spurious concepts that manual concept sets would miss.


Level 5 — Mastery

Exercise 5.1

Prove that TCAV is invariant to the scaling of the gradient: show that if you replace with for any , the yes/no vote never changes. Then explain why this is a design feature, not a coincidence.

Recall Solution

A vote is . Scaling: . For , multiplying by a positive number preserves the sign, so . Vote unchanged. ∎ Why it is a feature: logit gradients have arbitrary magnitude depending on network scale, layer, and normalisation. If TCAV depended on magnitude it would be uncomparable across layers/models. By keeping only the sign, TCAV measures the geometric alignment of the concept with the "which way is uphill" direction — a scale-free, interpretable quantity.

Exercise 5.2

Edge / degenerate cases. For each, state the TCAV vote (yes / no / undefined) and why: (a) (a saturated logit, gradient vanishes). (b) and are exactly opposite: . (c) (dot product exactly ).

Recall Solution

(a) , so : counts as no. Interpretation: at a saturated point the class score cannot be increased at all, so no direction — concept or otherwise — helps. Beware: many saturated examples can artificially depress TCAV; check gradient norms. (b) : no. The concept direction points exactly downhill for the class — moving toward the concept lowers the class score. This is a strong "concept opposes class" signal. (c) dot product , vote is no (boundary counts as no, matching the strict ). The concept is irrelevant to first order for this example.

Exercise 5.3

Two teams report on the same model. Team A: "Probing shows 'texture' is encoded with 92% accuracy — so the model relies on texture." Team B runs TCAV and gets for texture. Reconcile these findings without either team being wrong.

Recall Solution

Both can be correct because they measure different questions (see Probing Classifiers):

  • Probing at 92% shows texture is linearly decodable — the information is present and encoded in the activations.
  • TCAV (essentially the random baseline of ) shows that, at decision time, the class logit's gradient is not aligned with the texture direction — the model does not use texture to make this decision. Reconciliation: a network can represent a feature richly yet route its decision through other features entirely. The texture information lives in the activations (so a probe reads it easily), but the class logit does not rise when you push activations toward the texture direction (so TCAV stays at chance). In one sentence: encoded ≠ used. This is the single most important distinction in concept-based interpretability, and why causal directional-derivative testing (TCAV) is not replaceable by probing accuracy alone. Compare with Feature Attribution Methods and Layer-wise Relevance Propagation, which answer yet another question ("which inputs mattered") entirely.

Recall One-line summary to test yourself

The whole page reduces to ::: TCAV = fraction of class examples whose logit-gradient points to the same side as the concept arrow; only the SIGN of the dot product matters; and this must beat a random-CAV baseline (≈0.5 by symmetry) to count.