Four questions about model behavior

Start from the definitions supplied in each task.

  1. Attention: who bites whom?
  2. Ensembles: why can more models stop helping?
  3. Evidence: how can we construct a lower bound?
  4. Latent codes: what does good reconstruction reveal?

Variant 1, Task 30.

Can attention tell who bites whom? · Exact examination statement · 1/2

Consider one self-attention layer on three token embeddings x1,x2,x3x_1,x_2,x_3. There are no positional features, masks or dropout. Queries and keys have dimension dkd_k. The same matrices are used at every position: qi=WQxi,ki=WKxi,vi=WVxi,aij=exp⁡(qi⊤kj/dk)∑r=13exp⁡(qi⊤kr/dk),hi=∑j=13aijvj. q_i=W_Qx_i,\quad k_i=W_Kx_i,\quad v_i=W_Vx_i,\qquad a_{ij}=\frac{\exp(q_i^\top k_j/\sqrt{d_k})} {\sum_{r=1}^3\exp(q_i^\top k_r/\sqrt{d_k})},\quad h_i=\sum_{j=1}^3a_{ij}v_j. Compare A: “dog bites man” with B: “man bites dog”. Each word has a fixed embedding, so B exchanges x1,x3x_1,x_3 and keeps x2x_2. A classifier receives only h2h_2, the contextual representation of “bites”.

Variant 1, Task 30. Questions

Can attention tell who bites whom? · Exact examination statement · 2/2

(a) Express B’s three weights for query 2 in terms of A’s weights. Use this to prove that the classifier receives the same vector in A and B.

(b) Is the entire ordered output (h1,h2,h3)(h_1,h_2,h_3) also necessarily unchanged? Give its exact relation to A’s output and justify it.

(c) Now replace each input by xi+pix_i+p_i, where pip_i is a fixed vector attached to position ii. Explain precisely why the previous permutation argument need no longer hold when p1≠p3p_1\ne p_3. Does this guarantee that every choice of WQ,WK,WVW_Q,W_K,W_V distinguishes the sentences? Justify.

Follow the words through the swap

Variant 1 · A word keeps its embedding when its slot changes

The outer dog and person tiles exchange slots while the middle action tile remains fixed. Arrows indicate token permutation, not attention weights.
dog · e1e_1bites · e2e_2man · e3e_3
man · e3e_3bites · e2e_2dog · e1e_1

The middle query stays fixed; keys and values move together.

Can attention tell who bites whom?

Variant 1 · Fixed word embeddings · Shared weights · No positions, masks or dropout

Sentence Position 1 Position 2 Position 3
A dog bites man
B man bites dog

qi=WQxi,ki=WKxi,vi=WVxi,aij=exp⁡(qi⊤kj/dk)∑r=13exp⁡(qi⊤kr/dk),hi=∑jaijvj.q_i=W_Qx_i,\quad k_i=W_Kx_i,\quad v_i=W_Vx_i,\qquad a_{ij}=\frac{\exp(q_i^\top k_j/\sqrt{d_k})}{\sum_{r=1}^3\exp(q_i^\top k_r/\sqrt{d_k})},\quad h_i=\sum_j a_{ij}v_j.

Vocabulary [dog, bites, man]: xdog=e1x_{\mathrm{dog}}=e_1, xbites=e2x_{\mathrm{bites}}=e_2, xman=e3x_{\mathrm{man}}=e_3. Word identity stays fixed when its slot changes. The classifier reads only h2h_2.

The middle word stays in place: q2′=q2q'_2=q_2.

Keys and values exchange slots 1 and 3 together.

The middle representation

Variant 1(a) · A has weights (a21,a22,a23)(a_{21},a_{22},a_{23})

h2=a21v1+a22v2+a23v3.h_2=a_{21}v_1+a_{22}v_2+a_{23}v_3.

Illustration with one-hot values: (12,e1),(13,e2),(16,e3)(\tfrac12,e_1),(\tfrac13,e_2),(\tfrac16,e_3) move as pairs. Their sum stays (12,13,16)(\tfrac12,\tfrac13,\tfrac16).

