Md. Asif Uddin
    Problem I.13.B03

    When the code switches off

    limit▲▲△

    Exact values where possible; six decimal places otherwise.

    STATEMENT

    Solve the linear β-VAE exactly, find its rate and distortion, and follow them as β goes to zero and as β grows past the point where the code is abandoned.

    GIVEN

    Centred data whose covariance has eigenvalues λ1>λ2≥⋯\lambda_1>\lambda_2\geq\cdots, the top one along u1\vec u_1. One latent dimension with prior N(0,1)\mathcal N(0,1), a decoder x∣z∼N(wz,σ2I)\vec x\mid z\sim\mathcal N(\vec wz,\sigma^2\mat I) with σ2\sigma^2 fixed, and an encoder N(m,v)\mathcal N(m,v) chosen freely for each input. The objective is the average of Eqlog⁡p(x∣z)−β KL⁡(q ∥ N(0,1))\E_q\log p(\vec x\mid z)-\beta\,\KL(q\,\|\,\mathcal N(0,1)). For numbers use the four points of I.12: λ1=4\lambda_1=4, λ2=1\lambda_2=1, σ2=1\sigma^2=1.

    FIND

    (a) The best encoder for a given w\vec w. (b) The best ∥w∥2\|\vec w\|^2. (c) The rate and the mean squared distortion there. (d) The limits β→0\beta\to0 and βσ2≥λ1\beta\sigma^2\geq\lambda_1. (e) A table for the four points at β=0.25\beta=0.25, 11, 22 and 44.

    STRATEGY

    Write a=wTxa=\vec w^{\mathsf T}\vec x, r=∥w∥2r=\|\vec w\|^2 and c=r+βσ2c=r+\beta\sigma^2. Optimise the encoder first; what is left depends on w\vec w only through rr and its direction.

    SOLUTION

    (a) For one input, up to terms that do not involve mm or vv, the objective is

    2am−(m2+v)r2σ2−β2(m2+v−1−log⁡v).\begin{aligned} &\frac{2am-(m^2+v)r}{2\sigma^2}\\ &\quad-\frac\beta2\big(m^2+v-1-\log v\big). \end{aligned}

    Setting the derivatives in mm and vv to zero,

    m=ac,v=βσ2c.m=\frac{a}{c},\qquad v=\frac{\beta\sigma^2}{c}.

    (b) Substituting, the terms in a2a^2 combine to a2/(2σ2c)a^2/(2\sigma^2c) and the terms in vv to β2log⁡(βσ2/c)\tfrac\beta2\log(\beta\sigma^2/c), up to constants. Averaged over the data, E[a2]=wTSw\E[a^2]=\vec w^{\mathsf T}\mat S\vec w, which for a given rr is largest, rλ1r\lambda_1, when w\vec w lies along u1\vec u_1. What remains is

    J(r)=rλ12σ2c−β2log⁡c+const,\begin{aligned} J(r)&=\frac{r\lambda_1}{2\sigma^2c}-\frac\beta2\log c\\ &\quad+\text{const}, \end{aligned}

    with derivative

    J′(r)=β2c(λ1c−1).J'(r)=\frac{\beta}{2c}\Big(\frac{\lambda_1}{c}-1\Big).

    It is positive while c<λ1c<\lambda_1 and negative after, so

    r=max⁡(λ1−βσ2,  0).r=\max(\lambda_1-\beta\sigma^2,\;0).

    (c) While the code is in use, c=λ1c=\lambda_1. Then E[m2]=r/λ1\E[m^2]=r/\lambda_1 and v=βσ2/λ1v=\beta\sigma^2/\lambda_1, and the average KL is

    R=12(r+βσ2λ1−1−log⁡βσ2λ1)=12log⁡λ1βσ2.\begin{aligned} R&=\tfrac12\Big(\frac{r+\beta\sigma^2}{\lambda_1}-1\\ &\qquad-\log\frac{\beta\sigma^2}{\lambda_1}\Big)\\ &=\tfrac12\log\frac{\lambda_1}{\beta\sigma^2}. \end{aligned}

    The squared error averages to tr⁡S−2r+(E[m2]+v) r=tr⁡S−r\operatorname{tr}\mat S-2r+(\E[m^2]+v)\,r=\operatorname{tr}\mat S-r, so

    D=∑i>1λi+βσ2.D=\sum_{i>1}\lambda_i+\beta\sigma^2.

    (d) As β→0\beta\to0, r→λ1r\to\lambda_1, the encoder’s variance βσ2/λ1\beta\sigma^2/\lambda_1 goes to zero, the rate grows like −12log⁡β-\tfrac12\log\beta without bound, and the distortion falls to ∑i>1λi\sum_{i>1}\lambda_i, the loss of the principal-axis autoencoder of I.12.T1. The code tends to u1Tx/λ1\vec u_1^{\mathsf T}\vec x/\sqrt{\lambda_1}: the principal score, scaled to the prior’s unit variance.

    As βσ2\beta\sigma^2 rises to λ1\lambda_1, rr and RR fall to zero and DD rises to tr⁡S\operatorname{tr}\mat S. For any larger β\beta, J′(r)<0J'(r)<0 for all r≥0r\geq0: the optimum is w=0\vec w=\vec 0, the encoder returns N(0,1)\mathcal N(0,1) for every input, and the code is ignored.

    (e) With λ1=4\lambda_1=4, λ2=1\lambda_2=1 and σ2=1\sigma^2=1, R=12log⁡(4/β)R=\tfrac12\log(4/\beta) and D=1+βD=1+\beta:

    β\betarrvvRRDD
    0.250.253.753.750.06250.06251.3862941.3862941.251.25
    11330.250.250.6931470.69314722
    22220.50.50.3465740.34657433
    4400110055

    Answer

    m=a/(r+βσ2)m=a/(r+\beta\sigma^2) and v=βσ2/(r+βσ2)v=\beta\sigma^2/(r+\beta\sigma^2); ∥w∥2=max⁡(λ1−βσ2,0)\|\vec w\|^2=\max(\lambda_1-\beta\sigma^2,0) along u1\vec u_1; while in use, R=12log⁡(λ1/βσ2)R=\tfrac12\log(\lambda_1/\beta\sigma^2) and D=∑i>1λi+βσ2D=\sum_{i>1}\lambda_i+\beta\sigma^2. As β→0\beta\to0, D→∑i>1λiD\to\sum_{i>1}\lambda_i and R→∞R\to\infty; from βσ2=λ1\beta\sigma^2=\lambda_1 on, the code is unused, with R=0R=0 and D=tr⁡SD=\operatorname{tr}\mat S.

    Check — sanity

    At β=1\beta=1 the encoder is the exact posterior of (I.13.2), r=3r=3 is probabilistic PCA’s ∥w∥2\|\vec w\|^2, and the objective equals the log-evidence −3.531024-3.531024 of every corner. The curve is continuous at the threshold: 1+4=5=tr⁡S1+4=5=\operatorname{tr}\mat S.

    Where this breaks

    The solution needs σ2\sigma^2 fixed. If it is learned, at β=1\beta=1 it settles at the average discarded eigenvalue, and a direction collapses when its eigenvalue does not exceed that. With several latent dimensions the same threshold applies to each eigen-direction separately.

    Variation

    At β=8\beta=8 the code is unused, as at β=4\beta=4. At β=0.5\beta=0.5 the rate is 12log⁡8=1.039721\tfrac12\log8=1.039721 and the distortion 1.51.5. Halving β\beta always adds 12log⁡2=0.346574\tfrac12\log2=0.346574 nats to the rate.

    Draws on