Variational Autoencoders Pursue PCA Directions (by Accident)

Michal Rolinek, Dominik Zietlow, Georg Martius

Introduction

The Variational Autoencoder (VAE) is one of the foundational architectures in modern-day deep learning. It serves both as a generative model as well as a representation learning technique. The generative model is predominantely exploited in computer vision with notable exceptions such as generating combinatorial graphs . As for representation learning, there is a variety of applications, ranging over image interpolation , one-shot generalization , language models , speech transformation , and more. Aside from direct applications, VAEs embody the success of variational methods in deep learning and have inspired a wide range of ongoing research .

Recently, unsupervised learning of interpretable latent representations has received a lot of attention. Interpretability of the latent code is an intuitively clear concept. For instance, when representing faces one latent variable would solely correspond to the gender of the person, another to skin tone, yet another to hair color and so forth. Once such a representation is found it allows for interpretable latent code manipulation, which is desirable in a variety of applications; recently, for example, in reinforcement learning .

The term disentanglement offers a more formal approach. A representation is considered disentangled if each latent component encodes precisely one “aspect” (a generative factor) of the data. Under the current disentanglement metrics , VAE-based architectures (β\beta-VAE , TCVAE , FactorVAE ) dominate the benchmarks, leaving behind other approaches such as InfoGAN and DCIGN . Exemplarily, a latent traversal for a β\beta-VAE is shown in Fig. 1 in which precisely one generative factor is isloated (face azimuth).

The success of VAE-based architectures on disentanglement tasks comes with a certain surprise. One surprising aspect is that VAEs have been challenged on both of its own design functionalities, as generative models and as log-likelihood optimizers . Yet, no such claims are made in terms of disentanglement. Another surprise stems from the fact that disentanglement requires the following feature: the representative low-dimensional manifold must be aligned well with the coordinate axes. However, the design of the VAE does not suggest any such mechanism. On the contrary, the idealized log-likelihood objective is, for example, invariant to rotational changes in the alignment.

Such observations have planted a suspicion that the inner workings of the VAE are not sufficiently understood. Several recent works approached this issue . However, a mechanistic explanation for the VAE’s unexpected ability to disentangle is still missing.

In this paper, we isolate an internal mechanism of the VAE (also β\beta-VAE) responsible for choosing a particular latent representation and its alignment. We give theoretical analysis covering also the nonlinear case and explain the discovered dynamics intuitively. We show that this mechanism promotes local orthogonality of the embedding transformation and clarify how this orthogonality corresponds to good disentanglement. Further, we uncover strong resemblance between this mechanism and the classical Principle Components Analysis (PCA) algorithm. We confirm our theoretical findings in experiments.

Our theoretical approach is particular in the following ways: (a) we base the analysis on the implemented loss function in contrast to the typically considered idealized loss, and (b) we identify a specific regime, prevalent in practice, and utilize it for a vital simplification. This simplification is the crucial step in enabling formalization.

The results, other than being significant on their own, also provide a solid explanation of “why β\beta-VAEs disentangle”.

Background

Let us begin with reviewing the basics of VAE, PCA, and of the Singular Value Decomposition (SVD), along with a more detailed overview of disentanglement.

This objective is, however, not tractable and is approximated by the evidence lower bound (ELBO) . For a fixed xi\mathbf{x}^{i} the log-likelihood log⁡p(xi)\log p(\mathbf{x}^{i}) is lower bounded by

where the first term corresponds to the reconstruction loss and the second to the KL divergence between the latent representation q(z∣xi)q(\mathbf{z}\mid\mathbf{x}^{i}) and the prior distribution p(z)p(\mathbf{z}). A variant, the β\beta-VAE , introduces a weighting β\beta on the KL term for regulating the trade-off between reconstruction (first term) and the proximity to the prior. Our analysis will automatically cover this case as well.

Finally, the prior p(z)p(\mathbf{z}) is set to N(0,I)\mathcal{N}(0,\mathcal{I}) and the encoder is assumed to have the form

where μφ\mathbf{\mu}_{\varphi} and σφ\mathbf{\sigma}_{\varphi} are deterministic mappings depending on parameters φ\varphi. Note particularly, that the covariance matrix is enforced to be diagonal. This turns out to be highly significant for the main result of this work. The KL-divergence in (2) can be computed in closed form as

In practical implementations, the reconstruction term from (2) is approximated with either a square loss or a cross-entropy loss.

2 Disentanglement

In the context of learning interpretable representations it is useful to assume that the data originates from a process with some generating factors. For instance, for images of faces this could be face azimuth, skin brightness, hair length, and so on. Disentangled representations can then be defined as ones in which individual latent variables are sensitive to changes in individual generating factors, while being relatively insensitive to other changes . Although quantifying disentanglement is nontrivial, several metrics have been proposed .

Note also, that disentanglement is impossible without first learning a sufficiently expressive latent representation capable of good reconstruction.

In an unsupervised setting, the generating factors are of course unknown and the learning has to resort to statistical properties. Linear dimensionality reduction techniques demonstrate the two basic statistical approaches. Principle Components Analysis (PCA) greedily isolates sources of variance in the data, while Independent Component Analysis (ICA) recovers a factorized representation, see for a recent review.

One important point to make is that disentanglement is sensitive to rotations of the latent embedding. Following the example above, let us denote by aa, ss, and hh, continuous values corresponding to face azimuth, skin brightness, and hair length. Then, if we change the ideal latent representation as follows

we obtain a representation that is equally expressive in terms of reconstruction (in fact we only multiplied with a 3D rotation matrix) but individual latent variables entirely lost their interpretable meaning.

3 PCA and Latent Representations

Let us examine more closely how PCA chooses the alignment of the latent embedding and why it matters.

