Perceptual and Generative Evaluation › Reconstruction and Predictive Accuracy

Michael BrenndoerferAugust 1, 202616 min read
World Models HandbookAll chapters
Part 11 of 12Evaluation and Understanding
Chapter 62Perceptual and Generative Evaluation › Reconstruction and Predictive Accuracy
Reading section 2 of 8 · Reconstruction and Predictive Accuracy · 16 minSection 2 of 8 · 16 min

Book contents

Section 2 of 8 · 16 min read

Perceptual and Generative Evaluation › Reconstruction and Predictive AccuracyOne section · Sections in this chapter2 / 8 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Reconstruction scoring and future-prediction scoring agree on the math and disagree on the story. In reconstruction the model sees oto_t, produces o^t\hat o_t, and we compare o^t\hat o_t to oto_t. In future prediction the model sees hth_t and at:t+H−1a_{t:t+H-1} and produces o^t+1:t+H\hat o_{t+1:t+H}, and we compare the predicted sequence to the realized sequence ot+1:t+Ho_{t+1:t+H}. Pixel-wise mean squared error (MSE) and peak signal-to-noise ratio (PSNR) are the two workhorses of both. Frame MSE averages squared pixel residuals; frame PSNR applies a logarithm to that spatially averaged MSE. For sequences, averaging frame PSNR is not the same as applying the logarithm to a pooled MSE. The averaging conventions matter and are the subject of the next formulas.

The reference changes meaning between tasks. Ordinary reconstruction compares against the fixed input observation; zero pixel MSE requires reproducing that array, but reconstruction quality alone does not establish useful internal state. Future prediction compares against a realized outcome, potentially one of several possible futures. The same distance therefore has a different interpretation.

The mean squared error (MSE) between a prediction x^\hat x and a target xx, both of shape (Himg,W)(H_{\mathrm{img}}, W) with pixel values in [0,1][0,1], is

MSE(x^,x)  =  1HimgW∑i=1Himg∑j=1W(x^ij−xij)2\mathrm{MSE}(\hat x, x) \;=\; \frac{1}{H_{\mathrm{img}} W} \sum_{i=1}^{H_{\mathrm{img}}} \sum_{j=1}^{W} \bigl(\hat x_{ij} - x_{ij}\bigr)^2

where:

  • x^ij\hat x_{ij}: the predicted pixel value at spatial position (i,j)(i, j)
  • xijx_{ij}: the target pixel value at the same position
  • Himg,WH_{\mathrm{img}}, W: the height and width of the frame in pixels
  • 1HimgW\frac{1}{H_{\mathrm{img}}W}: normalization by the pixel count, making the result an average rather than a sum

The subtraction x^ij−xij\hat x_{ij} - x_{ij} is the signed per-pixel error. Squaring removes its sign and heavily penalizes large deviations.

The square grows quadratically with error magnitude. Uniform error of 0.1 gives MSE 0.01. Error of 0.3 on 10 percent of pixels, with zero error elsewhere, gives MSE 0.09×0.1=0.0090.09\times0.1=0.009. These close averages do not describe where the errors occur. The perceptual importance of a localized error depends on the scene and viewing task; we have not measured it in this calculation.

The quadratic penalty is easiest to see as a curve. The same squared-error contribution can come from a small error everywhere or a larger error in a small region.

In[5]:
Code
import numpy as np

error_magnitude = np.linspace(0.0, 0.35, 200)
squared_error = error_magnitude**2
uniform_error = 0.1
localized_error = 0.3
uniform_contribution = uniform_error**2
localized_contribution = localized_error**2
# The prose claim is that a localized 0.3 error on 10% of pixels scores comparably to
# a uniform 0.1 error on all pixels: 0.09 * 0.1 = 0.009 vs 0.01. Verify the contest is
# actually close enough that the plot supports the prose rather than showing a trivial gap.
uniform_total = uniform_contribution
localized_total = localized_contribution * 0.1
assert abs(uniform_total - localized_total) / uniform_total < 0.2
Out[6]:
Visualization
Line plot of squared error versus error magnitude with uniform and localized examples.
Squared error versus per-pixel error magnitude. A 0.1 error contributes 0.01 per pixel; a 0.3 error contributes 0.09 per affected pixel. If only 10 percent of pixels have the latter error, total MSE is 0.009. The curve shows the arithmetic penalty, not a human-visibility experiment.

