Machine Learning & Signals Learning

\(\newcommand{\footnotename}{footnote}\) \(\def \LWRfootnote {1}\) \(\newcommand {\footnote }[2][\LWRfootnote ]{{}^{\mathrm {#1}}}\) \(\newcommand {\footnotemark }[1][\LWRfootnote ]{{}^{\mathrm {#1}}}\) \(\let \LWRorighspace \hspace \) \(\renewcommand {\hspace }{\ifstar \LWRorighspace \LWRorighspace }\) \(\newcommand {\TextOrMath }[2]{#2}\) \(\newcommand {\mathnormal }[1]{{#1}}\) \(\newcommand \ensuremath [1]{#1}\) \(\newcommand {\LWRframebox }[2][]{\fbox {#2}} \newcommand {\framebox }[1][]{\LWRframebox } \) \(\newcommand {\setlength }[2]{}\) \(\newcommand {\addtolength }[2]{}\) \(\newcommand {\setcounter }[2]{}\) \(\newcommand {\addtocounter }[2]{}\) \(\newcommand {\arabic }[1]{}\) \(\newcommand {\number }[1]{}\) \(\newcommand {\noalign }[1]{\text {#1}\notag \\}\) \(\newcommand {\cline }[1]{}\) \(\newcommand {\directlua }[1]{\text {(directlua)}}\) \(\newcommand {\luatexdirectlua }[1]{\text {(directlua)}}\) \(\newcommand {\protect }{}\) \(\def \LWRabsorbnumber #1 {}\) \(\def \LWRabsorbquotenumber "#1 {}\) \(\newcommand {\LWRabsorboption }[1][]{}\) \(\newcommand {\LWRabsorbtwooptions }[1][]{\LWRabsorboption }\) \(\def \mathchar {\ifnextchar "\LWRabsorbquotenumber \LWRabsorbnumber }\) \(\def \mathcode #1={\mathchar }\) \(\let \delcode \mathcode \) \(\let \delimiter \mathchar \) \(\def \oe {\unicode {x0153}}\) \(\def \OE {\unicode {x0152}}\) \(\def \ae {\unicode {x00E6}}\) \(\def \AE {\unicode {x00C6}}\) \(\def \aa {\unicode {x00E5}}\) \(\def \AA {\unicode {x00C5}}\) \(\def \o {\unicode {x00F8}}\) \(\def \O {\unicode {x00D8}}\) \(\def \l {\unicode {x0142}}\) \(\def \L {\unicode {x0141}}\) \(\def \ss {\unicode {x00DF}}\) \(\def \SS {\unicode {x1E9E}}\) \(\def \dag {\unicode {x2020}}\) \(\def \ddag {\unicode {x2021}}\) \(\def \P {\unicode {x00B6}}\) \(\def \copyright {\unicode {x00A9}}\) \(\def \pounds {\unicode {x00A3}}\) \(\let \LWRref \ref \) \(\renewcommand {\ref }{\ifstar \LWRref \LWRref }\) \( \newcommand {\multicolumn }[3]{#3}\) \(\require {textcomp}\) \( \newcommand {\abs }[1]{\lvert #1\rvert } \) \( \DeclareMathOperator {\sign }{sign} \) \(\newcommand {\intertext }[1]{\text {#1}\notag \\}\) \(\let \Hat \hat \) \(\let \Check \check \) \(\let \Tilde \tilde \) \(\let \Acute \acute \) \(\let \Grave \grave \) \(\let \Dot \dot \) \(\let \Ddot \ddot \) \(\let \Breve \breve \) \(\let \Bar \bar \) \(\let \Vec \vec \) \(\newcommand {\bm }[1]{\boldsymbol {#1}}\) \(\require {physics}\) \(\newcommand {\LWRphystrig }[2]{\ifblank {#1}{\textrm {#2}}{\textrm {#2}^{#1}}}\) \(\renewcommand {\sin }[1][]{\LWRphystrig {#1}{sin}}\) \(\renewcommand {\sinh }[1][]{\LWRphystrig {#1}{sinh}}\) \(\renewcommand {\arcsin }[1][]{\LWRphystrig {#1}{arcsin}}\) \(\renewcommand {\asin }[1][]{\LWRphystrig {#1}{asin}}\) \(\renewcommand {\cos }[1][]{\LWRphystrig {#1}{cos}}\) \(\renewcommand {\cosh }[1][]{\LWRphystrig {#1}{cosh}}\) \(\renewcommand {\arccos }[1][]{\LWRphystrig {#1}{arcos}}\) \(\renewcommand {\acos }[1][]{\LWRphystrig {#1}{acos}}\) \(\renewcommand {\tan }[1][]{\LWRphystrig {#1}{tan}}\) \(\renewcommand {\tanh }[1][]{\LWRphystrig {#1}{tanh}}\) \(\renewcommand {\arctan }[1][]{\LWRphystrig {#1}{arctan}}\) \(\renewcommand {\atan }[1][]{\LWRphystrig {#1}{atan}}\) \(\renewcommand {\csc }[1][]{\LWRphystrig {#1}{csc}}\) \(\renewcommand {\csch }[1][]{\LWRphystrig {#1}{csch}}\) \(\renewcommand {\arccsc }[1][]{\LWRphystrig {#1}{arccsc}}\) \(\renewcommand {\acsc }[1][]{\LWRphystrig {#1}{acsc}}\) \(\renewcommand {\sec }[1][]{\LWRphystrig {#1}{sec}}\) \(\renewcommand {\sech }[1][]{\LWRphystrig {#1}{sech}}\) \(\renewcommand {\arcsec }[1][]{\LWRphystrig {#1}{arcsec}}\) \(\renewcommand {\asec }[1][]{\LWRphystrig {#1}{asec}}\) \(\renewcommand {\cot }[1][]{\LWRphystrig {#1}{cot}}\) \(\renewcommand {\coth }[1][]{\LWRphystrig {#1}{coth}}\) \(\renewcommand {\arccot }[1][]{\LWRphystrig {#1}{arccot}}\) \(\renewcommand {\acot }[1][]{\LWRphystrig {#1}{acot}}\) \(\require {cancel}\) \(\newcommand {\underuparrow }[1]{{\underset {\uparrow }{#1}}}\) \(\DeclareMathOperator *{\argmax }{argmax}\) \(\DeclareMathOperator *{\argmin }{arg\,min}\) \(\def \E [#1]{\mathbb {E}\!\left [ #1 \right ]}\) \(\def \Var [#1]{\operatorname {Var}\!\left [ #1 \right ]}\) \(\def \Cov [#1]{\operatorname {Cov}\!\left [ #1 \right ]}\) \(\newcommand {\floor }[1]{\lfloor #1 \rfloor }\) \(\newcommand {\DTFTH }{ H \brk 1{e^{j\omega }}}\) \(\newcommand {\DTFTX }{ X\brk 1{e^{j\omega }}}\) \(\newcommand {\DFTtr }[1]{\mathrm {DFT}\left \{#1\right \}}\) \(\newcommand {\DTFTtr }[1]{\mathrm {DTFT}\left \{#1\right \}}\) \(\newcommand {\DTFTtrI }[1]{\mathrm {DTFT^{-1}}\left \{#1\right \}}\) \(\newcommand {\Ftr }[1]{ \mathcal {F}\left \{#1\right \}}\) \(\newcommand {\FtrI }[1]{ \mathcal {F}^{-1}\left \{#1\right \}}\) \(\newcommand {\Zover }{\overset {\mathscr Z}{\Longleftrightarrow }}\) \(\renewcommand {\real }{\mathbb {R}}\) \(\newcommand {\ba }{\mathbf {a}}\) \(\newcommand {\bb }{\mathbf {b}}\) \(\newcommand {\bc }{\mathbf {c}}\) \(\newcommand {\bd }{\mathbf {d}}\) \(\newcommand {\be }{\mathbf {e}}\) \(\newcommand {\bf }{\mathbf {f}}\) \(\newcommand {\bg }{\mathbf {g}}\) \(\newcommand {\bh }{\mathbf {h}}\) \(\newcommand {\bi }{\mathbf {i}}\) \(\newcommand {\bn }{\mathbf {n}}\) \(\newcommand {\bo }{\mathbf {o}}\) \(\newcommand {\bp }{\mathbf {p}}\) \(\newcommand {\bq }{\mathbf {q}}\) \(\newcommand {\br }{\mathbf {r}}\) \(\newcommand {\bs }{\mathbf {s}}\) \(\newcommand {\bt }{\mathbf {t}}\) \(\newcommand {\bu }{\mathbf {u}}\) \(\newcommand {\bv }{\mathbf {v}}\) \(\newcommand {\bw }{\mathbf {w}}\) \(\newcommand {\bx }{\mathbf {x}}\) \(\newcommand {\bxx }{\mathbf {xx}}\) \(\newcommand {\bxy }{\mathbf {xy}}\) \(\newcommand {\by }{\mathbf {y}}\) \(\newcommand {\byx }{\mathbf {yx}}\) \(\newcommand {\byy }{\mathbf {yy}}\) \(\newcommand {\bz }{\mathbf {z}}\) \(\newcommand {\bA }{\mathbf {A}}\) \(\newcommand {\bB }{\mathbf {B}}\) \(\newcommand {\bC }{\mathbf {C}}\) \(\newcommand {\bD }{\mathbf {D}}\) \(\newcommand {\bH }{\mathbf {H}}\) \(\newcommand {\bI }{\mathbf {I}}\) \(\newcommand {\bK }{\mathbf {K}}\) \(\newcommand {\bM }{\mathbf {M}}\) \(\newcommand {\bP }{\mathbf {P}}\) \(\newcommand {\bQ }{\mathbf {Q}}\) \(\newcommand {\bR }{\mathbf {R}}\) \(\newcommand {\bS }{\mathbf {S}}\) \(\newcommand {\bU }{\mathbf {U}}\) \(\newcommand {\bW }{\mathbf {W}}\) \(\newcommand {\bX }{\mathbf {X}}\) \(\newcommand {\bY }{\mathbf {Y}}\) \(\newcommand {\bZ }{\mathbf {Z}}\) \(\newcommand {\balpha }{\bm {\alpha }}\) \(\newcommand {\bth }{{\bm {\theta }}}\) \(\newcommand {\bepsilon }{{\bm {\epsilon }}}\) \(\newcommand {\bmu }{{\bm {\mu }}}\) \(\newcommand {\bgamma }{{\bm {\gamma }}}\) \(\newcommand {\bphi }{\bm {\phi }}\) \(\newcommand {\bOne }{\mathbf {1}}\) \(\newcommand {\bZero }{\mathbf {0}}\) \(\newcommand {\indFunc }{\mathbb {1}}\) \(\newcommand {\btx }{\tilde {\bx }}\) \(\newcommand {\loss }{\mathcal {L}}\) \(\newcommand {\score }{\mathcal {S}}\) \(\newcommand {\SSE }{\mathrm {SSE}}\) \(\newcommand {\SST }{\mathrm {SST}}\) \(\newcommand {\SSR }{\mathrm {SSR}}\) \(\newcommand {\MSE }{\mathrm {MSE}}\) \(\newcommand {\RMSE }{\mathrm {RMSE}}\) \(\newcommand {\toprule }[1][]{\hline }\) \(\let \midrule \toprule \) \(\let \bottomrule \toprule \) \(\def \LWRbooktabscmidruleparen (#1)#2{}\) \(\newcommand {\LWRbooktabscmidrulenoparen }[1]{}\) \(\newcommand {\cmidrule }[1][]{\ifnextchar (\LWRbooktabscmidruleparen \LWRbooktabscmidrulenoparen }\) \(\newcommand {\morecmidrules }{}\) \(\newcommand {\specialrule }[3]{\hline }\) \(\newcommand {\addlinespace }[1][]{}\) \(\newcommand {\LWRsubmultirow }[2][]{#2}\) \(\newcommand {\LWRmultirow }[2][]{\LWRsubmultirow }\) \(\newcommand {\multirow }[2][]{\LWRmultirow }\) \(\newcommand {\mrowcell }{}\) \(\newcommand {\mcolrowcell }{}\) \(\newcommand {\STneed }[1]{}\) \(\newcommand {\tcbset }[1]{}\) \(\newcommand {\tcbsetforeverylayer }[1]{}\) \(\newcommand {\tcbox }[2][]{\boxed {\text {#2}}}\) \(\newcommand {\tcboxfit }[2][]{\boxed {#2}}\) \(\newcommand {\tcblower }{}\) \(\newcommand {\tcbline }{}\) \(\newcommand {\tcbtitle }{}\) \(\newcommand {\tcbsubtitle [2][]{\mathrm {#2}}}\) \(\newcommand {\tcboxmath }[2][]{\boxed {#2}}\) \(\newcommand {\tcbhighmath }[2][]{\boxed {#2}}\) \(\require {colortbl}\) \(\let \LWRorigcolumncolor \columncolor \) \(\renewcommand {\columncolor }[2][named]{\LWRorigcolumncolor [#1]{#2}\LWRabsorbtwooptions }\) \(\let \LWRorigrowcolor \rowcolor \) \(\renewcommand {\rowcolor }[2][named]{\LWRorigrowcolor [#1]{#2}\LWRabsorbtwooptions }\) \(\let \LWRorigcellcolor \cellcolor \) \(\renewcommand {\cellcolor }[2][named]{\LWRorigcellcolor [#1]{#2}\LWRabsorbtwooptions }\) \(\newcommand {\LWRoverlaysymbols }[2]{\mathord {\smash {\mathop {#2\strut }\limits ^{\smash {\lower 3ex{#1}}}}\strut }}\) \(\def\otheralpha{\unicode{x03B1}}\) \(\def\otherbeta{\unicode{x03B2}}\) \(\def\othervarbeta{\unicode{x03D0}}\) \(\def\othergamma{\unicode{x03B3}}\) \(\def\otherdigamma{\unicode{x03DD}}\) \(\def\otherdelta{\unicode{x03B4}}\) \(\def\otherepsilon{\unicode{x03F5}}\) \(\def\othervarepsilon{\unicode{x03B5}}\) \(\def\otherzeta{\unicode{x03B6}}\) \(\def\othereta{\unicode{x03B7}}\) \(\def\othertheta{\unicode{x03B8}}\) \(\def\othervartheta{\unicode{x03D1}}\) \(\def\otheriota{\unicode{x03B9}}\) \(\def\otherkappa{\unicode{x03BA}}\) \(\def\othervarkappa{\unicode{x03F0}}\) \(\def\otherlambda{\unicode{x03BB}}\) \(\def\othermu{\unicode{x03BC}}\) \(\def\othernu{\unicode{x03BD}}\) \(\def\otherxi{\unicode{x03BE}}\) \(\def\otheromicron{\unicode{x03BF}}\) \(\def\otherpi{\unicode{x03C0}}\) \(\def\othervarpi{\unicode{x03D6}}\) \(\def\otherrho{\unicode{x03C1}}\) \(\def\othervarrho{\unicode{x03F1}}\) \(\def\othersigma{\unicode{x03C3}}\) \(\def\othervarsigma{\unicode{x03C2}}\) \(\def\othertau{\unicode{x03C4}}\) \(\def\otherupsilon{\unicode{x03C5}}\) \(\def\otherphi{\unicode{x03D5}}\) \(\def\othervarphi{\unicode{x03C6}}\) \(\def\otherchi{\unicode{x03C7}}\) \(\def\otherpsi{\unicode{x03C8}}\) \(\def\otheromega{\unicode{x03C9}}\) \(\def\otherAlpha{\unicode{x1D6E2}}\) \(\def\otherBeta{\unicode{x1D6E3}}\) \(\def\otherGamma{\unicode{x1D6E4}}\) \(\def\otherDigamma{\mathit{\unicode{x03DC}}}\) \(\def\otherDelta{\unicode{x1D6E5}}\) \(\def\otherEpsilon{\unicode{x1D6E6}}\) \(\def\otherZeta{\unicode{x1D6E7}}\) \(\def\otherEta{\unicode{x1D6E8}}\) \(\def\otherTheta{\unicode{x1D6E9}}\) \(\def\otherVartheta{\unicode{x1D6F3}}\) \(\def\otherIota{\unicode{x1D6EA}}\) \(\def\otherKappa{\unicode{x1D6EB}}\) \(\def\otherLambda{\unicode{x1D6EC}}\) \(\def\otherMu{\unicode{x1D6ED}}\) \(\def\otherNu{\unicode{x1D6EE}}\) \(\def\otherXi{\unicode{x1D6EF}}\) \(\def\otherOmicron{\unicode{x1D6F0}}\) \(\def\otherPi{\unicode{x1D6F1}}\) \(\def\otherRho{\unicode{x1D6F2}}\) \(\def\otherSigma{\unicode{x1D6F4}}\) \(\def\otherTau{\unicode{x1D6F5}}\) \(\def\otherUpsilon{\unicode{x1D6F6}}\) \(\def\otherPhi{\unicode{x1D6F7}}\) \(\def\otherChi{\unicode{x1D6F8}}\) \(\def\otherPsi{\unicode{x1D6F9}}\) \(\def\otherOmega{\unicode{x1D6FA}}\) \(\newcommand {\othergreek }[1]{#1}\) \(\let \varvarrho \varrho \) \(\let \varvarpi \varpi \) \(\let \othervarvarpi \othervarpi \) \(\let \othervarvarrho \othervarrho \) \(\let \varpartialdiff \partial \) \(\let \llbracket \lBrack \) \(\let \rrbracket \rBrack \) \(\let \dblbrackleft \lBrack \) \(\let \dblbrackright \rBrack \) \(\let \VERT |\) \(\newcommand {\parallelslant }{\mathrel {\unicode {x02AFD}}}\) \(\newcommand {\thething }{\mathord {\unicode {x1F60E}}}\) \(\newcommand {\nparallelslant }{\mathrel {\LWRoverlaysymbols {-}{\unicode {x02AFD}}}}\) \(\newcommand {\xswordsup }{\mathord {\unicode {x2694}}}\) \(\newcommand {\xswordsdown }{\mathord {\unicode {x2694}}}\) \(\newcommand {\notowns }{\mathrel {\unicode {x220C}}}\) \(\newcommand {\iintop }{\mathop {\unicode {x222C}}\limits }\) \(\newcommand {\iiintop }{\mathop {\unicode {x222D}}\limits }\) \(\newcommand {\oiint }{\mathop {\unicode {x222F}}\limits }\) \(\let \oiintop \oiint \) \(\newcommand {\oiiint }{\mathop {\unicode {x2230}}\limits }\) \(\let \oiiintop \oiiint \) \(\newcommand {\slashint }{\mathop {\unicode {x2A0D}}\limits }\) \(\let \slashintop \slashint \) \(\let \overgroup \overparen \) \(\let \wideparen \overparen \) \(\let \widearc \overparen \) \(\let \wideOarc \overrightarrow \) \(\newcommand {\widering }[1]{\stackrel {\unicode {x2218}}{\overgroup {#1}}}\)

27 Computer Vision: Task Comparison and Diagnostics

  • Goal: Compare the computer-vision tasks of the previous chapters side by side, and check that a trained vision model relies on real image structure.

The chapter covers:

  • • Section 27.1 (Comparison): the tasks of Chapters 23 to 26 side by side, with their losses and headline metrics.

  • • Sections 27.2 and 27.3 (Diagnostics): image-specific sanity checks, and the interpretation of models that fuse an image with another modality.

27.1 Comparison of CV tasks

Table 27.1 summarizes the computer-vision tasks covered in the previous four chapters: image classification (Ch. 23), image segmentation (Ch. 24), object detection (Ch. 25), Siamese embeddings (Sec. 26.1), and masked-autoencoder pretraining (Sec. 26.2). The right column captures the practical question each one is designed to answer.

Table 27.1: Computer-vision tasks side by side.
.

Task

Output

Loss family

Headline metric

When to use

Image classification

one class label per image

cross-entropy (optionally focal)

Top-1 / Top-\(k\), macro-\(F_1\)

one dominant object, closed set

Image segmentation

per-pixel class map \(\in \{0,\dots ,C\}^{H\times W}\)

CE \(+\) Dice

mIoU, Dice

masks needed, boundaries matter

Object detection

list of \((b, y, s)\) tuples

box regression \(+\) objectness/class CE

mAP@[.5:.95]

locate and count objects, real-time

Siamese embedding

embedding \(\bz \in \mathbb {R}^d\)

contrastive / triplet / SupCon

verification AUC, top-\(k\) retrieval

open set, few-shot, similarity search

Masked autoencoder

reusable backbone \(f_\theta \)

masked-patch MSE

fine-tuned / linear-probe accuracy

unlabeled images plentiful, labels scarce

Table 27.2 consolidates the evaluation metrics of these chapters, grouped by the task that produces them. Classification primitives (accuracy, \(F_1\), AUC) are deferred to Chapter 17 and reused by several modes here.

Table 27.2: Headline performance metrics of the computer-vision chapters, grouped by task.
.

Task

Metric

What it measures

Reference

Image classification

Top-1, Top-\(k\), macro-\(F_1\), AUC

Per-image label accuracy and ranking quality.

Sec. 23.1

Semantic segmentation

mIoU (Eq. 24.7), per-class IoU, fwIoU

Pixel overlap, class-averaged or frequency-weighted.

Sec. 24.5

Medical segmentation

Dice (Eq. 24.10), boundary IoU/\(F\)

Same as IoU on a different scale; boundary metrics for thin contours.

Sec. 24.6

Instance / panoptic seg.

mask-AP, Panoptic Quality (Eq. 24.12)

Detection-style mask matching; PQ combines segmentation and recognition quality.

Sec. 24.8

Object detection

AP@\(\tau \) (Eq. 25.2), mAP@.5, mAP@[.5:.95] (Eq. 25.4)

Area under PR curve at one or many IoU thresholds.

Sec. 25.2

Detection size bands

\(\text {AP}_{\text {small/medium/large}}\)

AP restricted to GT boxes in a size band; diagnoses small-object failure.

Sec. 25.2

Siamese verification

AUC, EER, TAR@FAR\(=10^{-k}\)

Same/different decision on pairs at a distance threshold; biometrics low-FAR operating point.

Sec. 26.1.8

Siamese retrieval

Rank-\(k\) / CMC, Recall@\(k\), mAP

Ranked-gallery quality for an open-set query.

Sec. 26.1.8

Siamese as features

Linear probe acc., \(k\)-NN acc.

Downstream usefulness of frozen embeddings.

Sec. 26.1.8

Self-supervised pretraining

Fine-tuned acc., linear probe acc.

Downstream usefulness of the backbone; the pretraining loss is not a quality measure.

Sec. 26.2

27.2 Image-Specific Sanity Checks (*)

  • Goal: Validate that image-based classifiers rely on meaningful spatial or global structure rather than localized artifacts or per-pixel statistics.

The sanity checks in this section (beyond these in Ch. 18) are specific to classifiers operating on image data (raw pixels or spatial feature maps). They test whether the model exploits spatial structure—edges, textures, shapes—or relies on superficial statistics that happen to correlate with the labels.

27.2.1 Visual Inspection of Worst-Performing Examples

Worst-case visual inspection: Rank the held-out examples by a per-example performance score (loss, or \(1-p_y\) for classification, \(1-\text {IoU}\) for segmentation, \(1-\text {IoU}\) between best-matched boxes for detection), select the worst \(k\) (typically \(k=20\) to \(50\)), and display them in a grid annotated with the true label, the predicted label, and the model’s confidence.

Aggregate metrics (Sec. 23.1 for classification, Sec. 24.4 for segmentation, Sec. 25.2 for detection) summarize performance into a single number and hide which images the model gets wrong. Manually inspecting a few dozen worst cases regularly surfaces failure modes that no single-number metric can reveal, and it is among the simplest diagnostics available: it requires no retraining and no additional labels.

Patterns to look for in the worst-case grid:

  • • Label noise: the ground-truth annotation is wrong or ambiguous, and the model’s prediction is in fact reasonable. Common on crowd-sourced or hastily relabeled datasets.

  • • Out-of-distribution inputs: corrupt files, extreme rotation or cropping, drastically different lighting or resolution from the training set.

  • • Confounding artifacts: timestamps, watermarks, scanner markers, ruler overlays, or hospital identifiers that correlate with the label in training but not at deployment.

  • • Systematic class confusion: one class is consistently mistaken for another (e.g. visually similar dog breeds, two adjacent organ classes), pointing to a missing distinguishing feature or insufficient training examples for the confused pair.

Model vs annotation

The worst-case set is usually a mix of:

  • • model failure and

  • • annotation failure.

Separate the two before reacting: relabeling or removing mislabeled examples often improves more than another round of hyperparameter tuning.

27.2.2 Pixel Shuffle Test

Pixel shuffle test: Given a dataset of \(N\) images, randomly permute all pixel locations within each image independently, producing a shuffled dataset \(\bX _{\text {shuf}}\). Re-extract features from \(\bX _{\text {shuf}}\) and repeat the cross-validation procedure.

Shuffling destroys all spatial structure (edges, textures, object shapes) while preserving the per-image pixel histogram (mean intensity, variance, and higher-order marginal statistics remain identical). A classifier that genuinely relies on spatial patterns will see its accuracy drop to chance level on \(\bX _{\text {shuf}}\). Conversely, if the accuracy remains high after shuffling, the classifier exploits per-pixel statistics rather than spatial structure, and the original cross-validation result is unreliable.

The pixel shuffle test is specific to classifiers that operate on raw pixel features or spatial feature maps (e.g., convolutional networks). It does not apply when hand-crafted, non-spatial features are extracted before classification.

27.2.3 Black-Patch Test

Black-patch test: Occlude a randomly positioned square region of each image with a black (zero or other constant-valued) patch of side length \(s\) pixels. Re-extract features and repeat cross-validation. Repeat for progressively larger patch sizes (e.g., \(s \in \{16, 32, 56, 112\}\)) to obtain an accuracy-versus-occlusion curve.

The black-patch test probes whether the classifier uses distributed spatial information or relies on a localized region. Three representative outcomes:

  • • Gradual, monotonic decline in accuracy as \(s\) increases—the classifier uses information spread across the image, which is the expected behavior for a well-trained model.

  • • Sharp drop at a specific patch size—the classifier depends on a localized region. This may indicate a genuine region of interest, but could also signal reliance on a confounding artifact (e.g., a timestamp, label overlay, or acquisition marker embedded in a fixed image location).

  • • Stable accuracy across all patch sizes—the classifier is largely insensitive to spatial content, raising concern that it exploits non-image-based confounders (e.g., differences in file encoding or image dimensions between classes).

When interpreting the black-patch test, consider the patch area relative to the total image area. A \(112 \times 112\) patch occludes roughly \(44\%\) of a \(168 \times 168\) image but only \(5\%\) of a \(512 \times 512\) image. Report patch sizes as fractions of the image dimensions to allow meaningful comparison across datasets.

27.3 Interpreting Multimodal Models (MultiViz) (*)

  • Goal: Explain a prediction from a model that fuses several modalities (e.g., an image and a text question) by attributing it to the contributing inputs, their interactions, and the internal representations.

The diagnostics above probe a classifier that sees a single image. Many modern vision models are instead multimodal: they fuse an image with another modality, such as the text of a question in visual question answering (VQA), or accompanying tabular and clinical data. For such a model the interpretation question is richer: not only where in one image the model looks, but which modality drives the answer and how the modalities interact. MultiViz is a framework that organizes this analysis into four stages.

It is worth separating this task from the Classifier Comparison chapter (Ch. 19). Those methods compare two models from their outputs alone (hard labels or predicted probabilities on a shared test set) to decide which is better or whether to fuse them. MultiViz instead interprets a single fused model, one prediction at a time, by opening its inputs and internal features. The two live on orthogonal axes; the closest relatives of MultiViz are the single-model, input-level diagnostics of this chapter, such as the worst-case inspection and the black-patch/occlusion test (Sec. 27.2.3).

The four MultiViz stages are:

  • • Unimodal importance: attribute the prediction to individual inputs within each modality, using per-modality saliency (gradient-based or LIME). The single-image analogue is the black-patch/occlusion test (Sec. 27.2.3), which localizes the image region a classifier depends on.

  • • Cross-modal interactions: identify which pairs of inputs across modalities jointly drive the prediction, for example a specific question word tied to a specific image region. This stage has no single-modality counterpart, and it is often where a multimodal model succeeds or fails.

  • • Multimodal representations: inspect the fused internal features, in the same spirit as the embedding analysis used for Siamese networks (Sec. 26.1) and the low-dimensional projections of Ch. 16 (t-SNE, UMAP), to see what the representation has encoded.

  • • Prediction analysis: fit a sparse, local surrogate that relates a few representation units to the final output, closing the loop from inputs, through interactions and representations, to the prediction.

The visualizations produced at each stage are hypotheses about the model’s behavior, not proofs. A highlighted region or a clean-looking embedding cluster can still be a spurious artifact, so the same cautions as the sanity checks above apply: confirm an interpretation with a controlled intervention (e.g., occluding the highlighted region, or perturbing the implicated modality) before trusting it.

Further Reading