However, there are many minimizers of (6) that do not induce the same latent representation. In fact, it suffices to append Y′Y^{\prime} with some invertible transformations (e.g. rotations and scaling) and prefix YY with their inverses. This geometrical intuition is well captured using the singular value decomposition (SVD), see also Figure 2.

For the sake of brevity, we will refer to orthogonal transformations (with slight abuse of terminology) simply as rotations.

Define YY and Y′Y^{\prime} with their SVDs as Y=P⊤ΣQY=P^{\top}\Sigma Q and its pseudoinverse Y′=Y†=Q⊤Σ†PY^{\prime}=Y^{\dagger}=Q^{\top}\Sigma^{\dagger}P and see that

so they are indeed also minimizers of the objective (6) irrespective of our choice of QQ and Σ\Sigma.

It is also straightforward to check that the only choices of QQ, which respect the coordinate axes given by PCA, are for ∣Q∣|Q| to be a permutation matrix.

The take-away message (valid also in the non-linear case) from this example is:

Different rotations of the same latent space are equally suitable for reconstruction.

Following the PCA example, we formalize which linear mappings have the desired “axes-preserving” property.

The columns of MM are (pairwise) orthogonal.

In every SVD of MM as M=UΣV⊤M=U\Sigma V^{\top}, ∣V∣|V| is a permutation matrix.

We strongly suggest developing a geometrical understanding for both cases (a) and (b) via Figure 2. For an intuitive understanding of the formal requirement of distinct eigenvalues, we refer to Supp. C.2.

Take into consideration that once the encoder preserves the principle directions of the data, this already ensures an axis-aligned embedding. The same is true also if the decoder is axes-preserving, provided the reconstruction of the autoencoder is accurate.

4 Related work

Due to high activity surrounding VAEs, additional care is needed when it comes to evaluating novelty. To the best of our knowledge, two recent works address related questions and require special attention.

The authors of also aim to explain good performance of (β\beta–)VAE in disentanglement tasks. A compelling intuitive picture of the underlying dynamics is drawn and supporting empirical evidence is given. In particular, the authors hypothesize that “β\beta–VAE finds latent components which make different contributions to the log-likelihood term of the cost function [reconstruction loss]”, while suspecting that the diagonal posterior approximation is responsible for this behavior. Our theoretical analysis confirms both conjectures (see Section 4).

Concurrent work develops ISA-VAE; another VAE-based architecture suited for disentanglement. Some parts of the motivation overlap with the content of our work. First, rotationally nonsymmetric priors are introduced for reasons similar to the content of Section 3.1. And second, both orthogonalization and alignment with PCA directions are empirically observed for VAEs applied to toy tasks.

Results

The message from Example 1 and from the discussion about disentanglement is clear: latent space rotation matters. Let us look how the idealized objectives (1) and (2) handle this.

For a fixed rotation matrix UU we will be comparing a baseline encoder-decoder pair (Encφ⁡,Decθ⁡)(\operatorname{Enc_{\varphi}},\operatorname{Dec_{\theta}}) with a pair (Encφ⁡,U,Decθ⁡,U)(\operatorname{Enc_{\varphi}}_{,U},\operatorname{Dec_{\theta}}_{,U}) defined as

The shortcomings of idealized losses are summarized in the following propositions.

Let φ\varphi, θ\theta be any choice of parameters for encoder-decoder pair (Encφ⁡,U,Decθ⁡,U)(\operatorname{Enc_{\varphi}}_{,U},\operatorname{Dec_{\theta}}_{,U}). Then, if the prior p(z)p(\mathbf{z}) is rotationally symmetric, the value of the log-likelihood objective (1) does not depend on the choice of UU.

Note that the standard prior N(0,I)\mathcal{N}(0,\mathcal{I}) is rotationally symmetric. This deficiency is not salvaged by the ELBO approximation.

Let φ\varphi, θ\theta be any choice of parameters for encoder-decoder pair (Encφ⁡,U,Decθ⁡,U)(\operatorname{Enc_{\varphi}}_{,U},\operatorname{Dec_{\theta}}_{,U}). Then, if the prior p(z)p(\mathbf{z}) is rotationally symmetric, the value of the ELBO objective (2) does not depend on the choice of UU.

We do not claim novelty of these propositions, however we are not aware of their formalization in the literature. The proofs can be found in Supplementary Material (Suppl. A). An important point now follows:

Log-likelihood based methods (with rotationally symmetric priors) cannot claim to be designed to produce disentangled representations.

However, enforcing a diagonal posterior of the VAE encoder (3) disrupts the rotational symmetry and consequently the resulting objective (4) escapes the invariance arguments. Moreover, as we are about to see, this diagonalization comes with beneficial effects regarding disentanglement. We assume this diagonalization was primarily introduced for different reasons (tractability, computational convenience), hence the “by accident” part of the title.

2 Reformulating VAE loss

The fact that VAEs were not meant to promote orthogonality reflects in some technical challenges. For one, we cannot follow a usual workflow of a theoretical argument; set up an idealized objective and find suitable approximations which allow for stochastic gradient descent (a top-down approach). We need to do the exact opposite, start with the implemented loss function and find the right simplifications that allow isolating the effects in question while preserving the original training dynamics (a bottom-up approach). This is the main content of this section.

First, we formalize the typical situation in which VAE architectures “shut down” (fill with pure noise) a subset of latent variables and put high precision on the others.

We say that parameters φ\varphi, θ\theta induce a polarized regime if the latent coordinates {1,2,…,d}\{1,2,\dots,d\} can be partitioned as Va∪VpV_{a}\cup V_{p} (sets of active and passive variables) such that

μj2(x)≪1\mu^{2}_{j}(\mathbf{x})\ll 1 and σj2(x)≈1\sigma^{2}_{j}(\mathbf{x})\approx 1 for j∈Vpj\in V_{p},