Swapping the keys reorders the denominator’s three terms. Its sum stays fixed.

(a21′,a22′,a23′)=(a23,a22,a21). (a'_{21},a'_{22},a'_{23})=(a_{23},a_{22},a_{21}).

h2′=a23v3⏟new slot 1+a22v2⏟slot 2+a21v1⏟new slot 3=h2.h'_2=\underbrace{a_{23}v_3}_{\text{new slot 1}}+ \underbrace{a_{22}v_2}_{\text{slot 2}}+ \underbrace{a_{21}v_1}_{\text{new slot 3}}=h_2.

A deterministic classifier of h2h_2 receives the same vector.

Outputs follow the words

Variant 1(b) · Rows are query slots; columns are key/value slots

Stack token transposes as rows: X∈ℝ3×dX\in\mathbb R^{3\times d}, Q=XWQ⊤Q=XW_Q^\top, K=XWK⊤K=XW_K^\top, V=XWV⊤V=XW_V^\top.

P=(001010100),X′=PX,Aatt=softmax⁡rows(QK⊤/dk).P=\begin{pmatrix}0&0&1\\0&1&0\\1&0&0\end{pmatrix},\quad X'=PX,\quad A_{\mathrm{att}}=\operatorname{softmax}_{\mathrm{rows}}(QK^\top/\sqrt{d_k}).

Both query rows and key columns move. Row denominators keep the same terms: Aatt′=PAattP⊤,V′=PV.A'_{\mathrm{att}}=P A_{\mathrm{att}}P^\top,\qquad V'=PV.

H′=PAattP⊤P⏟IV=PH,(h1′,h2′,h3′)=(h3,h2,h1).H'=P A_{\mathrm{att}}\underbrace{P^\top P}_{I}V=PH, \qquad (h'_1,h'_2,h'_3)=(h_3,h_2,h_1).

The sequence is equivariant; the selected middle row is unchanged.

Position supplies additional information

Variant 1(c) · Replace each word input by xi+pix_i+p_i, with p1≠p3p_1\ne p_3

A’s endpoints B’s endpoints
Augmented inputs (x1+p1,x3+p3)(x_1+p_1,\ x_3+p_3) (x3+p1,x1+p3)(x_3+p_1,\ x_1+p_3)

Position vectors stay attached to slots when words move. Xaug′=PX+Epos,PXaug=PX+PEpos.X'_{\mathrm{aug}}=PX+E_{\mathrm{pos}},\qquad PX_{\mathrm{aug}}=PX+PE_{\mathrm{pos}}.

Their difference is Epos−PEpos≠0E_{\mathrm{pos}}-PE_{\mathrm{pos}}\ne0 when p1≠p3p_1\ne p_3. The swap proof no longer guarantees the output relation.

A counterexample to a guarantee: WV=0W_V=0 makes every output zero.

Position can enable a distinction; learned weights must use it.

Variant 2, Task 30.

Why more models can stop helping · Exact examination statement · 1/2

At a fixed input xx, repeated random training runs produce predictions F1,…,FMF_1,\ldots,F_M, where M≥2M\ge2. For a fixed target value yy, assume 𝔼[Fm]=y+b,Var⁡(Fm)=σ2>0,Cov⁡(Fm,Fr)=ρσ2(m≠r),0≤ρ≤1. \mathbb E[F_m]=y+b,\qquad \operatorname{Var}(F_m)=\sigma^2>0,\qquad \operatorname{Cov}(F_m,F_r)=\rho\sigma^2\quad(m\ne r),\quad 0\le\rho\le1. The ensemble prediction is F¯=M−1∑mFm\overline F=M^{-1}\sum_m F_m. All expectations concern randomness in training, not different inputs. You may use Var⁡(Z)=𝔼[(Z−𝔼Z)2]\operatorname{Var}(Z)=\mathbb E[(Z-\mathbb E Z)^2] and Cov⁡(Z,T)=𝔼[(Z−𝔼Z)(T−𝔼T)]\operatorname{Cov}(Z,T)=\mathbb E[(Z-\mathbb E Z)(T-\mathbb E T)].