For a multi-step prediction, we first compute the per-frame MSE for each horizon step and then average those per-frame values over time. The sequence MSE is

MSEseq(o^t+1:t+H,ot+1:t+H)  =  1H∑k=1HMSE(o^t+k,ot+k)\mathrm{MSE}_{\text{seq}}(\hat o_{t+1:t+H}, o_{t+1:t+H}) \;=\; \frac{1}{H} \sum_{k=1}^{H} \mathrm{MSE}\bigl(\hat o_{t+k}, o_{t+k}\bigr)

where:

  • o^t+k\hat o_{t+k}: the predicted frame at horizon step kk
  • ot+ko_{t+k}: the realized frame at the same horizon step
  • HH: the number of future frames being averaged
  • MSE(o^t+k,ot+k)\mathrm{MSE}(\hat o_{t+k}, o_{t+k}): the per-frame MSE defined above

Notice the two averaging decisions: how to combine spatial and channel dimensions into a per-frame value, and how to combine frames into a per-rollout value. Do not compare two numbers from different conventions. Always specify the pixel range (here in [0,1][0,1]) and the tensor layout, and state whether frames of different length are padded and excluded via a valid mask mk∈{0,1}m_k \in \{0, 1\}:

MSEseq  =  ∑k=1Hmk MSE(o^t+k,ot+k)∑k=1Hmk\mathrm{MSE}_{\text{seq}} \;=\; \frac{\sum_{k=1}^{H} m_k\, \mathrm{MSE}(\hat o_{t+k}, o_{t+k})}{\sum_{k=1}^{H} m_k}

where:

  • mk∈{0,1}m_k \in \{0, 1\}: a validity indicator for frame kk, where mk=1m_k = 1 includes the frame and mk=0m_k = 0 excludes it (e.g., padding)
  • HH: the prediction horizon, as before
  • ∑k=1Hmk\sum_{k=1}^{H} m_k: the valid-frame count, which must be positive. An all-padding sequence has no defined score under this formula and must be excluded or handled by a declared convention.

The valid mask is not a cosmetic detail. Suppose a model is trained to predict up to 64 frames, but two datasets provide rollouts of length 32 and 48 respectively. If the evaluation pads all rollouts to length 64 and averages the padded MSE without masking, the shorter dataset will be artificially penalized or rewarded depending on what value padded frames take. A mask removes this artifact by restricting the average to the frames the data actually contains. The same averaging convention question also arises when sequences are grouped into batches: the natural convention is to compute a per-sequence score and then average over sequences, rather than pooling all frames across the batch, because the latter weights long sequences more heavily.

Peak signal-to-noise ratio (PSNR) is MSE expressed on a logarithmic scale. It answers the question: how large is the squared peak signal relative to the squared reconstruction error? Given a declared peak value LL (usually the maximum representable pixel value, so L=1L = 1 for a [0,1][0, 1] range and L=255L = 255 for 8-bit images), PSNR is

PSNR(x^,x)  =  10log⁡10L2MSE(x^,x)\mathrm{PSNR}(\hat x, x) \;=\; 10 \log_{10} \frac{L^2}{\mathrm{MSE}(\hat x, x)}

where:

  • LL: the declared peak value of the pixel range, i.e. the maximum representable pixel value
  • MSE(x^,x)\mathrm{MSE}(\hat x, x): the pixel MSE between prediction and target, defined above
  • 10log⁡10(⋅)10 \log_{10}(\cdot): a logarithmic rescaling of the ratio into decibels (dB). At fixed LL, lower MSE means higher PSNR, so the preference ordering is equivalent with opposite score directions.