σj2(x)≪1\sigma^{2}_{j}(\mathbf{x})\ll 1 for j∈Vaj\in V_{a},

The decoder ignores the passive latent components, i.e.

The polarized regime simplifies the loss LKLL_{\text{KL}} from (4); part (a) ensures zero loss for passive variables and part (b) implies that σj2(x)≪−log⁡(σj2(x))\sigma^{2}_{j}(\mathbf{x})\ll-\log(\sigma^{2}_{j}(\mathbf{x})). All in all, the per-sample-loss reduces to

We will assume the VAE operates in the polarized regime. In Section 5.2, we show on multiple tasks and datasets that the two objectives align very early in the training. This behavior is well-known to practitioners.

Also, we approximate the reconstruction term in (2), as it is most common, with a square loss

where the expectation is over the stochasticity of the encoder. All in all, the loss we will analyze has the form

Moreover, the reconstruction loss can be further decomposed into two parts; deterministic and stochastic. The former is defined by

and captures the square loss of the mean encoder. Whereas the stochastic loss

is purely induced by the noise injected in the encoder.

If the stochastic estimate Decθ⁡(Encφ⁡(xi))\operatorname{Dec_{\theta}}(\operatorname{Enc_{\varphi}}(\mathbf{x}^{i})) is unbiased around Decθ⁡(μ(xi))\operatorname{Dec_{\theta}}(\mu(\mathbf{x}^{i})), then

This decomposition resembles the classical bias-variance decomposition of the square error .

3 The main result

Now, we finally give theoretical evidence for the central claim of the paper:

Optimizing the stochastic part of the reconstruction loss promotes local orthogonality of the decoder.

On that account, we set up an optimization problem which allows us to optimize the stochastic loss (14) independently of the other two. This will isolate its effects on the training dynamics.

In order to make statements about local orthogonality, we introduce for each xi\mathbf{x}^{i} the Jacobian (linear approximation) JiJ_{i} of the decoder at point μ(xi)\mu(\mathbf{x}^{i}), i.e.

Since, according to (3), the encoder can be written as Encφ⁡(xi)=μ(xi)+ε(xi)\operatorname{Enc_{\varphi}}(\mathbf{x}^{i})=\mu(\mathbf{x}^{i})+\varepsilon(\mathbf{x}^{i}) with

we can approximate the stochastic loss (14) with

Although we aim to fix the deterministic loss (13), we do not need to freeze the mean encoder and the decoder entirely. Following Example 1, for each JiJ_{i} and its SVD Ji=UiΣiVi⊤J_{i}=U_{i}\Sigma_{i}V_{i}^{\top}, we are free to modify ViV_{i} as long we correspondingly (locally) modify the mean encoder.

Then we state the optimization problem as follows:

where ε(xi)\varepsilon(\mathbf{x}^{i}) are sampled as in (16).

This optimization is not over network parameters, rather directly over the values of all Vi,σjiV_{i},\sigma^{i}_{j} (only constrained by (19)).

Both the objective and the constraint concern global losses, not per sample losses.

Indeed, none of Vi,σjiV_{i},\sigma^{i}_{j} interfere with the rest of the VAE objective (12).

The presence of the (monotone) log function has one main advantage; we can describe all global minima of (18) in closed form. This is captured in the following theorem, the technical heart of this work.

The following holds for optimization problem (18, 19):

In every global minimum, the columns of every JiJ_{i} are orthogonal.

The full proof as well as an explicit description of the minima is given in Suppl. A.1. However, an outline of the main steps is given in the next section on the example of a linear decoder.

The presence of the log term in (18) admittedly makes our argument indirect. There are, however, a couple of points to make. First, as was mentioned earlier, encouraging orthogonality was not a design feature of the VAE. In this sense, it is unsurprising that our results are also mildly indirect.

Also, and more importantly, the global optimality of Theorem 2 also implies that, locally, orthogonality is encouraged even for the pure (without logarithm) stochastic loss.

For fixed xi∈X\mathbf{x}^{i}\in X consider a subproblem of (18) defined as

Also then, the result on the structure of local (global) minima holds:

In every global minimum, the columns of every JiJ_{i} are orthogonal.

All in all, Theorem 2 justifies the central message of the paper stated at the beginning of this section. The analogy with PCA is now also clearer. Locally, VAEs optimize a tradeoff between reconstruction and orthogonality.

This result is unaffected by the potential β\beta term in Equation (2), although an appropriate β\beta might be required to ensure the polarized regime.

Proof outline

In this section, we sketch the key steps in the proof of Theorem 2 and, more notably, the intuition behind them. The full proof can be found in Suppl. A.1.

We will restrict ourselves to a simplified setting. Consider a linear decoder MM with SVD M=UΣVTM=U\Sigma V^{T}, which removes the necessity of local linearization. This reduces the objective (18) from a “global” problem over all examples xi\mathbf{x}^{i} to an objective where we have the same subproblem for each xi\mathbf{x}^{i}.

As in optimization problem (18, 19), we resort to fixing the mean encoder (imagine a well performing one).

In the next paragraphs, we separately perform the optimization over the parameters σ{\bm{\sigma}} and the optimization over the matrix VV.

For this part, we fix the decoder matrix MM and optimize over values σ2=(σ12,…,σd2)\bm{\sigma}^{2}=(\sigma^{2}_{1},\dots,\sigma^{2}_{d}). The simplified objective is

where the ∥μ∥2\|\mu\|^{2} terms from (10) disappear since the mean encoder is fixed.

The values −log⁡(σj)-\log(\sigma_{j}) can now be thought of as precisions allowed for different latent coordinates. The log⁡\log functions even suggests thinking of the number of significant digits. Problem (22) then asks to distribute the “total precision budget“ so that the deviation from decoding “uncorrupted” values is minimal.