Variant 2, Task 30. Questions

Why more models can stop helping · Exact examination statement · 2/2

(a) Expand the square in the variance definition to derive Var⁡(F¯)\operatorname{Var}(\overline F). Show how many diagonal and off-diagonal terms occur; do not quote a memorized ensemble formula.

(b) By adding and subtracting 𝔼[F¯]\mathbb E[\overline F], derive 𝔼[(F¯−y)2]\mathbb E[(\overline F-y)^2]. Find its limit as M→∞M\to\infty and explain which two obstacles cannot be removed merely by increasing MM.

(c) Suppose ρ=1/4\rho=1/4. Can any finite MM make the ensemble variance at most σ2/4\sigma^2/4? Explain. What does the formula say when ρ=1\rho=1?

Averaging random predictions

Variant 2 · Fixed input xx and target yy · Randomness comes from training

𝔼[Fm]=y+b,Var⁡(Fm)=σ2>0,\mathbb E[F_m]=y+b,\qquad \operatorname{Var}(F_m)=\sigma^2>0, Cov⁡(Fm,Fr)=ρσ2(m≠r),0≤ρ≤1.\operatorname{Cov}(F_m,F_r)=\rho\sigma^2\quad(m\ne r),\qquad 0\le\rho\le1. F¯=1M∑m=1MFm,M≥2.\overline F=\frac1M\sum_{m=1}^M F_m,\qquad M\ge2.

Fixed target yy → common center y+by+b → predictions F1,…,FMF_1,\ldots,F_M. Averaging changes their spread, while the common center stays fixed.

Center each prediction: Gm=Fm−(y+b)G_m=F_m-(y+b).

𝔼[Gm]=0,𝔼[F¯]=y+b.\mathbb E[G_m]=0,\qquad \mathbb E[\overline F]=y+b.

Here bb is common prediction bias and σ2\sigma^2 is prediction variance across training runs.

Counting covariance terms

Variant 2(a) · Expand the square before simplifying

Var⁡(F¯)=1M2𝔼[(∑mGm)2].\operatorname{Var}(\overline F)=\frac1{M^2}\mathbb E\left[\left(\sum_m G_m\right)^2\right].

=Mσ2⏞diagonal+M(M−1)ρσ2⏞off-diagonalM2.=\frac{\overbrace{M\sigma^2}^{\text{diagonal}}+ \overbrace{M(M-1)\rho\sigma^2}^{\text{off-diagonal}}}{M^2}.

=σ2(ρ+1−ρM).=\sigma^2\left(\rho+\frac{1-\rho}{M}\right).

Example: M=4M=4

σ² ρσ² ρσ² ρσ²
ρσ² σ² ρσ² ρσ²
ρσ² ρσ² σ² ρσ²
ρσ² ρσ² ρσ² σ²

4 diagonal + 12 ordered off-diagonal terms

Correlated fluctuations survive averaging.

Bias and variance in prediction error

Variant 2(b) · What remains after averaging?

Error budget: common bias² + shared fluctuation + averaged fluctuation.

F¯−y=(F¯−𝔼[F¯])+b.\overline F-y=(\overline F-\mathbb E[\overline F])+b.

𝔼[(F¯−y)2]=Var⁡(F¯)+2b𝔼[F¯−𝔼F¯]⏟0+b2.\mathbb E[(\overline F-y)^2] =\operatorname{Var}(\overline F)+2b\underbrace{\mathbb E[\overline F-\mathbb E\overline F]}_{0}+b^2.

=b2+σ2(ρ+1−ρM).=b^2+\sigma^2\left(\rho+\frac{1-\rho}{M}\right).

limM→∞𝔼[(F¯−y)2]=b2⏟common bias+ρσ2⏟correlation floor.\lim_{M\to\infty}\mathbb E[(\overline F-y)^2] =\underbrace{b^2}_{\text{common bias}}+\underbrace{\rho\sigma^2}_{\text{correlation floor}}.

Can a finite ensemble reach the floor?

Variant 2(c) · Set ρ=1/4\rho=1/4

