L ATENT S PACE O DDITY : ON THE C URVATURE OF D EEP G ENERATIVE M ODELS
Anonymous authors
Paper under double-blind review
A BSTRACT
Deep generative models provide a systematic way to learn nonlinear data distributions, through a set of latent variables and a nonlinear “generator” function that maps latent points into the input space.
The nonlinearity of the generator imply that the latent space gives a distorted view of the input space.
Under mild conditions, we show that this distortion can be characterized by a stochastic Riemannian metric, and demonstrate that distances and interpolants are signiﬁcantly improved under this metric.
This in turn improves probability distributions, sampling algorithms and clustering in the latent space.
Our geometric analysis further reveals that current generators provide poor variance estimates and we propose a new generator architecture with vastly improved variance estimates.
Results are demonstrated on convolutional and fully connected variational autoencoders, but the formalism easily generalize to other deep generative models.
I NTRODUCTION
Deep generative models (Goodfellow et al., 2014; Kingma & Welling, 2014; Rezende et al., 2014) model the data distribution of observations x ∈ X through corresponding latent variables z ∈ Z and a stochastic generator function f : Z → X as x = f ( z ) .
Using reasonably low-dimensional latent variables and highly ﬂexible generator functions allows these models to efﬁciently represent a useful distribution over the underlying data manifold.
These approaches have recently attracted a lot of attention as deep neural networks are suitable generators, which leads to the impressive performance of current variational autoencoders (VAEs) (Kingma &
Welling, 2014) and generative adversarial networks (GANs) (Goodfellow et al., 2014).
Consider the left panel of Fig. 1, which shows the latent representations of digits 0 and 1 from
MNIST under a VAE.
Three latent points are highlighted: one point ( A ) far away from the class boundary, and two points ( B , C ) near the boundary, but on opposite sides.
Seemingly the points B and C near the boundary are very close to each other, while the third is far away from the others.
Intuitively, we would hope that points from the same class ( A and B ) are closer to each other than to members of other classes ( C ), but this is seemingly not the case.
In this paper we argue this seeming conclusion is incorrect and only due to a misinterpretation of the latent space — in fact points A and
B are closer to each other than to C in the latent representation .
Correcting this misinterpretation not only improves our understanding of generative models, but also improves interpolations, clusterings, latent probability distributions, sampling algorithms, interpretability and more.
In general, latent space distances lack physical units (making them difﬁcult to interpret) and are sensitive to speciﬁcs of the underlying neural nets.
It is therefore more robust to consider inﬁnitesimal distances along the data manifold in the input space.
Let z be a latent point and let ∆ z 1 and ∆ z 2 be inﬁnitesimals, then we can compute the squared distance
[Equation]
using Taylor’s Theorem.
This imply that the natural distance function in Z changes locally as it is governed by the local Jacobian.
Mathematically, the latent space should then not be seen as a linear Euclidean space, but rather as a curved space.
The right panel of Fig.
1 provides an example of the implications of this curvature.
The ﬁgure shows synthetic data from two classes, and the corresponding latent representation of the data.
The background color of the latent space corresponds to (cid:112) det( J (cid:124)
z J z ) , which can be seen as a measure of the local distortion of the latent space.
We interpolate two points from the same class by walking along the connecting straight line (red); in the right panel, we show points along this straight line, which have been mapped by the generator to the input space.
Since the generator deﬁnes a surface in the input space, we can alternatively seek the shortest curve along this surface that connects the two points; this is perhaps the most natural choice of interpolant.
We show this shortest curve in green.
From the center panel it is evident that the natural interpolant is rather different from the straight line.
This is due to the distortion of the latent space, which is the topic of the present paper.
Outline.
In Sec.
2 we brieﬂy present the VAE as a representative instance of generative models.
In Sec.
3 we connect generative models with their underlying geometry, and in Sec.
4 we argue that a stochastic Riemannian metric is naturally induced in the latent space by the generator.
This metric enable us to compute length minimizing curves and corresponding distances.
This analysis, however, reveals that the traditional variance approximations in VAEs are rather poor and misleading; we propose a solution in Sec. 4.1.
In Sec.
5 we demonstrate how the resulting view of the latent space improves latent interpolations, gives rise to more meaningful latent distributions, clusterings and more.
We discuss related work in Sec. 6 and conclude the paper with an outlook in Sec. 7.
T HE V ARIATIONAL A UTOENCODERS ACTING AS THE G ENERATOR
The variational autoencoder (VAE) proposed by Kingma & Welling (2014) is a simple yet powerful generative model, which consist of two parts: (1) an inference network or recognition network ( encoder ) learns the latent representation (codes) of the data in the input space X
= R D ; and (2) the generator ( decoder ) learns how to reconstruct the data from these latent space codes in Z = R d .
Formally, a prior distribution is deﬁned for the latent representations p ( z ) =
N ( 0 , I d ) , and there exist a mapping function µ θ : Z → X that generates a surface in X .
Moreover, we assume that another function σ θ : Z → R D + captures the error (or uncertainty ) between the actual data observation x ∈ X and its reconstruction as x = µ θ ( z ) + σ θ (cid:12) (cid:15) , where (cid:15) ∼ N ( 0 , I D ) and (cid:12) is the Hadamard (element-wise) product.
Then the likelihood is naturally deﬁned as p θ ( x | z ) =
N ( x | µ θ ( z ) , I D σ 2 θ ( z )) .
The ﬂexible functions µ θ and σ θ are usually deep neural networks with parameters θ .
However, the corresponding posterior distribution p θ ( z | x ) is unknown, as the marginal likelihood p ( x ) is intractable.
Hence, the posterior is approximated using a variational distribution q φ ( z | x ) =
N ( z | µ φ ( x ) , I d σ 2 φ ( x )) , where the functions µ φ : X → Z and σ φ : X → R d + are again deep neural networks with parameters φ .
Since the generator (decoder) is a composition of linear maps and activation functions, its smoothness is based solely on the chosen activation functions.
The optimal parameters θ and φ are found by maximizing the evidence lower bound (ELBO) of the marginal likelihood p ( x ) as
[Equation]
where the bound follows from Jensen’s inequality.
The optimization is based on variations of gradient descent using the reparametrization trick (Kingma & Welling, 2014; Rezende et al., 2014).
Further improvements have been proposed that provide more ﬂexible posterior approximations (Rezende & Mohamed, 2015; Kingma et al., 2016) or tighter lower bound (Burda et al., 2016).
In this paper we consider the standard VAE for simplicity.
The optimization problem in Eq.
3 is difﬁcult since poor reconstructions by µ θ can be explained by increasing the corresponding variance σ 2 θ .
A common trick, which we also follow, is to optimize µ θ while keeping σ 2 θ constant, and then ﬁnally optimize for the variance σ 2 θ .
S URFACES AS THE F OUNDATION OF G ENERATIVE M ODELS
Mathematically, a deterministic generative model x = f ( z ) can be seen as a surface model (Gauss, 1827) if the generator f is sufﬁciently smooth.
Here, we brieﬂy review the basic concepts on surfaces as they form the mathematical foundation of this work.
Intuitively, a surface is a smoothly-connected set of points embedded in X .
When we want to make computations on a surface it is often convenient to parametrize the surface by a low-dimensional (latent) variable z along with an appropriate function f : Z → X .
We let d = dim( Z ) denote the intrinsic dimensionality of the surface, while
D = dim( X ) is the dimensionality of the input space.
If we consider a smooth (latent) curve γ t : [0 , 1]
→ Z , then it has length (cid:82) 1 0 (cid:107) ˙
γ t (cid:107) d t , where ˙ γ t =
d γ t / d t denote the velocity of the curve.
In practice, the low-dimensional parametrization Z often lack a principled meaningful metric, so we measure lengths in input space by mapping the curve through f ,
[Equation]
where the last step follows from Taylor’s Theorem.
This imply that the length of a curve γ t along the surface can be computed directly in the latent space using the (locally deﬁned) norm
[Equation]
Here, M γ = J (cid:124)
γ J γ is a symmetric positive deﬁnite matrix, which acts akin to a local Mahalanobis distance measure.
This gives rise to the deﬁnition of a Riemannian metric , which represents a smoothly changing inner product structure.
Deﬁnition 1.
A Riemannian metric M : Z → R d × d is a smooth function that assigns a symmetric positive deﬁnite matrix to any point in Z .
It should be clear that if the generator function f is sufﬁciently smooth, then M γ in Eq.
5 is a
Riemannian metric.
When deﬁning distances across a given surface, then it is meaningful to seek the shortest curve connecting two points.
Then a distance can be deﬁned as the length of this curve.
The shortest curve connecting points z 0 and z 1 is by (trivial) deﬁnition
[Equation]
A classic result of differential geometry (do Carmo, 1992) is that solutions to this optimization problem satisfy the following system of ordinary differential equations (ODEs)
[Equation]
where vec [ · ] stacks the columns of a matrix into a vector and ⊗ is the Kronecker product.
For completeness, we provide a derivation of this result in Appendix A. Shortest curves can then be computed by solving the ODEs numerically; our implementation use bvp5c from Matlab.
T HE G EOMETRY OF S TOCHASTIC G ENERATORS
In the previous section we considered deterministic generators f to provide relevant background information.
We now extend these results to the stochastic case; in particular we consider
[Equation]
This is the generator driving VAEs and related models.
For our purposes, we will call µ ( · ) the mean function and σ 2 ( · ) the variance function .
Following the discussion from the previous section, it is natural to consider the Riemannian metric
M z
=
J (cid:124)
z J z in the latent space.
Since the generator is now stochastic, this metric also becomes stochastic, which complicate analysis.
The following results, however, simplify matters.
Theorem 1.
If the stochastic generator in Eq.
8 has mean and variance functions that are at least twice differentiable, then the expected metric equals
[Equation]
where J ( µ ) z and J ( σ ) z are the Jacobian matrices of µ ( · ) and σ ( · ) .
Proof.
See Appendix B.
Remark 1.
By Deﬁnition 1, the metric tensor must change smoothly, which implies that the Jacobians must be smooth functions as well.
This is easily ensured with activations functions for the neural networks that are C 2 differentiable, e.g. tanh( · ), sigmoid( · ) , and softplus( · ) .
Theorem 2 (Due to Tosi et al.
The variance of the metric under the L 2 measure vanishes when the data dimension goes to inﬁnity, i.e. lim D →∞ Var ( M z ) = 0 .
Theorem 2 suggest that the (deterministic) expected metric M z is a good approximation to the underlying stochastic metric when data dimension is large.
We make this approximation, which allows us to apply the theory of deterministic generators.
This expected metric has a particular appealing form, where the two terms capture the distortion of the mean and the variance functions respectively.
In particular, the variance term ( J ( σ ) z ) (cid:124)
( J ( σ ) z ) will be large in regions of the latent space, where the generator has large variance.
This imply that induced distances will be large in regions of the latent space where the generator is highly uncertain, such that shortest paths will tend to avoid these regions.
These paths will then tend to follow the data in the latent space, c.f. Fig.
It is worth stressing, that no learning is needed to compute this metric: it only consist of terms that can be derived directly from the generator.
4. E NSURING P ROPER G EOMETRY T HROUGH M EANINGFUL V ARIANCE F UNCTIONS
Theorem 1 informs us on how the geometry of the generative model depends on both the mean and the variance of the generator.
Assuming successful training of the generator, we can expect to have good estimates of the geometry in regions near the data.
But what happens in regions further away from the data?
In general, the mean function cannot be expected to give useful extrapolations to such regions, so it is reasonable to require that the generator has high variance in regions that are not near the data.
In practice, the neural net used to represent the variance function is only trained in regions where data is available, which implies that variance estimates are extrapolated to regions with no data.
As neural nets tend to extrapolate poorly, practical variance estimates tend to be arbitrarily poor in regions without data .
Figure 4 illustrate this problem.
The ﬁrst two panels show the data and its corresponding latent representations (here both input and latent dimensions are 2 to ease illustration).
The third panel
Inputspace1 -   data
Latentspace −   −   latent repr.
Standardvarianceestimate −   −   − − − −
Proposedvarianceestimate −   −       show the variance function under a standard architecture, deep multilayer perceptron with softplus nonlinearity for the output layer.
It is evident that variance estimates in regions without data is not representative of neither uncertainty or error of the generative process; sometimes variance is high, sometimes it is low.
From a probabilistic modeling point-of-view this is disheartening.
An informal survey of publicly available VAE implementations also reveal that it is common to enforce a constant unit variance everywhere; this is further disheartening.
For our purposes we need well-behaved variance functions to ensure a well-behaved geometry, but reasonable variance estimates are of general use.
Here we propose, as a general strategy, to model the inverse variance with a network that extrapolates towards zero.
This at least ensures that variances are large in regions without data.
Speciﬁcally, we model the precision as β ψ ( z ) =
1 σ 2 ψ ( z ) , where all operations are element-wise.
Then, we model this precision with a radial basis function (RBF) neural network (Que & Belkin, 2016).
Formally this is written
[Equation]
where ψ are all parameters,
W ∈ R D × K >are the positive weights of the network (positivity ensures a positive precision), c k and λ k are the centers and the bandwidth of the K radial basis functions, and ζ → 0 is a vector of positive constants to prevent division by zero.
It is easy to see that with this approach the variance of the generator increases with the distance to the centers.
The rightmost panel of Fig.
4 shows an estimated variance function, which indeed has the desired property that variance is large outside the data support.
Further note the increased variance between the two clusters, which captures that even interpolating between clusters comes with a level of uncertainty.
[Figure]
Training the variance network amounts to ﬁtting the RBF network.
Assuming we have already trained the inference network (Sec. 2), we can encode the training data, and use k -means to estimate the
RBF centers.
Then, an estimate for the bandwidths of each kernel can be computed as
[Equation]
where the hyper-parameters a ∈ R + controls the curvature of the
Riemannian metric, i.e. how fast it changes based on the uncertainty.
Since the mean function of the generator is already trained, the weights of the RBF can be found using projected gradient descent to ensure positive weights.
One visualization of the distortion of the latent space relative to the input space is the geometric volume measure (cid:112) det( M z ) , which capture the volume of an inﬁnitesimal area in the input space.
Figure 5 show this volume measure for both standard variance functions as well as our proposed RBF model.
We see that the proposed model captures the trend of the data unlike the standard model.
E MPIRICAL R ESULTS
We demonstrate the usefulness of the geometric view of the latent space with several experiments.
Model and implementation details can be found in Appendix C.
In all experiments we ﬁrst train a
VAE
and then use the induced Riemannian metric.
5. M EANINGFUL D ISTANCES
[Table]
First we seek to quantify if the induced Riemannian distance in the latent space is more useful than the usual Euclidean distance
For this we perform basic k -means clustering under the two metrics.
We constructsets of MNIST digits, using 1000 random samples for each digit.
We train a VAE for each set, and then subdivide each into 10 sub-sets, and performed k -means clustering under both distances.
One example result is shown in Fig.
Here it is evident that since the latent points roughly follow a unit Gaussian, there is little structure to be discovered by the Euclidean k -means, and consequently it performs poorly.
The Riemannian clustering is remarkably accurate.
Summary statistics across all subsets is provided in Table 1, which show the established F -measure for clustering accuracy.
Again, the Riemannian metric signiﬁcantly improves clustering.
This implies that the underlying Riemannian distance is more useful than its Euclidean counterpart.
5. I NTERPOLATIONS
Next we investigate if the Riemannian metric gives more meaningful interpolations.
First, we train a VAE for the digits 0 and 1 from MNIST.
The upper left panel of Fig.
7 shows the latent space with the Riemannian measure as background color, together with two interpolations.
Images generated by both Riemannian and Euclidean interpolations are shown in the bottom of Fig.
The Euclidean interpolations seem to have a very abrupt change when transitioning from one class to another.
The
Riemannian interpolant gives smoother changes in the generated images.
The top-right panel of the ﬁgure shows the auto-correlation of images along the interpolants; again we see a very abrupt change in the Euclidean interpolant, while the Riemannian is signiﬁcantly smoother.
We also train a convolutional VAE on frames from a video.
Figure 8 shows the corresponding latent space and some sample interpolations.
As before, we see more smooth changes in generated images when we take the Riemannian metric into account.
5. L ATENT P ROBABILITY D ISTRIBUTIONS
We have seen strong indications that the Riemannian metric gives a more meaningful view of the latent space, which may also improve probability distributions in the latent space.
A relevant candidate distribution is the locally adaptive normal distribution (LAND) (Arvanitidis et al., 2016)
[Equation]
−  −  where dist Σ is the Riemannian extension of Mahalanobis distance.
We ﬁt a mixture of two LANDs to the MNIST data from Sec.
5.2 alongside a mixture of Euclidean normal distributions.
The ﬁrst column of Fig.
9 shows the density functions of the two mixture models.
Only the Riemannian model reveals the underlying clusters.
We then sample 40 points from each component of these generative models 1 (center column of the ﬁgure).
We see that the Riemannian model generates high quality samples, whereas the Euclidean model generates several samples in regions where the generator is not trained and therefore produce blurry images.
Finally, the right column of Fig.
9 shows all pairwise distances between the latent points under both Riemannian and Euclidean distances.
Again, we see that the geometric view clearly reveals the underlying clusters.
5. R ANDOM W ALK ON THE D ATA M ANIFOLD
Finally, we consider random walks over the data manifold, which is a common tool for exploring latent spaces.
To avoid the walk drifting outside the data support, practical implementations artiﬁcially [Figure] restrict the walk to stay inside the [ − 1 , 1] d hypercube.
Here we consider unrestricted Brownian motion under both the Euclidean and Riemannian metric.
We perform this random walk in the latent space of the convolutional VAE from Sec. 5.2.
Figure 10 shows example walks, while Fig.
11 shows generated images (video here).
While the Euclidean random walk moves freely, the Riemannian walk stays within the support of the data.
This is explained in the left panel of Fig.
10, which shows that the variance term in the Riemannian metric creates a “wall” around the data which the random walk will only rarely cross.
These “walls” also force shortest paths to follow the data.
R ELATED W ORK
Generative models.
This unsupervised learning category attracted a lot of attention, especially, due to the advances on the deep neural networks.
We have considered VAEs (Kingma & Welling, 2014; Rezende et al., 2014), but the ideas extend to similar related models.
This include extensions that provide more ﬂexible approximate posteriors (Rezende & Mohamed, 2015; Kingma et al., 2016).
GANs (Goodfellow et al., 2014) also fall in this category as these models have an explicit generator.
While the inference network is not a necessary component in the GAN model, it has been shown that incorporating them improves overall performance (Donahue et al., 2017; Dumoulin et al., 2017).
Likewise, approaches that are based on the transformation of the latent space through sequence of bijective functions (Dinh et al., 2017).
Geometry in neural networks.
Bengio et al.
(2013) discuss the importance of geometry in neural networks as a tool to understand local generalization.
For instance, the Jacobian matrix is a measure of smoothness for a function that interpolates a surface to the given data.
This is exactly the implication in (Rifai et al., 2011) where the norm of the Jacobian acts as a regularizer for the deterministic autoencoder.
Recently Kumar et al.
(2017) used the Jacobian to inject invariances in a classiﬁer.
Riemannian Geometry.
Similarly with the present paper, Tosi et al.
(2014) derive a suitable Riemannian metric in Gaussian process (GP) latent variable models (Lawrence, 2005), but the computational complexity of GPs cause practical concerns.
Unlike works that explicitly learn a Riemannian metric (Hauberg et al., 2012; Peltonen et al., 2004), our metric is fully derived from the generator and requires no extra learning once the generator is available.
D ISCUSSION AND F URTHER E XTENSIONS
The geometric interpretation of representation learning is that the latent space is a compressed and ﬂattened version of the data manifold.
We show that the actual geometry of the data manifold can be more complex than it ﬁrst appears.
Here we have initiated the study of proper geometries for generative models.
We showed that the latent space not only provides a low-dimensional representation of the data manifold, but at the same time, can reveal the underlying geometrical structure.
We proposed a new variance network for the generator, which provides meaningful uncertainty estimates while regularizing the geometry.
The new detailed understanding of the geometry provide us with more relevant distance measures, as demonstrated by the fact that a k -means clustering, on these distances, is better aligned with the ground truth label structure than a clustering based on conventional Euclidean distances.
We also found that the new distance measure produces smoother interpolation and when training Riemannian “LAND” mixture models based on the new geometry, the components aligned much better with the ground truth group structure.
Finally, inspired by the recent interest in sequence generation by random walks in latent space, we found that geometrically informed random walks stayed on the manifold for much longer runs than sequences based on Euclidean random walks.
The presented analysis easily extend to sophisticated generative models, where the latent space will be potentially endowed with more ﬂexible nonlinear structures.
This directly implies particularly interesting geometrical models.
An obvious question is, if the geometry of the latent space can play a role while we learn the generative model?
Either way, we believe that this geometric perspective provides a new way of thinking and further interpreting the generative models, while at the same time is appealing for developing new nonlinear models in the representation space.
A T HE D ERIVATION OF THE G EODESIC D IFFERENTIAL E QUATION
The shortest path between two points x , y ∈ M on a Riemannian manifold M is found by optimizing the functional
[Equation]
where γ t : [
[Equation]
1] → M and ˙ γ t = ∂ γ t ∂t .
The minima of this problem can be found instead by optimizing the curve energy (do Carmo, 1992)
[Equation]
so the functional becomes
[Equation]
The inner product can be written explicitly as
[Equation]
where the index in the parenthesis represents the corresponding element in the vector or matrix.
In the derivation the ⊗ is the usual Kronocker product and the vec [ · ] stacks the column of a matrix into a vector.
We ﬁnd the minimizers by the Euler-Lagrange equation
[Equation] [Equation]
where
[Equation]
= ∂ ∂t (cid:0) 2 · M γ t ˙ γ t (cid:1) =(cid:20) ∂
M γ t ∂t ˙
γ t + M γ t ¨ γ t (cid:21) .
Since the term ∂ M γ t ∂t =   ∂M (11) γ t ∂t · · · ∂M (1 D )
γ t ∂t ∂M (21) γ t ∂t · · · ∂M (2 D ) γ t ∂t ...
∂M ( D 1) γ ∂t · · · ∂M ( DD ) γ t ∂t 
 =   ∂M (11) γ t ∂ γ t (cid:124) ˙
γ t · · · ∂M (1 D ) γ t ∂ γ t (cid:124) ˙
γ t ∂M (21) γ t ∂ γ t (cid:124) ˙
γ t · · · ∂M (2 D ) γ ∂ γ t (cid:124) ˙
γ t ...
∂M ( D 1) γ t ∂ γ t (cid:124) ˙
γ t · · · ∂M ( DD ) γ t ∂ γ t
(cid:124) ˙
γ t   (18) we can write the right hand side of the Eq.
16 as
[Equation]
The left hand side term of the Eq.
16 is equal to ∂L
[Equation]
The ﬁnal system of 2 nd order ordinary differential equations is
[Equation]
B T HE D ERIVATION OF THE R IEMANNIAN M ETRIC
The proof of Theorem 1.
Proof.
As we introduced in Eq.
the stochastic generator is
[Equation]
Thus
[Equation]
we can compute the corresponding Jacobian as follows
[Equation]
where S i =
[Equation]

[Equation]
(25) and the resulting “random” metric in the latent space is M z =
J (cid:124)
z J z .
The randomness is due to the random variable (cid:15) , and thus, we can compute the expectation
[Equation]
Using the linearity of expectation we get that
[Equation] [Equation]
(27) because E p ( (cid:15) )
[ (cid:15) ]
= 0 .
The other term
[Equation]
 
[Equation]

[Equation]
D
[Equation]
(cid:15)
[Equation]
]   (28)
[Equation]
    (cid:15) (cid:124) S 1 S 1 (cid:15) (cid:15) (cid:124) S 1 S 2 (cid:15) · · · (cid:15) (cid:124) S 1 S d (cid:15) (cid:15) (cid:124) S 2 S 1 (cid:15) (cid:15) (cid:
) S 2 S 2 (cid:15) · · · (cid:15) (cid:
) S 2 S d (cid:15) ...
(cid:15) (cid:124) S d S 1 (cid:15) (cid:15) (cid:124) S d S 2 (cid:15) · · · (cid:15) (cid:124)
S
d S d (cid:15) 
   (29) with E p ( (cid:15) )