Already here we see, that the latent variable xx seems more influential for the reconstruction. We would expect that xx receives higher precision than yy.

Now, for ε=(εx,εy)\bm{\varepsilon}=(\varepsilon_{x},\varepsilon_{y}), we compute

and after taking the expectation, we can use the fact that ε\bm{\varepsilon} has zero mean and write

Finally, we use that for uncorrelated random variables AA and BB we have var⁡(A+cB)=var⁡A+c2var⁡B\operatorname{var}(A+cB)=\operatorname{var}A+c^{2}\operatorname{var}B. After rearranging we obtain

where σ=(σx2,σy2)\bm{\sigma}=(\sigma^{2}_{x},\sigma^{2}_{y}). Note that the coefficients are the squared norms of the column vectors of M1M_{1}.

This turns the optimization problem (22) into a simple exercise, particularly after realizing that (23) fixes the value of the product σxσy\sigma_{x}\sigma_{y}. Indeed, we can even set a2=50σxa^{2}=50\sigma_{x} and b2=3σyb^{2}=3\sigma_{y} in the trivial inequality a2+b2≥2aba^{2}+b^{2}\geq 2ab and find that

with equality achieved when σx2/σy2=3/50\sigma^{2}_{x}/\sigma^{2}_{y}=3/50. This also implies that the precision −log⁡σx2{-}\log\sigma^{2}_{x} on variable xx will be considerably higher than for yy, just as expected.

Two remarks regarding the general case follow.

The full version of inequality (25) relies on the concavity of the log⁡\log function; in particular, on (a version of) Jensen’s inequality.

The minimum value of the objective depends on the product of the column norms. This also carries over to the unsimplified setting.

2 Isolating sources of variance

Imagine, the encoder alters the latent representation by a 45∘45^{\circ} rotation. Then we can adjust the decoder M1M_{1} by first undoing this rotation. In particular, we set M2=M1R45∘⊤M_{2}=M_{1}R_{45^{\circ}}^{\top}, where RθR_{\theta} is a 2D rotation matrix, rotating by angle θ\theta. We have

and performing analogous optimization as before gives

We see that the minimal value of the objective is more than twice as high, a substantial difference. On a high level, the reason M1M_{1} was a better choice of a decoder is that the variables xx and yy had very different impact on the reconstruction. This allowed to save some precision on variable yy, as it had smaller effect, and use it on xx, where it is more beneficial.

For a higher number of latent variables, one way to achieve a “maximum stretch” among the impacts of latent variables, is to pick them greedily, always picking the next one so that its impact is maximized. This is, at heart, the greedy algorithm for PCA.

Let us consider a slightly more technical statement. We saw in (25) and (26) that after finding optimal values of σ\bm{\sigma} the remaining objective is the product of the column norms of matrix MM. Let us denote such quantity by colΠ⁡(M)=∏j∥M⋅j∥\operatorname{col_{\Pi}}(M)=\prod_{j}\|M_{\cdot j}\|. Then for a fixed matrix MM, we optimize

This problem can be interpreted geometrically. The column vectors of MV⊤MV^{\top} are the images of base vectors eje_{j}. Consequently, the product gives an upper bound on the volume (the image of the unit cube)

However, as orthogonal matrices VV are isometries, they do not change this volume. Also, the bound (28) is tight precisely when the vectors MV⊤ejMV^{\top}e_{j} are orthogonal. Hence, the only way to optimize colΠ⁡(MV⊤)\operatorname{col_{\Pi}}(MV^{\top}) is by tightening the bound, that is by finding VV for which the column vectors of MV⊤MV^{\top} are orthogonal, see Figure 3 for an illustration. In this regards, it is important that MM performs a different scaling along each of the axis (using Σ\Sigma), which allows for changing the angles among the vectors MV⊤ejMV^{\top}e_{j} (cf.​ Figure 2).

Experiments

We performed several experiments with different architectures and datasets to validate our results empirically. We show the prevalence of the polarized regime, the strong orthogonal effects of the (β\beta-)VAE, as well as the links to disentanglement.

Architectures. We evaluate the classical VAE, β\beta-VAE, a plain autoencoder, and β\beta-VAEΣ\text{VAE}_{\Sigma}, where the latter removes the critical diagonal approximation (3) and produces a full covariance matrix Σ(xi)\Sigma(\mathbf{x}^{i}) for every sample. The resulting KL term of the loss is changed accordingly (see Suppl. B.3 for details).

Disentanglement metric. For quantifying the disentanglement of a representation, the so called Mutual Information Gap (MIG) was introduced in . As MIG is not well defined for continuous variables, we use an adjusted definition comprising both continuous and discrete variables, simply referred to as Disentanglement score. Details are described in Suppl. B.1. Just as in the case of MIG, the Disentanglement score is a number between and 11, where higher value means stronger disentanglement.

Orthogonality metric. For measuring the practical effects of Theorem 2, we introduce a measure of non-orthogonality. As argued in Proposition 1 and Figure 2, for a good decoder MM and its SVD M=UΣV⊤M=U\Sigma V^{\top}, the matrix VV should be trivial (a signed permutation matrix). We measure the non-triviality with the Distance to Orthogonality (DtO) defined as follows. For each xi\mathbf{x}^{i}, i=1,…,Ni=1,\dots,N, employing again the Jacobian JiJ_{i} of the decoder at xi\mathbf{x}^{i} and its SVD Ji=UiΣiVi⊤J_{i}=U_{i}\Sigma_{i}V_{i}^{\top} and define