Normalized ensemble variance versus model count. Rho zero decreases toward zero, rho one quarter approaches one quarter from above, and rho one stays at one. Line styles and labels distinguish the curves.

Var⁡(F¯)σ2=14+34M>14for every finite M.\frac{\operatorname{Var}(\overline F)}{\sigma^2} =\frac14+\frac{3}{4M}>\frac14\quad\text{for every finite }M.

At ρ=1\rho=1, the variance stays σ2\sigma^2 for every MM.

Variant 3, Task 30.

Build a lower bound from a weighted average · Exact examination statement · 1/2

Fix an observation xx. A latent variable uu takes values 1,…,K1,\ldots,K. The model specifies strictly positive numbers pθ(x,u)p_\theta(x,u), and pθ(x)=∑upθ(x,u)p_\theta(x)=\sum_u p_\theta(x,u). Choose any probabilities qu>0q_u>0 with ∑uqu=1\sum_u q_u=1. Define ℬ(q)=∑uquln⁡pθ(x,u)qu. \mathcal B(q)=\sum_u q_u\ln\frac{p_\theta(x,u)}{q_u}. You may use the strict concavity of the natural logarithm: ln⁡(∑uqutu)≥∑uquln⁡tu\ln(\sum_u q_u t_u)\ge\sum_u q_u\ln t_u for tu>0t_u>0, with equality exactly when all tut_u are equal.

Variant 3, Task 30. Questions

Build a lower bound from a weighted average · Exact examination statement · 2/2

(a) Rewrite pθ(x)p_\theta(x) as a qq-weighted average and prove ℬ(q)≤ln⁡pθ(x)\mathcal B(q)\le\ln p_\theta(x). Find the unique qq that gives equality and identify it probabilistically.

(b) Let ru=pθ(x,u)/pθ(x)r_u=p_\theta(x,u)/p_\theta(x) and define D(q∥r)=∑uquln⁡(qu/ru)D(q\|r)=\sum_u q_u\ln(q_u/r_u). Show by expansion that ln⁡pθ(x)−ℬ(q)=D(q∥r)\ln p_\theta(x)-\mathcal B(q)=D(q\|r). What does part (a) tell you about the sign of DD?

(c) If pθ(x,u)=p(u)pθ(x∣u)p_\theta(x,u)=p(u)p_\theta(x\mid u), rewrite ℬ(q)\mathcal B(q) as an expected log-likelihood minus D(q∥p)D(q\|p), using the same definition of DD. Explain the two terms in one sentence. This bound is called the ELBO.

From a hidden cause to its posterior

Variant 3 · Fixed observation xx · Circle: u=1u=1 · Diamond: u=2u=2

The observation informs the likelihood panel. Prior times likelihood gives joint masses, whose sum is evidence. Normalization gives the posterior; a separate trial distribution is shown below.
Prior p(u)p(u)
(0.5,0.5)(0.5,0.5)
Likelihood pθ(x∣u)p_\theta(x\mid u)
(0.2,0.8)(0.2,0.8)
Observed xx
Joint pθ(x,u)p_\theta(x,u)
0.10.4
u=1u=2u=1\qquad u=2
Posterior r(u)r(u)
0.20.8
u=1u=2u=1\qquad u=2
Sum: pθ(x)=0.5p_\theta(x)=0.5
Normalize: r(u)=pθ(x,u)/0.5r(u)=p_\theta(x,u)/0.5
Trial qq: (0.5,0.5)(0.5,0.5)
Chosen separately from the model

Evidence is a scalar. The posterior is a distribution over hidden states.

Evidence is a sum over hidden states

Variant 3 · Fix an observation xx · Latent state u=1,…,Ku=1,\ldots,K

pθ(x)=∑upθ(x,u),pθ(x,u)>0.p_\theta(x)=\sum_u p_\theta(x,u),\qquad p_\theta(x,u)>0.

Joint masses (0.1,0.4)(0.1,0.4) → sum 0.50.5 → normalize to posterior (0.2,0.8)(0.2,0.8).

Choose qu>0q_u>0, ∑uqu=1\sum_u q_u=1:

ℬ(q)=∑uquln⁡pθ(x,u)qu.\mathcal B(q)=\sum_u q_u\ln\frac{p_\theta(x,u)}{q_u}.

Supplied tool: concavity of the natural logarithm

ln⁡(∑uqutu)≥∑uquln⁡tu,tu>0.\ln\left(\sum_u q_u t_u\right)\ge\sum_u q_u\ln t_u,\qquad t_u>0.

Equality holds exactly when all tut_u are equal.

A weighted average inside the logarithm

Variant 3(a) · How can the supplied inequality apply to the evidence?

pθ(x)=∑uqupθ(x,u)qu.p_\theta(x)=\sum_u q_u\frac{p_\theta(x,u)}{q_u}.

Set tu=pθ(x,u)/qut_u=p_\theta(x,u)/q_u. The weights sum to one.

ln⁡pθ(x)=ln⁡(∑uqutu)≥∑uquln⁡tu=ℬ(q).\ln p_\theta(x)=\ln\left(\sum_u q_u t_u\right) \ge\sum_u q_u\ln t_u=\mathcal B(q).

Every admissible qq gives a lower bound on log evidence.

The concave logarithm at the weighted mean 0.5 lies above the mean of the logarithms at 0.2 and 0.8.

When does the bound touch the evidence?

Variant 3(a) · Use the equality condition and normalization

pθ(x,u)qu=cfor every u.\frac{p_\theta(x,u)}{q_u}=c\quad\text{for every }u.

pθ(x)=∑ucqu=c.p_\theta(x)=\sum_u c q_u=c.

qu=pθ(x,u)pθ(x)=pθ(u∣x).q_u=\frac{p_\theta(x,u)}{p_\theta(x)}=p_\theta(u\mid x).

The unique equality distribution is the exact posterior.

The model is fixed. Varying qq changes the bound; log evidence stays fixed.

Joint masses 0.1 and 0.4 sum to evidence 0.5. Normalization gives posterior 0.2 and 0.8; the trial distribution can match it.

The gap is a posterior KL

Variant 3(b) · Define ru=pθ(u∣x)r_u=p_\theta(u\mid x) and D(q∥r)=∑uquln⁡(qu/ru)D(q\|r)=\sum_u q_u\ln(q_u/r_u)

Fixed log evidence = chosen bound + nonnegative inference gap. The gap compares qq with the posterior, not the prior.

D(q∥r)=∑uqu[lnqu−lnpθ(x,u)+lnpθ(x)].D(q\|r)=\sum_u q_u\left[\ln q_u-\ln p_\theta(x,u)+\ln p_\theta(x)\right].

Since ∑uqu=1\sum_u q_u=1,

D(q∥r)=ln⁡pθ(x)−ℬ(q).D(q\|r)=\ln p_\theta(x)-\mathcal B(q).

D(q∥r)≥0,D(q∥r)=0⇔q=r.D(q\|r)\ge0,\qquad D(q\|r)=0\iff q=r.

The posterior KL measures how far the bound falls below log evidence.

Two KLs, two different questions

Variant 3(c) · Prior p(u)p(u) · Trial q(u)q(u) · Posterior r(u)=pθ(u∣x)r(u)=p_\theta(u\mid x)

Posterior KL: how much does inference miss? Prior KL: what does the code cost?

pθ(x,u)=p(u)pθ(x∣u),ln⁡pθ(x,u)qu=ln⁡pθ(x∣u)−ln⁡qup(u).p_\theta(x,u)=p(u)p_\theta(x\mid u),\qquad \ln\frac{p_\theta(x,u)}{q_u}=\ln p_\theta(x\mid u)-\ln\frac{q_u}{p(u)}.

ℬ(q)=𝔼q[ln⁡pθ(x∣u)]⏟R:explain the observation−D(q∥p)⏟C:deviation from prior.\mathcal B(q)=\underbrace{\mathbb E_q[\ln p_\theta(x\mid u)]}_{R:\ \text{explain the observation}} -\underbrace{D(q\|p)}_{C:\ \text{deviation from prior}}.