When MSE=0\mathrm{MSE} = 0, PSNR is +∞+\infty in the mathematical definition. If a report clips exact matches to a finite cap, it must state that choice. Declare LL and keep it consistent with the pixel units. Rescaling both images by 255 multiplies MSE by 2552255^2 and changes LL from 1 to 255, leaving PSNR unchanged. Changing only LL while keeping the same numerical errors adds 20log⁡10(255)≈48.1320\log_{10}(255) \approx 48.13 dB, an inconsistent protocol rather than a model improvement. At fixed LL, PSNR is a strictly convex function of positive MSE: a constant minus 10log⁡10(MSE)10\log_{10}(\mathrm{MSE}).

For positive frame errors e1,…,ene_1,\ldots,e_n and the same LL, Jensen's inequality gives mean frame PSNR greater than or equal to PSNR of mean MSE, with equality when all errors agree. Their gap is 10log⁡10(AM(e)/GM(e))10\log_{10}(\mathrm{AM}(e)/\mathrm{GM}(e)), the logarithm of the arithmetic-to-geometric mean ratio. It increases under a mean-preserving spread of the errors; variance alone does not determine it. State which averaging convention the table uses. Exact-zero errors need an explicit infinity or clipping convention.

The next bar chart applies both averaging conventions to the same eight positive frame errors. Its difference measures the averaging gap for this fixed set, not a comparison between two predictors.

In[7]:
Code
import numpy as np

frame_mse = np.array([0.002, 0.003, 0.004, 0.006, 0.010, 0.018, 0.030, 0.050])
mean_psnr = float(np.mean(10.0 * np.log10(1.0 / frame_mse)))
psnr_of_mean = float(10.0 * np.log10(1.0 / np.mean(frame_mse)))
Out[8]:
Visualization
Bar chart comparing mean of per-frame PSNR with PSNR computed from mean MSE.
Mean per-frame PSNR exceeds PSNR computed from mean MSE for these eight unequal positive errors. At a common peak value, their gap is the logarithm of the arithmetic-to-geometric mean ratio. It increases under a mean-preserving spread, not necessarily whenever variance increases.

Expected MSE is minimized by the conditional mean. Suppose yy is a real-valued target with finite second moment, xx contains the conditioning information, and f(x)f(x) is an unrestricted measurable predictor with finite squared error. The expectation is over the joint distribution p(x,y)p(x,y). The squared error decomposes into an irreducible term plus the squared gap between ff and the conditional mean:

E[(y−f(x))2]  =  E[(y−E[y∣x])2]  +  E[(E[y∣x]−f(x))2]\mathbb{E}\bigl[(y - f(x))^2\bigr] \;=\; \mathbb{E}\bigl[(y - \mathbb{E}[y \mid x])^2\bigr] \;+\; \mathbb{E}\bigl[(\mathbb{E}[y \mid x] - f(x))^2\bigr]

Expanding the square and conditioning on xx eliminates the cross term: the conditional mean of y−E[y∣x]y-\mathbb{E}[y\mid x] is zero almost surely. The irreducible first term does not depend on ff; the second is nonnegative and is zero exactly when f(x)=E[y∣x]f(x)=\mathbb{E}[y\mid x] almost surely. Thus the conditional mean minimizes expected squared error under the stated integrability assumptions.

For a finite-dimensional image vector, apply the same decomposition to each coordinate and average. The conditional mean still minimizes expected pixel MSE. If possible images place an object at separated locations, averaging their pixels can produce a faded overlay rather than an image from either mode. This is a possible consequence of the geometry, not a claim that every multimodal distribution has an implausible mean.

In our separated-object example, an MSE-optimal point estimate need not be a plausible sample. That is a mismatch between the prediction target and the sample-quality question, not a contradiction in the theorem. Blur can also reflect limited decoder resolution or capacity; the image alone does not identify its cause.

Structural similarity (SSIM), introduced by Wang, Bovik, Sheikh, and Simoncelli (2004), compares local luminance, contrast, and structure rather than uniformly weighting pixel-coordinate squared errors. For each sliding-window position, it summarizes corresponding patches by weighted means, variances, and covariance. With normalized Gaussian window weights ww, these statistics are defined as:

μx=∑iwixi,σx2=∑iwi(xi−μx)2,σxy=∑iwi(xi−μx)(yi−μy)\mu_x = \sum_i w_i x_i, \qquad \sigma_x^2 = \sum_i w_i (x_i - \mu_x)^2, \qquad \sigma_{xy} = \sum_i w_i (x_i - \mu_x)(y_i - \mu_y)