where ∥⋅∥F\|\cdot\|_{F} is the Frobenius norm and P(Vi)P(V_{i}) is a signed permutation matrix that is closest to VV (in L1L^{1} sense). Finding the nearest permutation matrix is solved to optimality via mixed-integer linear programming (see Suppl. B.2).

2 Polarized regime

In Section 3.2, we assumed VAEs operate in a polarized regime and approximated LKLL_{\text{KL}}, the KL term of the implemented objective (4), with L≈KLL_{\approx\text{KL}} (10). In Table 2 we show that the polarized regime is indeed dominating the training in all examples after a short initial phase. We report the fraction of the training time in which the relative error

3 Orthogonality and Disentanglement

Now, we provide evidence for Theorem 2 by investigating the DtO (29) for a variety of architectures and datasets, see Table 1. The results clearly support the claim that the VAE based architectures indeed strive for local orthogonality. By generalizing the β\beta-VAE architecture, such that the approximate posterior is any multivariate Gaussian (β\beta-VAEΣ), the objective becomes rotationally symmetric (just as the idealized objective). As such, no specific alignment is prioritized. The simple autoencoders also do not favor particular orientations of the latent space.

Another important observation is the clear correlation between DtO and the disentanglement score. We show this in Figure 4 where different restarts of the same β\beta-VAE architecture on the dSprites dataset are displayed. We used the state-of-the-art value β=4\beta=4 . Additional experiments are reported in Suppl. C.

Discussion

We isolated the mechanism of VAE that leads to local orthogonalization and, in effect, to performing local PCA. Additionally, we demonstrated the functionality of this mechanism in intuitive terms, in formal terms, and also in experiments. We also explained why this behavior is desirable for enforcing disentangled representations.

Our insights show that VAEs make use of the differences in variance to form the representation in the latent space – collapsing to PCA in the linear case. This does not directly encourage factorized latent representations. With this in mind, it makes perfect sense that recent improvements of (β\beta-)VAE incorporate additional terms promoting precisely independence.

It is also unsatisfying that VAEs promote orthogonality somewhat indirectly. It would seem that designing architectures allowing explicit control over this feature would be beneficial.

Acknowledgements

We thank the whole Autonomous Learning Group at MPI IS, as well as Friedrich Solowjow for the fruitful and invaluable discussions. Also, we thank the International Max Planck Research School for Intelligent Systems (IMPRS-IS) for supporting Dominik Zietlow.

The supplementary information is structured as follows. We start with a remark on Table 2 and then provide the proofs in Section A.1. Section B reports the details of the experiments followed by additional experiments in Section C.

Some dataset-architecture combinations listed in Table 1 are omitted for the following reasons.

On the one hand, calculating the Disentanglement Score for MNIST and fMNIST does not make sense, as the generating factors are not given (the one categorical label cannot serve as replacement). Consequently, as the values of β\beta are chosen according to this score, we do not report β\beta-VAE numbers for these datasets. On the other hand, for either synthetic task, the regular VAE vastly overprunes, see Figure 5, and the values become meaningless.

Appendix A Proofs

For part (b), we aim to derive a lower bound on the objective (18), that is independent from the optimization variables σj2(xi)\sigma^{2}_{j}(\mathbf{x}^{i}) and ViV_{i}. Moreover, we show that this lower bound is tight for some specific choices of σj2(xi)\sigma^{2}_{j}(\mathbf{x}^{i}) and ViV_{i}, i.e. the global optima. For these choices, all JiJ_{i} will have orthogonal columns.

The strategy for part (a) is to show that whenever σj2(xi)\sigma^{2}_{j}(\mathbf{x}^{i}) and ViV_{i} do not induce a global optimum, we can find a small perturbation that decreases the objective function. Thereby showing that local minima do not exist.

Technical lemmas:

We begin with introducing a few useful statements. First is the inequality between arithmetic and geometric mean; a consequence of Jensen’s inequality.

Let a1a_{1}, …, aNa_{N} be nonnegative real numbers. Then

with equality occuring if and only if a1=a2=⋯=ana_{1}=a_{2}=\cdots=a_{n}.

The second bound to be used is the classical Hadamard’s inequality.

with equality if and only if the vectors c1c_{1}, …, ckc_{k} are pairwise orthogonal.

And finally a simple lemma for characterizing matrices with orthogonal columns.

The columns of MM are (pairwise) orthogonal.

The columns of ΣV⊤\Sigma V^{\top} are (pairwise) orthogonal.

The equivalence of (a) and (b) is immediate. For equivalence of (a) and (c) it suffices to notice that if we set M′=ΣV⊤M^{\prime}=\Sigma V^{\top}, then

The equivalence of (a) and (b) now implies that MM has orthogonal columns if and only if M′M^{\prime} does. ∎

Initial considerations:

First, without loss of generality, we will ignore all passive latent variables (in the sense of Definition 1). Formally speaking, we will restrict to the case when the local decoder mappings JiJ_{i} are non-degenerate (i.e. have non-zero singular values). Now dd denotes the dimensionality of the latent space with d=∣Va∣d=|V_{a}|.

Next, we simplify the loss L≈KLL_{\approx\text{KL}}, Equation 10. Up to additive and multiplicative constants, this loss can be, for a fixed sample xi∈X\mathbf{x}^{i}\in X, written as

In the optimization problem (18, 19) the values μ(xi)\mu(\mathbf{x}^{i}) can only be affected via applying an orthogonal transformation ViV_{i}. But such transformation are norm-preserving (isometric) and hence the values ∥μ(xi)∥2\|\mu(\mathbf{x}^{i})\|^{2} do not change in the optimization. As a result, we can restate the constraint (19) as

Proof of Theorem 2(b):

Here, we explain how Theorem 2(b) follows from the following two propositions.