ln⁡pθ(x)=ℬ(q)+D(q∥r)⏟posterior gap.\ln p_\theta(x)=\mathcal B(q)+\underbrace{D(q\|r)}_{\text{posterior gap}}. Course notation: ℰ=ℬ(q)\mathcal E=\mathcal B(q) is the ELBO, maximized during fitting.

An exact posterior closes the gap; it need not equal the prior.

An exact two-state check

Additional example · Joint masses (0.1,0.4)(0.1,0.4) · Evidence 0.50.5 · Posterior (0.2,0.8)(0.2,0.8)

For joint masses 0.1 and 0.4, log evidence remains at ln 0.5. The ELBO curve touches this line at trial mass 0.2 for latent state one. At trial mass 0.5 the posterior KL gap is about 0.2231 nats.

q=(0.5,0.5)q=(0.5,0.5): ℬ=12ln⁡0.2+12ln⁡0.8=ln⁡0.4≈−0.9163\mathcal B=\tfrac12\ln0.2+\tfrac12\ln0.8=\ln0.4\approx-0.9163.

ln⁡pθ(x)=ln⁡0.5≈−0.6931\ln p_\theta(x)=\ln0.5\approx-0.6931; gap =ln⁡1.25≈0.2231=\ln1.25\approx0.2231.

q=(0.2,0.8)q=(0.2,0.8): both joint-to-qq ratios equal 0.50.5, so the gap is zero.

Variant 4, Task 30.

Good reconstruction or a useful latent variable? · Exact examination statement · 1/2

Let both the observation xx and latent variable uu be binary. The prior is p(u=0)=p(u=1)=1/2p(u=0)=p(u=1)=1/2. Compare two complete models:

  • Model A: pA(x=u∣u)=1p_A(x=u\mid u)=1 and pA(x≠u∣u)=0p_A(x\ne u\mid u)=0; its encoder assigns qA(u=x∣x)=1q_A(u=x\mid x)=1.
  • Model B: pB(x=0∣u)=pB(x=1∣u)=1/2p_B(x=0\mid u)=p_B(x=1\mid u)=1/2 for either uu; its encoder assigns qB(u=0∣x)=qB(u=1∣x)=1/2q_B(u=0\mid x)=q_B(u=1\mid x)=1/2.

For the observation x=1x=1, define the reconstruction score and latent cost R=∑u:q(u∣1)>0q(u∣1)ln⁡p(1∣u),C=∑u:q(u∣1)>0q(u∣1)ln⁡q(u∣1)p(u). R=\sum_{u:q(u\mid1)>0}q(u\mid1)\ln p(1\mid u),\qquad C=\sum_{u:q(u\mid1)>0}q(u\mid1)\ln\frac{q(u\mid1)}{p(u)}. The training score is R−CR-C, which is maximized. Zero-probability encoder states are omitted from these sums. Natural logarithms are used. You may use p(x)=∑up(x∣u)p(u)p(x)=\sum_u p(x\mid u)p(u) and p(u∣x)=p(x∣u)p(u)/p(x)p(u\mid x)=p(x\mid u)p(u)/p(x).

Variant 4, Task 30. Questions

Good reconstruction or a useful latent variable? · Exact examination statement · 2/2

(a) Compute pA(x=1)p_A(x=1) and pB(x=1)p_B(x=1) by summing over uu. Can likelihood of this observation distinguish the two models?

(b) Compute RR, CC and R−CR-C for each model. Explain why the model with better reconstruction does not obtain a better total score here.

(c) Use Bayes’ rule to find pA(u∣x=1)p_A(u\mid x=1) and pB(u∣x=1)p_B(u\mid x=1). Which latent variable carries information about xx, and which model ignores it? Explain why equal likelihood need not imply equally informative latent representations.

Same observations, different hidden relationships

Variant 4 · Hidden states: circle u=0u=0, diamond u=1u=1 · Observations: square x=0x=0, triangle x=1x=1

Model A: copies the hidden state

Model B: ignores the hidden state

Model A connects each hidden state only to its matching observation. Model B connects either hidden state to both observations. Connectors show allowed pairings; exact probabilities are specified below.