where:

  • wiw_i: the window weight at position ii (Gaussian or uniform), summing to 1
  • xi,yix_i, y_i: pixel values of the two images within the window
  • μx,μy\mu_x, \mu_y: the weighted local means
  • σx2,σy2\sigma_x^2, \sigma_y^2: the weighted local variances
  • σxy\sigma_{xy}: the weighted local covariance between the two patches, computed as ∑iwi(xi−μx)(yi−μy)\sum_i w_i (x_i - \mu_x)(y_i - \mu_y)

The SSIM score for that window is

SSIM(x,y)  =  (2μxμy+C1)(2σxy+C2)(μx2+μy2+C1)(σx2+σy2+C2)\mathrm{SSIM}(x, y) \;=\; \frac{(2 \mu_x \mu_y + C_1)(2 \sigma_{xy} + C_2)}{(\mu_x^2 + \mu_y^2 + C_1)(\sigma_x^2 + \sigma_y^2 + C_2)}

where:

  • (2μxμy+C1)(2 \mu_x \mu_y + C_1): the numerator of the luminance term, comparing the two local means
  • (μx2+μy2+C1)(\mu_x^2 + \mu_y^2 + C_1): the denominator of the luminance term, normalizing that comparison
  • (2σxy+C2)(2 \sigma_{xy} + C_2): the numerator of the combined contrast-and-structure term
  • (σx2+σy2+C2)(\sigma_x^2 + \sigma_y^2 + C_2): its denominator; together the factors compare covariance and local variance, not a squared correlation alone
  • C1=(K1L)2C_1 = (K_1 L)^2, C2=(K2L)2C_2 = (K_2 L)^2: small stabilizing constants using the reference defaults K1=0.01K_1 = 0.01 and K2=0.03K_2 = 0.03, where LL is the declared dynamic range

The first ratio measures luminance agreement and the second measures structural (contrast and correlation) agreement; the constants C1,C2C_1, C_2 keep the ratio finite when the local variances or means are near zero. The per-window scores are averaged over all window positions, giving the mean SSIM (MSSIM) that is reported for image-quality benchmarking.

The second ratio is not squared Pearson correlation. Without stabilizers and with positive local standard deviations, it equals the correlation multiplied by 2σxσy/(σx2+σy2)2\sigma_x\sigma_y/(\sigma_x^2+\sigma_y^2), a contrast-agreement factor. A positive gain can preserve correlation while reducing contrast agreement; an offset can reduce luminance agreement. SSIM does not ignore brightness shifts. Rescaling both images and the declared range LL together preserves this formula, but that change of units is not invariance to a physical gain or offset applied to just one image.

SSIM depends on the window size, whether the window is Gaussian or uniform, the standard deviation of the Gaussian, border-handling, whether the input is color or grayscale, and the declared LL. Two papers calling their metric "SSIM" may be computing different numbers. And, more importantly, SSIM is a proxy for human similarity judgments on natural images; it is not a semantic or physical truth classifier. A prediction with high SSIM can still place an object on the wrong side of a wall.

SSIM's agreement with human ratings was evaluated on specified image-distortion datasets. Agreement on a new domain or task is not guaranteed, but domain change does not necessarily reduce it. Validate the score against the distinctions that matter for the target task.

Full-reference vs. no-reference

MSE, PSNR, and SSIM are full-reference metrics: they require a specified, aligned reference. That reference need not be physical ground truth; an evaluation should state its source. For stochastic prediction, the realized future is one draw from the true conditional, so an alternative valid mode may score poorly against it. Comparing sample distributions changes the evaluation unit but introduces other limitations.

Consider a grayscale 48×4848 \times 48 canvas with a Gaussian blob of width σ=2.5\sigma=2.5 pixels. We prescribe two equally likely future locations under the same action, which could represent unobserved friction or contact variation. The code renders the two endpoints; it does not simulate that physical mechanism. The realized reference is the short-step endpoint. We compare a sharp match, a sharp alternative, and their pixel-wise mean using MSE and PSNR. At a fixed range on a single pair, PSNR gives exactly the reverse numerical ordering of MSE, so their preferences agree. We discuss SSIM separately rather than pretending to have computed it here.