[ (cid:15) (cid:124) S i S
j (cid:15) ] =
E p ( (cid:15) )  (cid:32) (cid:15) 1 ∂σ (1) z ∂z i , (cid:15)∂σ (2) z
∂z i , · · · , (cid:15) D ∂σ ( D ) z
∂z i (cid:33)   (cid:15) 1 ∂σ (1) z
∂z j (cid:15) 2 ∂σ (2) z
∂z j ...
(cid:15) D ∂σ ( D ) z
∂z j   
 (30) =
E p ( (cid:15) ) (cid:34) (cid:15)(cid:32) ∂σ (1) z ∂z i ∂σ (1) z ∂z j (cid:33) + (cid:15)(cid:32) ∂σ (2)
z
∂z i ∂σ (2) z
∂z j (cid:33) + · · · (cid:15) 2 D
[Equation]
because E p ( (cid:15) )
[ (cid:15) 2 i ] = 1 , ∀ i = 1 , . . .
, D .
The matrix A =
J ( µ ) z and for the variance network
[Equation]
33) it is easy to see that E p ( (cid:15) )
[ B (cid:124) B ] = (cid:16)
J ( σ ) z (cid:17) (cid:124) J ( σ ) z .
So the expectation of the induced Riemannian metric in the latent space by the generator is
[Equation]
) which concludes the proof.
C I MPLEMENTATION D ETAILS FOR THE E XPERIMENTS
Algorithm
The training of a VAE that ensures geometry
Output: the estimated parameters of the neural networks θ, φ, ψ 1: Train the µ φ , σ φ , µ θ as in Kingma & Welling (2014), keeping σ ψ ﬁxed.
2: Train the σ ψ as explained in Sec. 4.1.
Details for Experiments 5.1, 5.2 & 5.3.
The pixels values of the images are scaled to the interval [0 , 1] .
We use for the functions µ φ , σ φ , µ θ multilayer perceptron (MLP) deep neural networks, and for the β ψ the proposed RBF model with 64 centers, so W ∈ R D × 64 and the parameter a of Eq.is set to 2.
We used L 2 regularization with parameter equal to 1 e − 5 .
Encoder/Decoder
Layer
Layer Layer
[Equation]
The number corresponds to the size of the layer, and in the parenthesis the activation function.
For the encoder the mean and the variance functions share the weights of the Layer 1.
The input space dimension D = 784 .
After the training, the geodesics can be computed by solving Eq.numerically.
The LAND mixture model is ﬁtted as explained in (Arvanitidis et al., 2016).
Details for Experiments 5.4.
In this experiment we used Convolutional Variational AutoEncoders.
The pixel values of the images are scaled to the interval [0 , 1] .
For the β ψ we used the proposed RBF model with 64 centers and the parameter a of Eq.
11 is set to 2.
Considering the variance network during the decoding stage, the RBF generates an image, which represents intuitively the total variance of each pixel for the decoded ﬁnal image, but in an initial sub-sampled version.
Afterwards this image is passed through a sequence of deconvolution layers, and at the end will represent the variance of every pixel for each RGB channel.
However, it is critical that the weights of the ﬁlters must be clipped during the training to R + to ensure positive variance.
Encoder
Layer 1 (Conv)
Layer 2 (Conv)
Layer 3 (MLP)
Layer 4 (MLP) µ φ 32, 3, 2, ( tanh ) 32, 3, 2, ( tanh ) 1024, ( tanh ) d , ( linear ) σ φ 32, 3, 2, ( tanh ) 32, 3, 2, ( tanh ) 1024, ( tanh ) d , ( softplus )
For the convolutional and deconvolutional layers the ﬁrst number is the number of applied ﬁlters, the second is the kernel size, and third is the stride.
Also, for the encoder the mean and the variance functions share the convolutional layers.
We used L 2 regularization with parameter equal to 1 e − 5 .
Decoder
L. 1 (MLP)
L. 2 (MLP)
L. 3 (DE)
L. 4 (DE)
L. 5 (DE)
L.6 (CO) µ θ 1024, ( t )
D/ 4 , ( t ) 32, 3, 2, ( t ) 32, 3, 2, ( t ) 3, 3, 1, ( t ) 3, 3, 1, ( s )
For the decoder, the acronyms (DE) =
Deconvolution, (CO) =
Convolution and ( t ) , ( s ) stands for tanh and sigmoid , respectively.
Also, D = width × height × channels of the images, in our case 64,64,3.
For all the convolutions and deconvolutions the padding is set to same .
We used Lregularization with parameter equal to 1 e − 5 .
Decoder
Layer 1 (RBF)
Layer 2 (Deconv)
Layer 3 (Conv) β
ψ
W ∈ R ( D/ 2) ×1, 3, 2 ( linear ) 3, 3, 1 ( linear )
The Brownian motion over the Riemannian manifold in the latent space is presented in Alg. 2.
Algorithm
Input: the starting point
∈ R d
N metric tensor M ( · ) .
Output: random
Z ∈ R N s × d .
1: for n = 0 to N s do 2:
L , U = eig
( M ( z )) , ( L : eigenvalues, U : eigenvectors) 3: v = UL − 12 (cid:15) , (cid:15) ∼ N ( 0 , I d ) 4:
z = z + s · v 5:
Z ( n, :) =
z 6: end for