Allowed links: pA(x=u∣u)=1p_A(x=u\mid u)=1.
Other links: probability 00.

Every link: pB(x∣u)=1/2p_B(x\mid u)=1/2.

Both start from p(u)=(1/2,1/2)p(u)=(1/2,1/2). Does the observed distribution reveal the difference?

Two binary generative models

Variant 4 · x,u∈{0,1}x,u\in\{0,1\} · Prior p(u=0)=p(u=1)=1/2p(u=0)=p(u=1)=1/2

Joint masses p(u,x)p(u,x): hidden-state rows, observation columns.

A: x=0x=0 A: x=1x=1 B: x=0x=0 B: x=1x=1
u=0u=0 1/21/2 00 1/41/4 1/41/4
u=1u=1 00 1/21/2 1/41/4 1/41/4

A copies uu; qA(u=x∣x)=1q_A(u=x\mid x)=1. B ignores uu; qB(u∣x)=1/2q_B(u\mid x)=1/2.

For x=1x=1, sum only over states with q>0q>0:

R=∑u:q(u∣1)>0q(u∣1)ln⁡p(1∣u),C=∑u:q(u∣1)>0q(u∣1)ln⁡q(u∣1)p(u).R=\sum_{u:q(u\mid1)>0}q(u\mid1)\ln p(1\mid u),\qquad C=\sum_{u:q(u\mid1)>0}q(u\mid1)\ln\frac{q(u\mid1)}{p(u)}.

Maximize R−CR-C: reconstruction score minus latent cost.

Marginalizing the latent state

Variant 4(a) · Can the likelihood of x=1x=1 distinguish the models?

Use p(x)=∑up(x∣u)p(u)p(x)=\sum_u p(x\mid u)p(u).

pA(1)=0⋅12⏟u=0+1⋅12⏟u=1=12.p_A(1)=\underbrace{0\cdot\tfrac12}_{u=0}+\underbrace{1\cdot\tfrac12}_{u=1}=\tfrac12.

pB(1)=12⋅12⏟u=0+12⋅12⏟u=1=12.p_B(1)=\underbrace{\tfrac12\cdot\tfrac12}_{u=0}+\underbrace{\tfrac12\cdot\tfrac12}_{u=1}=\tfrac12.

Both log evidences equal −ln⁡2-\ln2.

The observation has equal likelihood under both models.

Model A has joint mass one half on each diagonal cell. Model B has one quarter in every cell. Both x equals one columns sum to one half.

Reconstruction and latent cost

Variant 4(b) · Which model achieves the larger score?

Model Reconstruction R Cost C Score R − C
A ln⁡1=0\ln1=0 ln⁡(1/(1/2))=ln⁡2\ln(1/(1/2))=\ln2 −ln⁡2-\ln2
B ln⁡(1/2)=−ln⁡2\ln(1/2)=-\ln2 ln⁡1=0\ln1=0 −ln⁡2-\ln2

A: only u=1u=1 contributes, with encoder probability one.

B: both states have the same log likelihood and the encoder equals the prior.

A’s reconstruction advantage is exactly offset by its latent cost.

Does the latent code carry information?

Variant 4(c) · Apply p(u∣x)=p(x∣u)p(u)/p(x)p(u\mid x)=p(x\mid u)p(u)/p(x)

Conditioning = select the x=1x=1 column, then divide by its sum 1/21/2.

pA(u∣1)=(0,1).The latent state identifies x.p_A(u\mid1)=(0,1).\qquad \text{The latent state identifies }x.

pB(u∣1)=(12,12)=p(u).The decoder ignores u.p_B(u\mid1)=(\tfrac12,\tfrac12)=p(u).\qquad \text{The decoder ignores }u.

Equal likelihood can accompany different amounts of latent information.

Both encoders are exact posteriors: both ELBOs equal log evidence. There is no approximation gap in either model.

Four distinctions to carry forward

  1. Equivariant outputs and an invariant selected readout
  2. Reduced variance and remaining bias/correlation
  3. Log evidence and a lower bound that depends on inference
  4. Accurate reconstruction and information in a latent code

Week 10 connects the ELBO and the usefulness of representations.