For a fixed sample xi∈X\mathbf{x}^{i}\in X let us denote by c1c_{1}, …, cdc_{d} the column vectors of JiJ_{i}. Then

with equality if and only if ∥cj∥2σj2(xi)=∥ck∥2σk2(xi)\|c_{j}\|^{2}\sigma^{2}_{j}(\mathbf{x}^{i})=\|c_{k}\|^{2}\sigma^{2}_{k}(\mathbf{x}^{i}) for every j,k∈{1,…,d}j,k\in\{1,\dots,d\}.

where by det†⁡(M)\operatorname{det^{\dagger}}(M) we denote the product of the singular values of MM. Equality occurs if and only if c1c_{1}, …, cdc_{d} are pairwise orthogonal.

First, Proposition 6 allows making further estimates in the inequality from Proposition 5. Indeed, we get

and after applying the (monotonous) log function we are left with

Finally, we sum over the samples xi∈X\mathbf{x}^{i}\in X and simplify via (35) as

The right-hand side of this inequality is independent from the values of σj2(xi)\sigma^{2}_{j}(\mathbf{x}^{i}), as well as from the orthogonal matrices ViV_{i}, since these do not influence the singular values of any JiJ_{i}.

Moreover, it is possible to make inequality (41) tight (i.e. reach the global minimum), by setting σj2(xi)\sigma^{2}_{j}(\mathbf{x}^{i}) as hinted by Proposition 5 and by choosing the matrices ViV_{i} such that every JiJ_{i} has orthogonal columns (this is clearly possible as seen in Proposition 1).

This yields the desired description of the global minima of (18). ∎

Proof of Proposition 5:

We further denote by r1r_{1}, …, rnr_{n} the row vectors of JiJ_{i}, and by ar,ca_{r,c} the element of JiJ_{i} at rr-th row and cc-th column. With sampling ε(xi)\bm{\varepsilon}(\mathbf{x}^{i}) according to

we begin simplifying the objective (18) with

Now, as the samples ε(xi)\bm{\varepsilon}(\mathbf{x}^{i}) are zero mean, we can further write

Now we use the fact that for uncorrelated random variables AA and BB we have var⁡(A+cB)=var⁡A+c2var⁡B\operatorname{var}(A+cB)=\operatorname{var}A+c^{2}\operatorname{var}B. This allows to expand the variance of the inner product as

from which the desired inequality follows via setting aj=∥cj∥2σj2(xi)a_{j}=\|c_{j}\|^{2}\sigma^{2}_{j}(\mathbf{x}^{i}) for j=1j=1, …, dd in Lemma 1. Indeed, then we have

Proof of Proposition 6:

For the right-hand side, this is clear as the singular values of UMUM are identical to those of MM. As for the left-hand side, we first need to realize that the vectors cjc_{j} are the images of the canonical basis vectors eje_{j}, i.e. cj=Mejc_{j}=Me_{j} for j=1,…,dj=1,\dots,d. But since UU is an isometry, we have ∥UMej∥=∥Mej∥=∥cj∥\|UMe_{j}\|=\|Me_{j}\|=\|c_{j}\| for every jj, and hence also the column norms are intact by prepending UU to MM.

This allows us to restrict to matrices MM for which the SVD has a simplified form M=ΣV⊤M=\Sigma V^{\top}. Next, let us denote by Σd×d\Sigma_{d\times d} the d×dd\times d top-left submatrix of Σ\Sigma. Note that Σd×d\Sigma_{d\times d} contains all nonzero elements of Σ\Sigma. As a result, the matrix M′=Σd×dV⊤M^{\prime}=\Sigma_{d\times d}V^{\top} contains precisely the nonzero rows of the matrix MM. This implies

In particular, the column vectors cj′c^{\prime}_{j} of M′M^{\prime} have the same norms as those of MM. Now we can write

where the inequality follows from Lemma 2 applied to nonsingular matrix M′M^{\prime}. Equality in Lemma 2 occurs precisely if the columns of M′M^{\prime} are orthogonal. However, according to Lemma 3 and (50), it also follows that the columns of M′M^{\prime} are orthogonal if and only if the columns of MM are. Note that Lemma 3(c) is needed for covering the reduction performed in the first two paragraphs. ∎

Proof of Theorem 2(a):

We show the nonexistence of local minima as follows. For any values of σj2(xi)\sigma^{2}_{j}(\mathbf{x}^{i}) and ViV_{i} that do not minimize the objective function (18), we find a small perturbation that improves this objective.

All estimates involved in establishing inequality (41) rely on either Lemma 1 or Lemma 2, where in both cases, the right-hand side was kept fixed. We show that both of these inequalities can be tightened in such fashion by small perturbations in their parameters.

For any non-negative values a1a_{1}, …, aNa_{N} for which

there exists a small perturbation ai′a^{\prime}_{i} of aia_{i} for i=1,…,Ni=1,\dots,N such that

Since (52) is a sharp inequality, we have ai>aja_{i}>a_{j} for some i≠ji\neq j. Then setting ai′=ai/(1+δ)a^{\prime}_{i}=a_{i}/(1+\delta), aj′=aj(1+δ)a^{\prime}_{j}=a_{j}(1+\delta), and ak′=aka^{\prime}_{k}=a_{k} otherwise, will do the trick. Indeed, we have aiaj=ai′aj′a_{i}a_{j}=a^{\prime}_{i}a^{\prime}_{j} as well as ai+aj>ai′+aj′a_{i}+a_{j}>a^{\prime}_{i}+a^{\prime}_{j} for small enough δ\delta. This ensures both 53 and 54. ∎

An analogous statement for Lemma 2 has the following form.

Then there exists an orthogonal matrix V′V^{\prime}, a small perturbation of VV, such that if we denote by c1′c^{\prime}_{1}, …, ck′c^{\prime}_{k} the column vectors of M′=UΣV′⊤M^{\prime}=U\Sigma V^{\prime\top}, we have