The soft rendering makes the pixel-wise average visible as a faded superposition. Gaussian blobs have overlapping tails, so they are separated rather than strictly disjoint. This particular average is neither sharp endpoint; the conditional-mean theorem does not assert that every mean of separated modes lies in a low-density region.

In[9]:
Code
import matplotlib.pyplot as plt
import numpy as np

SIZE = 48
BLOB_SIGMA = 2.5


def render_object(x, y=None, sigma=BLOB_SIGMA, size=SIZE):
    """Render a soft Gaussian blob centered at (x, y) on a size x size canvas."""
    if y is None:
        y = size / 2.0
    yy, xx = np.mgrid[0:size, 0:size].astype(float)
    return np.exp(-(((xx - x) ** 2 + (yy - y) ** 2) / (2.0 * sigma**2)))


def mse(a, b):
    return float(np.mean((a - b) ** 2))


def psnr(a, b, peak=1.0):
    m = mse(a, b)
    if m == 0.0:
        return float("inf")
    return 10.0 * np.log10(peak**2 / m)

Now we build a single realized future and three candidate predictions. The realized future is mode A. The candidates are mode A (Sharp-A), mode B (Sharp-B), and the pixel-wise conditional mean. The mean under a two-mode conditional with equal weights is the average of the two mode images.

In[10]:
Code
MODE_A_X = 20.0  # small step to the right under action a_t = +1
MODE_B_X = 28.0  # large step to the right under the same action
REALIZED_X = MODE_A_X  # the future that actually happened

observed = render_object(REALIZED_X)
pred_sharp_A = render_object(MODE_A_X)
pred_sharp_B = render_object(MODE_B_X)
pred_mean = 0.5 * (render_object(MODE_A_X) + render_object(MODE_B_X))

assert observed.shape == (SIZE, SIZE)
assert observed.min() >= 0.0 and observed.max() <= 1.0

Now score the predictions against the realized future. The mean averages two separated blobs with overlapping tails. Its maximum intensity is approximately 0.503 in this discretized example, close to half the peak of either endpoint, so it looks faded.

Out[11]:
Console
Sharp-A  MSE=0.000000  PSNR=inf
Sharp-B  MSE=0.015727  PSNR=18.03 dB
Mean     MSE=0.003932  PSNR=24.05 dB
Out[12]:
Visualization
Realized grayscale blob at horizontal position 20.
The realized future contains the blob at mode A.
Sharp-A grayscale prediction at position 20, matching the reference.
Sharp-A matches the realized mode exactly.
Sharp-B grayscale prediction at position 28, the alternative mode.
Sharp-B matches the other plausible mode, not this realization.
Two faded grayscale blobs formed by averaging both mode images.
The conditional mean overlays both modes at reduced intensity.
Out[13]:
Visualization
Bar chart of MSE for three predictions, ranked Sharp-A, Mean, Sharp-B.
Paired pixel MSE for the three predictions against the realized future. Sharp-A wins trivially because it happens to match the realized mode, Sharp-B is heavily penalized even though the data generator itself can produce it, and the conditional mean sits between them. PSNR gives the same ranking on a log scale.

The bar chart makes the first-class concern of this chapter concrete. Pixel error rewards the model that got lucky on this particular draw, not the model that captured the conditional. Sharp-B is a mode the ground-truth process itself can produce; if the realized future had been Sharp-B instead, the ranking would flip. And the conditional mean, which is MSE-optimal on average, looks neither like Sharp-A nor Sharp-B in this particular draw.

One paired score evaluates one prediction against one realized future. Repeated paired MSE estimates expected squared error, but even that expectation does not characterize the full conditional distribution: the conditional mean is optimal without representing its modes or probabilities. Distributional tests with explicit conditioning or proper probabilistic scores answer a different question.

MSE remains useful for measuring paired accuracy. To assess the forecast distribution, use a declared probabilistic scoring rule or conditional distributional diagnostic over enough held-out cases. Merely averaging more paired MSE values does not turn MSE into a complete distributional test.