We proceed by induction on kk. For k=2k=2, it can be verified directly that for some small δ\delta (in absolute value) setting V′=VRδV^{\prime}=VR_{\delta}, where RδR_{\delta} is a 2D rotation matrix by angle δ\delta, achieves what is required.

For the general case, the sharp inequality (55) implies that ci⊤cj≠0c_{i}^{\top}c_{j}\neq 0 for some pair of i≠ji\neq j. Without loss of generality, let i=1i=1, j=2j=2. In such case, we consider V′=VRδ2DV^{\prime}=VR^{2D}_{\delta}, where

is a block diagonal matrix, in which RδR_{\delta} is again a 2×22\times 2 rotation matrix. By design, we have ci=ci′c_{i}=c^{\prime}_{i} for i>2i>2. This, along with the fact that UU can be set to Ik\mathcal{I}_{k} (isometry does not influence either side of (55)), allows for a full reduction to the discussed two-dimensional case. ∎

It is easy to see that the performed perturbations continuously translate into perturbations of the parameters σj2(xi)\sigma^{2}_{j}(\mathbf{x}^{i}) and ViV_{i} in estimates (49) and (51). Consequently, any non-optimal values of σj2(xi)\sigma^{2}_{j}(\mathbf{x}^{i}) and ViV_{i} can be locally improved. This concludes the proof.

A.2 Rotational invariances

Let us start by fleshing out the common elements of the proofs of Propositions 2 and 3. In both cases, the encoder and decoder mappings Encφ⁡,U\operatorname{Enc_{\varphi}}_{,U}, Decθ⁡,U\operatorname{Dec_{\theta}}_{,U} induce joint distributions pU(x,z)p_{U}(\mathbf{x},\mathbf{z}), qU(x,z)q_{U}(\mathbf{x},\mathbf{z}) described as

For every xi∈X\mathbf{x}^{i}\in X we have p(xi)=pU(xi)p(\mathbf{x}^{i})=p_{U}(\mathbf{x}^{i}).

where in the third equality we used the Change of Variable Theorem to substitute UzU\mathbf{z} for z\mathbf{z} (keep in mind that ∣det⁡(U)∣=1|\det(U)|=1 as UU is an orthogonal matrix). In the fourth equality, we used the rotational symmetry of the prior p(z)p(\mathbf{z}). ∎

Proof of Proposition 2. This immediately follows from Lemma 6. ∎

Proof of Proposition 3. We utilize the full identity from ELBO derivation. For fixed xi∈X\mathbf{x}^{i}\in X we have

In order to prove invariance of ELBO to the choice of UU, it suffices to prove invariance of the right-hand side of (60). Due to Proposition (3) we only need to focus on the KL term. Similarly as in the proof of Lemma 6, we calculate

where we again used the Change of Variable Theorem in equality (4), rotational symmetry of p(z)p(\mathbf{z}) in equality (5), and Lemma 6 in equality (3). ∎

A.3 Other proofs

Proof of Proposition 1. Recall from Lemma 3 that column orthogonality of MM is equivalent to M⊤MM^{\top}M being a diagonal matrix.

(b) ⇒\Rightarrow (a): Let M=UΣV⊤M=U\Sigma V^{\top} where ∣V∣|V| is a permutation matrix. Then

where Σ′=Σ⊤Σ\Sigma^{\prime}=\Sigma^{\top}\Sigma is a diagonal matrix. But then VΣ′V⊤V\Sigma^{\prime}V^{\top} only permutes the diagonal entries of Σ′\Sigma^{\prime} (and possibly flips their signs). In particular, VΣ′V⊤V\Sigma^{\prime}V^{\top} is also diagonal.

(a) ⇒\Rightarrow (b): Let again M=UΣV⊤M=U\Sigma V^{\top} be some SVD of MM and assume M⊤M=DM^{\top}M=D for some diagonal matrix DD. Since MM has dd distinct nonzero singular values, M⊤MM^{\top}M has dd distinct nonzero eigenvalues (diagonal elements). Moreover, these eigenvalues are precisely the squares of the singular values captured by Σ\Sigma. Next, if we denote by PP the permutation matrix for which PDP−1PDP^{-1} has decreasing diagonal elements, we can write

Then using (62) and the SVD of MM similarly as in (61), we obtain

Further, the resulting identity (VP)D=D(VP)(VP)D=D(VP) implies that columns of VPVP are eigenvectors of DD, i.e. the canonical basis vectors. Since VPVP is additionally orthogonal, these eigenvectors are normalized. It follows that ∣VP∣|VP| is a permutation matrix and the conclusion follows.

The identity we obtain, is exactly what was required to prove. ∎

Appendix B Experimental details

As introduced in the paper, for disentangled representations, single latent variables should be sensitive to individual generating factors and insensitive to all others. To quantify this behavior, for each generating factor wiw_{i}, all latent variables are evaluated for their sensitivity to wiw_{i}. The sensitivity difference between the two most responsive variables then reflects both desired properties; the sensitivity of the associated best matching latent variable and also the insensitivity of all others. A set of quantities capturing disentanglement can therefore be described as

where Ai,jA_{i,j} is some sort of sensitivity measure of latent variable zjz_{j} with respect to the generating factor wiw_{i} and MiM_{i} is a normalization constant, ensuring the summands fall into the interval (0,1)(0,1).

The recently proposed Mutual Information Gap (MIG) uses the Mutual Information as a measure of how the latent variables depend on the generating factors. For the normalisation, the entropy of the generating factor is used.

For discrete generating factors {wi}\{w_{i}\}, the normalization with the entropy H(wi)H(w_{i}), binds the MIG to the (0,1)(0,1) interval, as expected. For continuous generating factors on the other side, this does not hold. In fact, differential entropy can be zero or even negative and no good normalization is possible.

To treat this shortcoming, we introduce the slightly modified Disentanglement score such that it comprises continuous and discrete variables alike. Rather than using mutual information measurements, we employ powerful nonlinear regressors and classifiers for the two different classes of latent variables. The predictability of a generating factor from a given latent coordinate indirectly reflects how much information the two share.

Accordingly, we define the Disentanglement score as in Equation 65 by defining Ai,jA_{i,j} as the prediction performance of the regressor/classifier for predicting generating factor wiw_{i} from the latent coordinate zjz_{j}. The normalization factor is then the performance of the best constant classifier/regressor. In case of regression with mean square error, this is simply the standard deviation of the generative factor.

We used the SciPy implementation of a kk-nearest-neighbors classifier and regressor with default settings (e.g. k=5k=5) to measure the Disentanglement Score. The regressor/classifier was trained on 80% of the test data and evaluated on the remaining 20%.

B.2 DtO via Integer Programming

The Distance to Orthogonality (DtO) describes the Frobenius norm of the difference between a matrix VV and its closest signed permutation matrix P(V)P(V). Using mixed-integer linear programming (MILP) formulation, we find the closest permutation matrix as the optimum P∗P^{*} of the following optimization problem

Producing a clean MILP formulation, with purely linear objective and binary integer values, can be achieved with a standard technique; introducing new variables. In particular, we set

and introduce (continuous) variables for the differences Vi,j−Pi,jV_{i,j}-P_{i,j}

B.3 β𝛽\beta-VAE with Full Covariance Matrix

In the derivation of the VAE loss function, the approximate posterior is set to be a multivariate normal distribution with a diagonal covariance matrix. The claim of the paper is that this diagonalization is responsible for the orthogonalization. As one of the control experiments in Section 5 we also implemented VAE with a full covariance matrix.

Two issues now need to be addressed; computing KL divergence in closed form and adapting the reparametrization trick. Regarding the former, the sought identity is

As for the reparametrization trick, if ε∼N(0,Ik)\varepsilon\sim\mathcal{N}(0,\mathcal{I}_{k}), it is easy to check that

where Σ=Σ1/2⋅(Σ1/2)⊤\Sigma=\Sigma^{1/2}\cdot\left(\Sigma^{1/2}\right)^{\top} is the unique Cholesky decomposition of the positive definite matrix Σ\Sigma.

B.4 Network Details and Training

Table 3 contains the training parameters used for the different architectures. The listed latent dimension is chosen to be the number of independent generating factors, if applicable, and chosen large enough to ensure decent reconstruction loss on all architectures.

All reported numbers are calculated using a previously unseen test dataset. To facilitate this, we split the whole datasets randomly into three parts for training, evaluation and test (containing 80 %80\,\%, 10 %10\,\% and 10 %10\,\% of all samples respectively). During development, we use the evaluation dataset, for the final reports we use the test dataset.

B.5 Synthetic Datasets

stretching along one axis by a fixed factor of 2,

rotation of 45∘45^{\circ} along the line containing the vector (1,−1,1)\left(1,-1,1\right).

Both datasets consist of 5000050000 samples.

Appendix C Additional Experiments

The choice of β\beta depends on the achievable Disentanglement Score. Figure 5 shows a more thorough analysis of the dependence of both the Disentanglement Score and the DtO. For too small values of β\beta, the effect of the KL term (and thus the orthogonalization) is negligible. In the other extreme case, too large values values of β\beta result in overpruning, such that the number of active latent coordinates drops below the number of generating factors.

C.2 Degenerate case

Proposition 1 insists that the locally linearized decoder have distinct singular values, otherwise orthogonality of the column vectors does not translate into preserving axes. Here, we design an experiment showing, that this condition is also relevant in practice.

The dataset in question will be a version of the linear synthetic task where the generating factors have the same scaling, as visualized in the upper plot of Figure 6. Note that any linear encoder applying a simple rotation has both orthogonal columns and equal singular values. But it does not respect the alignment of the original square, as it does not meet the assumptions of Proposition 1.

Behavior of the β\beta-VAE with a linear encoder/decoder network is consistent with this. The bottom part of Figure 6 shows β\beta-VAE latent representations of four random restarts; they expose random alignments. The same effect results in high variances for both the Disentanglement Score and the DtO, as shown in Table 4.

This degeneracy also occurs for PCA. It is easy to check that any projection of a unit square on a line has equal variance. Hence the greedy PCA algorithm has no preference over which alignment to choose, and the practical choice of alignment is implementation dependent.

This insight reinforces our point that β\beta-VAE (just like PCA) looks for sources of variance rather than for statistical independence.

We can also see in Table 4, that the degeneracy disappears even for small rescaling of the ground truth factors. Since β\beta-VAE promotes normalized latent representations (zero mean, unit variance), the singular values will no longer be equal and the right alignment is found. The same is true for PCA.

C.3 Non-Linear VAE Eigenfaces

In order to highlight the connection with PCA, we use β\beta-VAE to produce a non-linear version of the classical eigenfaces on the CelebA dataset . Fig 7 shows a discrete latent traversal.

We can see that unlike classical eigenfaces that mostly reflect photometric properties, the ‘nonlinear eigenfaces” capture also semantic features of the data. Note also that the ordering of the ‘principal components’ by the mean values of σj\sigma_{j} is naturally justified by our work. As was illustrated in Sec. 4.2 of the paper, the first β\beta-VAE ‘principle components’ also focus on characteristics with high impact on the reconstruction loss (i.e. capture the most variance),

Details about the architecture used are listed in Tab. 3.

References