Adrià Ruiz

Oriol Martinez

Xavier Binefa

Jakob Verbeek

Adria Ruiz

Learning Disentangled Representations with Reference-Based Variational Autoencoders

published or not. The documents may come   L'archive ouverte pluridisciplinaire

Introduction

Natural images are the result of a generative process involving a large number factors of variation. For instance, the appearance of a face is determined by the interaction between many latent variables including the pose, the illumination, identity, and expression. Given that the interaction between these underlying explanatory factors is very complex, inverting the generative process is extremely challenging.

From this perspective, learning disentangled representations where different high-level generative factors are independently encoded can be considered one of the most relevant problems in computer vision [START_REF] Bengio | Representation learning: A review and new perspectives[END_REF]. For 1 Univ. Grenoble Alpes, Inria, CNRS, Grenoble INP, LJK, 38000 Grenoble, France 2 Univ. Pompeu Fabra, DTIC , 08018 Barcelona, Spain. Correspondence to: Adria Ruiz <adria.ruizovejero@inria.fr>. instance, these representations can be applied to complex classification tasks given that features correlated with image labels can be easily identified. We find another example in conditional image generation [START_REF] Van Den Oord | Conditional image generation with PixelCNN decoders[END_REF][START_REF] Yan | Attribute2image: Conditional image generation from visual attributes[END_REF], where disentangled representations allow to manipulate high-level attributes in synthesized images.

Motivation: By coupling deep learning with variational inference, Variational autoencoders (VAEs) (Kingma & Welling, 2014) have emerged as a powerful latent variable model able to learn abstract data representations. However, VAEs are typically trained in an unsupervised manner and, they therefore lack a mechanism to impose specific high-level semantics on the latent space. In order to address this limitation, different semi-supervised variants have been proposed (Kingma et al., 2014;[START_REF] Narayanaswamy | Learning disentangled representations with semisupervised deep generative models[END_REF]. These approaches, however, require latent factors to be explicitly labelled in a training set. These annotations provide supervision to the model, and allow to disentangle the labelled variables from the remaining generative factors. The main drawback of this strategy is that it may require a significant annotation effort. For instance, if we are interested in disentangling facial gesture information from face images, we need to annotate samples according to different expression classes. While this is feasible for a reduced number of basic gestures, natural expressions depend on a combination of a large number of facial muscle activations with their corresponding intensities [START_REF] Ekman | What the face reveals: Basic and applied studies of spontaneous expression using the Facial Action Coding System (FACS)[END_REF]. Therefore, it is impractical to label all these factors even in a small subset of training images. In this context, our main motivation is to explore a novel learning setting allowing to disentangle specific factors of variation while minimizing the required annotation effort.

Contributions: We introduce reference-based disentangling. A learning setting in which, given a training set of unlabelled images, the goal is to learn a representation where a specific set of generative factors are disentangled from the rest. For that purpose, the only supervision comes in the form of an auxiliary reference set containing images where the factors of interest are constant (see Fig. 1). Different from a semi-supervised scenario, explicit labels are not available for the factors of interest during training. In contrast, reference-based disentangling is a weakly-supervised task, where the reference set only provides implicit informa- tion about the generative factors that we aim to disentangle. Note that a collection of reference images is generally easier to obtain compared to explicit labels of target factors. For example, it is more feasible to collect a set of faces with a neutral expression, than to annotate images across a large range of expression classes or attributes.

The main contributions of our paper are summarized as follows:

(1) We propose reference-based variational autoencoders (Rb-VAEs). Different from unsupervised VAEs, our model is able to impose high-level semantics into the latent variables by exploiting the weak supervision provided by the reference set; (2) We identify critical limitations of the standard VAE objective when used to train our model. To address this problem, we propose an alternative training procedure based on recently introduced ideas in the context of variational inference and adversarial learning; (3) By learning disentangled representations from minimal supervision, we show how our framework is able to naturally address tasks such as feature learning, conditional image generation, and attribute transfer.

Related Work

Deep Generative Models have been extensively explored to model visual and other types of data. Variational autoencoders (Kingma & Welling, 2014) and generative adversarial networks (GANs) [START_REF] Goodfellow | Generative adversarial nets[END_REF] have emerged as two of the most effective frameworks. VAEs use variational evidence lower bound to learn an encoder network that maps images to an approximation of the posterior distribution over latent variables. Similarly, a decoder network is learned that produces the conditional distribution on images given the latent variables. GANs are also composed of two differentiable networks. The generator network synthesizes images from latent variables, similar to the VAE decoder. The discriminator's goal is to separate real training images from synthetic images sampled from the generator. During training, GANs employ an adversarial learning procedure which allows to simultaneously optimize the discriminator and generator parameters. Even though GANs have been shown to generate more realistic samples than VAEs, they lack an inference mechanism able to map images into their corresponding latent variables. In order to address this drawback, there have been several attempts to combine ideas from VAEs and GANs [START_REF] Larsen | Autoencoding beyond pixels using a learned similarity metric[END_REF][START_REF] Dumoulin | Adversarially learned inference[END_REF][START_REF] Donahue | Adversarial feature learning[END_REF]. Interestingly, it has been shown that adversarial learning can be used to minimize the variational objective function of VAEs [START_REF] Makhzani | Adversarial autoencoders[END_REF][START_REF] Huszár | Variational inference using implicit distributions[END_REF]. Inspired by this observation, various methods such as adversarial variational Bayes [START_REF] Mescheder | Adversarial variational bayes: Unifying variational autoencoders and generative adversarial networks[END_REF], α-GAN [START_REF] Rosca | Variational approaches for autoencoding generative adversarial networks[END_REF], and symmetric-VAE (sVAE) [START_REF] Pu | Symmetric variational autoencoder and connections to adversarial learning[END_REF] have incorporated adversarial learning into the VAE framework.

Different from this prior work, our Rb-VAE model is a deep generative model specifically designed to solve the reference-based disentangling problem. During training, adversarial learning is used in order to minimize a variational objective function inspired by the one employed in sVAE [START_REF] Pu | Symmetric variational autoencoder and connections to adversarial learning[END_REF]. Although sVAE was originally motivated by the limitations of the maximum likelihood criterion used in unsupervised VAEs, we show how its variational formulation offers specific advantages in our context.

Learning Disentangled Representations is a long standing problem in machine learning and computer vision [START_REF] Bengio | Representation learning: A review and new perspectives[END_REF]. In the literature, we can differentiate three main paradigms to address it: unsupervised, supervised, and weakly-supervised learning. Unsupervised models are trained without specific information about the generative factors of interest [START_REF] Desjardins | Disentangling factors of variation via generative entangling[END_REF][START_REF] Chen | Infogan: Interpretable representation learning by information maximizing generative adversarial nets[END_REF]. To address this task, the most common approach consists in imposing different constraints on the latent representation. For instance, unsupervised VAEs typically define the prior over the latent variables with a fully-factorized Gaussian distribution. Given that high-level generative factors are typically independent, this prior encourage their disentanglement in different dimensions of the latent representation. Based on this observation, different approaches such as β-VAE [START_REF] Higgins | Beta-VAE: Learning basic visual concepts with a constrained variational framework[END_REF], DIP-VAE [START_REF] Kumar | Variational inference of disentangled latent concepts from unlabeled observations[END_REF], FactorVAE [START_REF] Kim | Disentangling by factorising[END_REF] or β-TCVAE [START_REF] Chen | Isolating sources of disentanglement in variational autoencoders[END_REF] have explored more sophisticated regularization mechanisms over the distribution of inferred latent variables. Although unsupervised approaches are able to identify simple explanatory components, they do not allow latent variables to model specific high-level factors.

A straight-forward approach to overcome this limitation is to use a fully-supervised strategy. In this scenario, models are learned by using a training set where the factors of interest are explicitly labelled. Following this paradigm, we can find different semi-supervised (Kingma et al., 2014;[START_REF] Narayanaswamy | Learning disentangled representations with semisupervised deep generative models[END_REF], and conditional [START_REF] Yan | Attribute2image: Conditional image generation from visual attributes[END_REF][START_REF] Pu | Variational autoencoder for deep learning of images, labels and captions[END_REF] variants of autoencoders. In spite of the effectiveness of supervised approaches in different applications, obtaining explicit labels is not feasible in scenarios where we aim to disentangle a large number of factors or their annotation is difficult. An intermediate solution between unsupervised and fully-supervised methods are weakly-supervised approaches. In this case, only implicit information about factors of variation is provided during training. Several works have explored this strategy by using different forms of weak-supervision such as: temporal coherence in sequential data [START_REF] Hsu | Unsupervised learning of disentangled and interpretable representations from sequential data[END_REF][START_REF] Denton | Unsupervised learning of disentangled representations from video[END_REF][START_REF] Villegas | Decomposing motion and content for natural video sequence prediction[END_REF], pairs of aligned images obtained from different domains [START_REF] Gonzalez-Garcia | Image-to-image translation for cross-domain disentanglement[END_REF] or knowledge about the rendering process in computer graphics [START_REF] Yang | Weaklysupervised disentangling with recurrent transformations for 3d view synthesis[END_REF][START_REF] Kulkarni | Deep convolutional inverse graphics network[END_REF].

Different from previous works relying on other forms of weak supervision, our method addresses the reference-based disentangling problem. In this scenario, the challenge is to exploit the implicit information provided by a training set of images where the generative factors of interest are constant. Related with this setting, recent approaches have considered to exploit pairing information of images known to share the same generative factors (Mathieu et al., 2016b;[START_REF] Donahue | Semantically decomposing the latent spaces of generative adversarial networks[END_REF][START_REF] Feng | Dual swap disentangling[END_REF][START_REF] Bouchacourt | Multi-level variational autoencoder: Learning disentangled representations from grouped observations[END_REF]. However, the amount of supervision required by these methods is larger than the available in reference-based disentangling. Concretely, we only know that reference images are generated by the same constant factor. In addition, no information is available about what unlabelled samples share the same target factors.

Preliminaries: Variational Autoencoders

Variational autoencoders (VAEs) are generative models defining a joint distribution p θ (x, z) = p θ (x|z)p(z), where x is an observation, e.g. an image, and z is a latent variable with a simple prior p(z), e.g. a Gaussian with zero mean and identity covariance matrix. Moreover, p θ (x|z) is typically modeled as a factored Gaussian, whose mean and diagonal covariance matrix are given by a function of z, implemented by a generator neural network.

Given a training set of samples from an unknown data distribution p(x), VAEs learn the optimal parameters θ by defining a variational distribution q ψ (x, z) = q ψ (z|x)p(x). Note that q ψ (z|x) approximates the intractable posterior p(z|x) and is defined as another factored Gaussian, whose mean and diagonal covariance matrix are given as the output of an encoder or inference network with parameters ψ. The generator and the encoder are optimized by solving:

min θ,ψ E p(x) KL(q ψ (z|x) p(z)) -E q ψ (z|x) log(p θ (x|z)) ,
which is equivalent to the minimization of the KL diver-gence between q ψ (x, z) and p θ (x, z). The first KL term can be interpreted as a regularization mechanism encouraging the distribution q ψ (z|x) to be similar to p(z). The second term is known as the reconstruction error, measuring the negative log-likelihood of a generated sample x from its latent variables q ψ (z|x). Optimization can be carried out by using stochastic gradient descent (SGD) where p(x) is approximated by the training set. The re-parametrization trick [START_REF] Rezende | Stochastic backpropagation and approximate inference in deep generative models[END_REF] is employed to enable gradient back-propagation across samples from q φ (z|x).

Reference-based Disentangling

Consider a training set of unlabelled images (e.g. human faces) x ∈ R W ×H×3 sampled from a given distribution p u (x). Our goal is to learn a latent variable model defining a joint distribution over x and latent variables e ∈ R De and z ∈ R Dz . Whereas e is expected to encode information about a set of generative factors of interest, e.g. facial expressions, z should model the remaining factors of variation underlying the images, e.g. pose, illumination, identity, etc. From now on, we will refer to e and z as the "target" and "common factors", respectively. In order to disentangle them, we are provided with an additional set of reference images sampled from p r (x), representing a distribution over x where target factors e are constant e.g. neutral faces. Given p r (x) and p u (x), we define an auxiliary binary variable y ∈ {0, 1} indicating whether an image x has been sampled from the unlabelled or reference distributions, i.e. p(x|y = 0) = p u (x) and p(x|y = 1) = p r (x). In reference-based disentangling, we aim to exploit the weaksupervision provided by y in order to effectively disentangle target factors e and common factors z.

Reference-based Variational Autoencoders

In this section, we present reference-based variational autoencoders (Rb-VAE). Rb-VAE is a deep latent variable model defining a joint distribution:

p θ (x, z, e, y) = p θ (x|z, e)p(z)p(e|y)p(y), (1)
where conditional dependencies are designed to address the reference-based disentangling problem, see Fig. 2(a). We define p θ (x|z, e) = L(x|G θ (z, e), λ), where G θ (z, e) is the generator network, mapping a pair of latent variables (z, e) to an image defining the mean of a Laplace distribution L with fixed scale parameter λ. We use a Laplace distribution, instead of the Gaussian usually employed in the VAEs. The reason is that the negative log-likelihood is equivalent to the 1 -loss which encourages sharper image reconstructions with better visual quality (Mathieu et al., 2016a).

To reflect the assumption of constant target factors across reference images, we define the conditional distribution over e given y = 1 as a delta peak centered on a learned vector Note that for the reference samples (y = 0), the prior p(e|y) is deterministic given that images are are known to be generated by constant e r . (b) Approximate posteriors q(z|x) and q(e|x, y) map images x to the corresponding common and target factors z and e respectively.

e r ∈ R De , i.e. p(e|y = 1) = δ(e -e r ). In contrast, for y = 0, the conditional distribution is set to a unit Gaussian, p(e|y = 0) = N (e|0, I), as in standard VAEs. In the following, we denote p(e|y = 0) = p(e). Contrary to the case of target factors e, the prior over common factors z is equal for reference and unlabelled images, and taken to be a unit Gaussian p(z) = N (z|0, I). Finally, we assume a uniform prior over y, i.e. p(y = 0) = p(y = 1) = 1 2 .

Conventional Variational Learning

Following the standard VAE framework discussed in Sec. 3, we define a variational distribution q ψ (x, z, e, y) = q ψ (x, z|x)q ψ (e|x, y)p(x, y), and learn the model parameters θ by minimizing the KL divergence between q ψ and p θ :

min θ,ψ
KL(q ψ (x, z, e, y) p θ (x, z, e, y)).

(2)

Note that the conditionals q ψ (e|x, y) and q ψ (z|x) provide a factored approximation of the intractable posterior p θ (e, z|x, y), allowing to infer target and common factors e and z given the image x, see Fig. 2(b). Given a reference image, i.e. with y = 1, the target factors q ψ (e|x, y = 1) are known to be equal to the reference value e r . On the other hand, given an non-reference image, i.e. with y = 0, we define the approximate posterior q ψ (e|x, y = 0) = N (e|E µ (x), E σ (x)), where the means and diagonal covariance matrices of a conditional Gaussian distribution are given by non-linear functions E µ (x) and E σ (x), respectively. Similarly, we use an additional network to model q ψ (z|x) = N (z|Z µ (x), Z σ (x)).

Optimization. In Appendix A.1 we show that the mini-mization of Eq. ( 2) can be expressed as min θ,ψ,e r E p u (x) KL(q ψ (z|x)q ψ (e|x) p(z)p(e))-

E q ψ (z|x)q ψ (e|x) log(p θ (x|z, e)) + E p r (x) KL(q ψ (z|x) p(z))- E q ψ (z|x) log(p θ (x|z, e r )) , (3)
where the second and fourth terms of the expression correspond to the reconstruction errors for unlabelled and reference images respectively. Note that, for reference images, no inference over target factors e is needed. Instead, the generator reconstructs them using the learned parameter e r . Similar to standard VAEs, the remaining terms consist of KL divergences between approximate posteriors and priors over the latent variables. The minimization problem defined in Eq. ( 3) can be solved using SGD and the re-parametrization trick in order to back-propagate the gradient when sampling from q ψ (e|x) and q ψ (z|x).

Symmetric Variational Learning

The main limitation of the variational objective defined in Eq. ( 3) is that it does not guarantee that common and target factors will be effectively disentangled in z and e respectively. In order to understand this phenomenon, it is necessary to analyze the role of the conditional distribution p(e|y) in Rb-VAEs. By defining p(e|y = 1) as a delta function, the model is forced to encode into z all the generative factors of reference images, given that they must be reconstructed via p θ (x|z, e r ) with constant e r . Therefore, p(e|y) is implicitly encouraging q ψ (z|x) to encode common factors present in reference and unlabelled samples. However, this mechanism does not avoid the scenario where target factors are also encoded into latent variables z. More formally, given that z is expressive enough, the minimization of Eq. ( 3) does not prevent a degenerate solution p θ (x|z, e) = p θ (x|z), where the inferred latent variables by q ψ (e|x) are ignored by the generator.

To address this limitation, we propose to optimize an alternative variational expression inspired by unsupervised Symmetric VAEs [START_REF] Pu | Symmetric variational autoencoder and connections to adversarial learning[END_REF]. Specifically, we add the reverse KL between q ψ and p θ to the objective of the minimization problem:

min θ,ψ
KL(q ψ (x, z, e, y) p θ (x, z, e, y))+ KL(p θ (x, z, e, y) q ψ (x, z, e, y)).

(4)

In order to understand why this additional term allows to mitigate the degenerate solution p θ (x|z, e) = p θ (x|z), it is necessary to observe that its minimization is equivalent to:

min θ,ψ E p(z,e) KL(p θ (x|z, e) p u (x))- (5)
E p θ (x|z,e) [log(q ψ (z|x)) + log(q ψ (e|x))] + E p(z)p θ (x|z,e r ) KL(p θ (x|z, e r )||p r (x)) -log(q ψ (z|x)) , see Appendix A.1 for details. Note that the two KL divergences encourage images generated using p(z), p(e) and e r to be similar to samples from the real distributions p r (x) and p u (x). On the other hand, the remaining terms correspond to reconstruction errors over latent variables z, e inferred from generated images drawn from p θ . As a consequence, the minimization of these errors is encouraging the generator p θ (x|z, e) to generate images x by taking into account latent variables e, since the latter must be reconstructed via q ψ (e|x). In conclusion, the minimization of the reversed KL avoids the degenerate solution ignoring e.

Optimization via Adversarial Learning. Given the introduction of the reversed KL divergence, the learning procedure described in Sec. 4.2 can not be directly applied to the minimization of Eq. ( 4). However, note that we can express the defined symmetric objective as:

min θ,ψ E q ψ (e,z|x)p u (x) L xze -E p θ (x|e,z)p(z)p(e) L xze + E q ψ (z|x)p r (x) L xz -E p θ (x|e r ,z)p(z) L xz , (6)
where L xze corresponds to the log-density ratio between distributions q ψ (e, z|x)p u (x) and p θ (x|e, z)p(z)p(e). Similarly, L xz defines an analogous expression for q ψ (z|x)p r (x) and p θ (x|e r , z)p(z). See Appendix A.1 for a detailed derivation.

Taking into account previous definitions, SGD optimization can be employed in order to learn model parameters. Concretely, we can evaluate L xze and L xz to back-propagate the gradients w.r.t. parameters ψ and θ by using the reparametrization trick over samples of x, e and z. The main challenge of this strategy is that expressions L xze and L xz can not be explicitly computed. However, the log-density ratio between two distributions can be estimated by using logistic regression [START_REF] Bickel | Discriminative learning for differing training and test distributions[END_REF]. In particular, we define an auxiliary parametric function d ξ (x, z, e) ∼ L xze and learn its parameters ξ by solving:

max ξ E p θ (x|z,e)p(z,e) log(σ(d ξ (x, z, e)) + E q ψ (e,z|x)p u (x) log(1 -σ(d ξ (x, z, e)), (7)
where σ(•) refers to the sigmoid function. Similarly, L xz is approximated with an additional function d γ (x, z).

This approach is analogous to adversarial unsupervised methods such as ALI [START_REF] Dumoulin | Adversarially learned inference[END_REF], where the function d γ (•) acts as a discriminator trying to distinguish whether pairs of reference images x and latent variables z have been generated by q ψ and p θ . However, in our case we have an additional discriminator d ξ operating over unlabelled images and its corresponding latent variables z and e (see Fig. 3a-b) To conclude, it is also interesting to observe that the discriminator d γ (x, z) is implicitly encouraging latent variables z to encode only information about the common factors. The reason is that samples generated from p θ (x|z, e r )p(z) are forced to be similar to reference images. As a consequence, z can not contain information about target factors, which must be encoded into e.

Using previous definitions, we use an adversarial procedure where model and discriminators parameters (θ,ψ), and (ξ,γ) are simultaneously optimized by minimizing and maximizing equations ( 6) and ( 7) respectively. The algorithm used to process one batch during SGD is shown in Appendix A.2. In Rb-VAEs, the discriminators d γ (•) and d ξ (•) are also implemented as deep convolutional networks.

Explicit Log-likelihood Maximization. As shown in equations (3) and ( 5), the minimization of the symmetric KL divergence encourages low reconstruction errors for images and inferred latent variables. However, by using the proposed adversarial learning procedure, the minimization of these terms becomes implicit. As shown by [START_REF] Dumoulin | Adversarially learned inference[END_REF] and [START_REF] Donahue | Adversarial feature learning[END_REF], this can cause original samples to differ substantially from their corresponding reconstructions. In order to address this drawback, we use a similar strategy as [START_REF] Pu | Symmetric variational autoencoder and connections to adversarial learning[END_REF] and [START_REF] Li | Towards understanding adversarial learning for joint distribution matching[END_REF], and explicitly add the reconstruction terms into the learning objective, minimizing them together with Eq. ( 6), see Fig. 3(c-f). In preliminary experiments, we found that the explicit addition of these reconstructions terms during training is important to achieve low reconstruction errors, and to increase stability of adversarial training.

Experiments

Datasets

To validate our approach and to compare to existing work, we consider two different problems.

Digit Style Disentangling.

The goal is to model style variations from hand-written digits. We consider the digit style as a set of three different properties: scale, width and color.

In order to address this task from a reference-based perspective, we use half of the original training images in the MNIST dataset [START_REF] Lecun | Gradientbased learning applied to document recognition[END_REF] as our reference distribution (30k examples). The unlabelled set is synthetically generated by applying different transformations over the remaining half of images: (1) Simulation of stroke widths by using a dilation with a given filter size;

(2) Digit colorization by multiplying the RGB components of the pixels in an image by a random 3D vector;

(3) Size variations by down-scaling the image by a given factor. We randomly transform each image twice to obtain a total of 60k unsuperivsed images. See more details in Appendix A.3.

Facial Expression Disentangling. We address the disentangling of facial expressions by using a reference set of neutral faces. As unlabelled images we use a subset of the AffectNet dataset [START_REF] Mollahosseini | Affectnet: A database for facial expression, valence, and arousal computing in the wild[END_REF], which contains a large quantity of facial images. This database is especially challenging since faces were collected "in the wild" and exhibit a large variety of natural expressions. A subset of the images are annotated according to different facial expressions: happiness, sadness, surprise, fear, disgust, anger, and contempt. We use these labels only for quantitative evaluation. Given that we found that many neutral images in the original database were not correctly annotated, we collected a separate reference set, see Appendix A.3. The unlabelled and reference sets consist of 150k and 10k images, respectively.

Baselines and Implementation Details

We evaluate the two different variants of our proposed method: Rb-VAE, trained using the standard variational objective (Sec. 4.2), and sRb-VAE, learned by minimizing the symmetric KL divergence (Sec. 4.3). To demonstrate the advantages of exploiting the weak-supervision provided by reference images, we compare both methods with various state-of-the-art unsupervised approaches based on the VAE framework: β-VAE [START_REF] Higgins | Beta-VAE: Learning basic visual concepts with a constrained variational framework[END_REF], β-TCVAE [START_REF] Chen | Isolating sources of disentanglement in variational autoencoders[END_REF], sVAE [START_REF] Pu | Symmetric variational autoencoder and connections to adversarial learning[END_REF], DIP-VAE-I and DIP-VAE-II [START_REF] Kumar | Variational inference of disentangled latent concepts from unlabeled observations[END_REF]. Note that β-VAE DIP-VAE and β-TCVAE have been specifically proposed for learning disentangled representations, showing better performance than other unsupervised methods such as InfoGAN [START_REF] Chen | Infogan: Interpretable representation learning by information maximizing generative adversarial nets[END_REF]. On the other hand, sVAE is trained using a similar variational objective as sRb-VAE, and can therefore be considered an unsupervised version of our method. We also evaluate vanilla VAEs (Kingma & Welling, 2014).

As discussed in Sec. 2, there are no existing approaches in the literature that directly address reference-based disentangling. In order to evaluate an alternative weakly-supervised baseline exploiting the reference-set, we have implemented (Mathieu et al., 2016b), and adapted it to our context. Concretely, we have modified the learning algorithm in order to use only pairing information from reference imagesm by removing the reconstruction losses for pairs of unlabelled samples as such information is not available in referencebased disentangling.

The different components of our method are implemented as deep neural networks. For this purpose, we have used convdeconv architectures as is standard in VAE and GANs literature. Specifically, we employ the main building blocks used by [START_REF] Karras | Progressive growing of gans for improved quality, stability, and variation[END_REF], where the generator is implemented as a sequence of convolutions, Leaky-ReLU non-linearities, and nearest-neighbour up-sampling operations. Encoder and discriminators follow a similar architecture, using average pooling for down-sampling. See Appendix A.4 for more details. For a fair comparison, we have developed our own implementation for all the evaluated methods in order to use the same network architectures and hyper-parameters.

During optimization, we use the Adam optimizer [START_REF] Kingma | A method for stochastic optimization[END_REF] and a batch size of 36 images. For the MNIST and AffectNet , the models are learned for 30 and 20 epochs respectively. The number of latent variables for the encoders has been set to 32 for all the experiments and models. The λ parameter in the Laplace distribution is set to 0.01.

Quantitative evaluation: Feature Learning

A common strategy to evaluate the quality of learned representations is to measure the amount of information that they convey about the underlying generative factors. In our setting, we are interested in modelling the target factors that To predict the different expression classes in the Af-fectNet dataset, we use a linear classifier. For methods using the reference-set, we used the inferred latent variables e as features since they are expected to encode the information regarding the target factors. In unsupervised models we use all the latent variables. For evaluation, we split each dataset in three subsets. The first is used to learn each generative model. Then, the second is used for training the regressors or classifier. Finally, the third is used to evaluate the predictions in terms of the mean absolute error and per-class accuracy for the MNIST and AffectNet datasets, respectively. In MNIST, the second and third subset (5k images each) have been randomly generated from the original MNIST test set using the procedure described in Sec. 5.1.

For AffectNet, we randomly select 500 images for each of the seven expressions from the original dataset, yielding 3,500 images per fold.

It is worth mentioning that some recent works [START_REF] Kumar | Variational inference of disentangled latent concepts from unlabeled observations[END_REF][START_REF] Chen | Isolating sources of disentanglement in variational autoencoders[END_REF] have proposed alternative criterias to evaluate disentanglement. However, the proposed metrics are specifically designed to measure how a single dimension of the learned representation corresponds to a single groundtruth label. Note, however, that the one-to-one mapping assumption is not appropriate for real scenarios where we want to model high-level generative factors. For instance, it is unrealistic to expect that a single dimension of the latent vector e can convey all the information about a complex label such as the facial expression.

Results and discussion. Table 1 shows the results obtained by the different baselines considered and the proposed Rb-VAE and sRb-VAE. For DIP-VAE, β-VAE and β-TCVAE we tested different regularization parameters in the range [1, 50], and report the best results. Note that the unsupervised approach DIP-VAE-I achieves better average results than Rb-VAE for MNIST. Moreover, in AffectNet, β-TCVAE achieves comparable or better performance in several cases. This may seem counter-intuitive because, unlike Rb-VAE, DIP-VAE-I is trained without the weaksupervision provided by reference images. However, it confirms our hypothesis that the learning objective of Rb-VAE does not explicitly encourage the disentanglement between target and common factors. In contrast, we can see that in most cases sRb-VAE obtains comparable or better results than rest of the methods. Moreover, it achieves the best average performance in both datasets. This demonstrates that the information provided by the reference distribution is effectively exploited by the symmetric KL objective used to train sRb-VAE. Additionally, note that the better performance of our model compared to unsupervised methods is informative. The reason is that the latter must encode all the generative factors into a single feature-vector. As a consequence, the target factors are entangled with the rest and the ground-truth labels are difficult to predict. In contrast, the representation e learned by our model is shown to be more effective because non-relevant factors are effectively removed, i.e. encoded into z.

In order to further validate this conclusion, we have followed the same evaluation protocol for Rb-VAE and sRb-VAE but considering the latent variables z as features. The average performance obtained by Rb-VAE is .349 and .195 for AffectNet and MNIST respectively. On the other hand, sRb-VAE achieves .335 and .189. Note that for both methods these results are significantly worse compared to using e as a representation in Table 1. This shows that latent variable z is mainly modelling the common factors between reference and unlabelled images. The qualitative results presented in the next section confirm this. To conclude, note that sRb-VAE also obtains better performance than Mathieu et al. (2016b) in both data-sets. So even though this method also uses reference-images during training, sRb-VAE is shown to better exploit the weak-supervision existing in referencebased disentangling. Using our model, this can be easily achieved by synthesizing a new image from latent variables e and z inferred from A and B respectively. Fig. 5 shows images generated by sRb-VAE and Rb-VAE in this scenario. In this case, we can draw similar conclusions than the previous experiment. Rb-VAE is not able to swap target factors related with the digit scale in the MNIST dataset, unlike sRb-VAE which better model this type of variation. On the AffectNet images, both methods are able to keep most of the information regarding the identity of the subject, but again Rb-VAE leads to weaker expression changes than sRb-VAE.

These qualitative results demonstrate that the standard variational objective of VAE is sub-optimal to train our model, and that the symmetric KL divergence objective used in sRb-VAE allows to better disentangle the common and target factors. Additional results are shown in Appendix A.5.

Conclusions

In this paper we have introduced the reference-based disentangling problem and proposed reference-based variational autoencoders to address it. We have shown that the standard variational learning objective used to train VAE can lead to degenerate solutions when it is applied in our setting, and proposed an alternative training strategy that exploits adversarial learning. Comparing the proposed model with previous state-of-the-art approaches, we have shown its ability to learn disentangled representations from minimal supervision and its application to tasks such as feature learning, conditional image generation and attribute transfer.

A. Appendix

A.1. Mathematical derivations Equivalence between KL(q ψ (x, z, e, y) p θ (x, z, e, y)) and Eq. ( 3):

y∈[0,1] x,e,z
q ψ (e|x, y)q ψ (z|x)p(x|y)p(y) log q ψ (z, e|x, y)p(x|y)p(y) p θ (x|e, z)p(z)p(e|y)p(y) dxdzde (8) = 1 2 x,e,z q ψ (e|x)q ψ (z|x)p u (x) log q ψ (e|x)q ψ (z|x)p u (x) p θ (x|e, z)p(z)p(e) dxdzde

+ 1 2 x,z q ψ (z|x)p r (x) log q ψ (z|x)p r (x) p θ (x|e r , z)p(z) dxdz (9) = 1 2 E p u (x) E q ψ (e|x)q ψ (z|x) log q ψ (e|x)q ψ (z|x) p(z)p(e) -log(p θ (x|e, z)) -H u (x) + 1 2 E p r (x) E q ψ (z|x) log q ψ (z|x) p(z) -log(p θ (x|e r , z)) -H r (x) (10) = 1 2 E p u (x) KL(q ψ (z|x)q ψ (e|x) p(z)p(e)) -E q ψ (z|x)q ψ (e|x) log(p θ (x|z, e)) + 1 2 E p r (x) KL(q ψ (z|x) p(z)) -E q ψ (z|x) log(p θ (x|z, e r )) -H r (x) -H u (x)
We use H r (X) and H u (X) to denote the entropy of the reference and unlabelled distributions p r (x) and p u (x) respectively. Note that they can be ignored during the minimization since are constant w.r.t. parameters θ and ψ. For the second equality, we have used the definitions p(x|y = 0) = p u (x), p(x|y = 1) = p r (x) and assumed p(y = 0) = p(y = 1) = 1 2 . Moreover, we have exploited the fact that q ψ (e|x, y = 1) and p(e|y = 1) are defined as delta functions and, therefore, E p(e|y=1) log( p(e|y=1) q ψ (e|y=1) ) = 0. We denote p(e|y = 0) = p(e) and q ψ (e|x, y = 0) = q ψ (e|x) for the sake of brevity. Equivalence between KL(p θ (x, z, e, y) q ψ (x, z, e, y)) and the expression in Eq. ( 5) y∈[0,1] x,e,z p θ (x|e, z)p(z)p(e|y)p(y) log p θ (x|e, z)p(z)p(e|y)p(y) q ψ (z, e|x, y)p(x|y)p(y) dxdzde (11)

= 1 2 x,e,z p θ (x|e, z)p(z)p(e) log p θ (x|e, z)p(z)p(e) q ψ (e|x)q ψ (z|x)p u (x) dxdzde + 1 2 x,z p θ (x|e r , z)p(z) log p θ (x|e r , z)p(z) q ψ (z|x)p r (x) dxdzde (12) = 1 2 E p(z)p(e) E p θ (x|e,z) log p θ (x|e, z) p(x) u -log(q ψ (e|x)q ψ (z|x)) + 1 2 E p(z) E p θ (x|e r ,z) log p θ (x|e r , z) p(x) r -log(q ψ (z|x)) -H(z) - 1 2 H(e) (13) = 1 2 E p(z)p(e) KL(p θ (x|z, e) p u (x)) -E p θ (x|z,e) [log(q ψ (z|x)) + log(q ψ (e|x))] + 1 2 E p(z) KL(p θ (x|z, e r ) p r (x)) -E p θ (x|z,e r ) log(q ψ (z|x)) -H(z) - 1 2 H(e) (14)
We have used the same definitions and assumptions previously discussed. Moreover, we denote H(z) and H(e) as the entropy of the priors p(z) and p(e). Again, we can ignore these terms when we are optimizing w.r.t parameters ψ and θ.

Equivalence between the minimization of the symmetric KL divergence in Eq. ( 4) and the expression in Eq. ( 6) KL(q ψ (z, e, x, y) p θ (x, z, e, y)) + KL(p θ (x, z, e, y) q ψ (z, e, x, y)) = (15)

= E q ψ (e|x,y)q ψ (z|x)p(x|y)p(y) log q ψ (e|x, y)q ψ (z|x)p(x|y)p(y) p θ (x|e, z)p(z)p(e|y)p(y)

+ E p θ (x|e,z)p(z)p(e|y)p(y) log p θ (x|e, z)p(z)p(e|y)p(y) q ψ (e|x, y)q ψ (z|x)p(x|y)p(y)

(16)

= 1 2 E q ψ (e,z|x)p u (x) log q ψ (e, z|x)p u (x) p θ (x|e, z)p(z)p(e) + E q ψ (z|x)p r (x) log q ψ (z|x)p(x) r p θ (x|e r , z)p(z) + E p θ (x|e,z)p(z)p(e) log p θ (x|e, z)p(z)p(e) q ψ (e, z|x)p u (x) + E p θ (x|e r ,z)p(z) log p θ (x|e r , z)p(z)) q ψ (z|x)p r (x) (17) = 1 2 E q ψ (e,z|x)p u (x) L xze + E q ψ (z|x)p r (x) L xz -E p θ (x|e,z)p(z)p(e) L xze -E p θ (x|e r ,z)p(z) L xz (18)
A.2. Pseudo-code for adversarial learning procedure

Algorithm 1 shows pseudo-code for the adversarial learning algorithm described in Sec. 4.3 of the paper.

Algorithm 1 sRb-VAE Advesarial Learning (Batch processing during SGD) 4: Sample {e1, ..., e M } using q φ (e|x) 5: Sample {z1, ..., z M } using q φ (z|x) 6: Sample {z r 1 , ..., z r M } using q φ (z|x r )

7: Compute gradient of Eq. ( 8) w.r.t ψ using the reparametrization trick for stochastic variables z, e and z r : We use slightly modified version of the MNIST images: the size is increased to 64 × 64 pixels and an edge detection procedure is applied to keep only the boundaries of the digit. We obtain the samples in the unlabelled dataset by applying the following transformations over the MNIST images:

g φ ← ∇ φ 1 m m d ξ (
1. Width: Generate a random integer in the range {1, . . . , 10} using a uniform distribution. Apply a dilation operation over the image using a squared kernel with pixel-size equal to the generated number.

2. Color: Generate a random 3D vector c ∈ [0, 1] 3 using a uniform distribution. Normalize the resulting vector as ĉ = c/||c|| 1 . Multiply the RGB components of all the pixels in the image by ĉ.

3. Size: Generate a random number in the range [0.5, 1] using a uniform distribution. Downscale the image by a factor equal to the generated number. Apply zero-padding to the resulting image in order to recover the original resolution.

A.3.2. AFFECTNET

Reference Set Collection. We collected a reference set of face images with neutral expression. We applied specific queries in order to obtain a large amount of faces from image search engines. Then, five different annotators filtered them in order to keep only images showing a neutral expression. The motivation for this data collection was that we found that many neutral images in the AffectNet dataset [START_REF] Mollahosseini | Affectnet: A database for facial expression, valence, and arousal computing in the wild[END_REF] are not accurate. As detailed in the original paper, the inter-observer agreement is significantly low for neutral images. In contrast, in our reference-set, each image was annotated in terms of "neutral" / "non-neutral" by two different annotators. In order to ensure a higher label quality compared to the AffectNet, only the images where both annotators agreed were added to the reference-set.

Figure 1 :

 1 Figure 1: Examples of reference-based disentangling problems. Left: Disentangling factors underlying facial expression. The reference set contains faces with neutral expression. Right: Disentangling style from digits. The reference set is composed by digits with a fixed style.

Figure 2 :

 2 Figure 2: (a) Rb-VAE generative process where p θ (x|z, e) maps latent variables z (common factors) and e (target factors) to images x. Shaded circles indicate observed variables.Note that for the reference samples (y = 0), the prior p(e|y) is deterministic given that images are are known to be generated by constant e r . (b) Approximate posteriors q(z|x) and q(e|x, y) map images x to the corresponding common and target factors z and e respectively.

Figure 3 :

 3 Figure 3: Losses used by sRB-VAE. Discriminator d ξ (x, z, e) measures the log-density ratio between the distributions q ψ (z, e|x)p u (x) and p θ (x|e, z)p(z)p(e). (b) Similar loss for reference images using an additional discriminator d γ (x, z) (c,d) Reconstruction errors for unlabelled and reference images. (e,f) Reconstruction error over latent variables inferred from unlabelled and reference images generated using p(z), p(e) and e r

Figure 4 :

 4 Figure 4: Conditional image synthesis for MNIST (top) and AffectNet (bottom) using sRb-VAE and Rb-VAE. Within each column images are generated using the same random target factors e.

Figure 5 :

 5 Figure 5: Transferring target factors e from image A to an image B on AffectNet (expression) and MNIST (style).

  xm, zm, em) *** Gradient θ ***/ 9: Sample {ê1, ..., êM } from p(e) 10: Sample {ẑ1, ..., ẑM } from p(z) 11: Sample {ẑ r 1 , ..., ẑr M } from p(z) 12: Sample {x1, ..., xM } using p θ (x|ẑ, e) 13: Sample {x r 1 , ..., xr M } using p θ (x|ẑ, e r ) 14: Compute gradient of Eq. (8) w.r.t θ using the reparametrization trick for stochastic variables x and xr : *** Gradient ξ ***/ 16: Compute gradient of discriminator function (Eq. (9)) w.r.t ξ: g ξ ← ∇ ξ 1 2m m log(σ(d ξ (xm, zm, em))+ log(1 -σ(d ξ (xm, ẑm, êm))17: /*** Gradient γ ***/ 18: Compute gradient of discriminator function (Eq. (9)) w.r.t γ: parameters via SGD with learning rate λ:θ ← θ + λg θ ψ ← ψ -λg ψ ξ ← ξ + λg ξ γ ← γ + λgγ A.3. DatasetsExamples of reference and unlabelled images for MNIST and AffectNet are shown in Fig.6. In the following, we provide more information about the used datasets.

Figure 6 :

 6 Figure 6: Examples of reference and unlabelled images used in our experiments. Extracted from MNIST (top) and AffectNet (bottom) datasets.

Figure 8 :

 8 Figure 8: Qualitative results of sRb-VAE and Rb-VAE applied to conditional image generation. See Sec. (5.4) of the paper for details.

Figure 9 :

 9 Figure 9: Qualitative results of sRb-VAE and Rb-VAE applied to visual attribute transfer. See Sec. (5.4) of the paper for details.

Figure 10 :

 10 Figure 10: Images sample from the sRB-VAE model. Images in the same panel share the same target factors e (expression). Images sharing the same position in the grids are generated from the same common factors z (identity)

Table 1 :

 1 Prediction of target factors from learned representations. We report accuracy and mean-absolute-error as evaluation metrics for the AffectNet and MNIST datasets, respectively. Two best methods shown in bold, best result in brackets.are constant in the reference distribution.

					AffectNet						MNIST
		Happ	Sad	Sur	Fear	Disg	Ang	Compt	Avg.	R	G	B	Scale Width	Avg.
	VAE	.554	.279	.383	.357	.256	.415	.439	.383	.099	.104	.101	[.034]	.085	.085
	DIP-VAE-I	.561	.269	[.401]	.367	.258	.397	.463	.388	[.055]	.064	.063	.038	.100	.064
	DIP-VAE-II	.548	.245	[.401] [.389]	.268	.391	.463	.386	.077	.069	.076	.035	.098	.071
	β VAE	.581	.283	.373	.323	.250	.415	.467	.384	.093	.099	.094	.039	.089	.083
	sVAE	.583	.251	.389	.349	.260	.391	.469	.384	.094	.092	.084	.036	.104	.082
	β-TCVAE	.563	.277	.393	.349	.256	[.427]	.467	.390	.098	.100	.099	[.034] [.084]	.083
	[Mathieu et. al]	.567	.388	.312	.330	.295	.353	[.512]	.395	.116	.116	.114	.039	.104	.098
	RBD-VAE	.536	.393	.379	.311	.320	.383	.421	392	.065	.069	.062	.061	.095	.070
	sRBD-VAE	[.587] [.405]	.387	.327	[.344]	.425	.483	[.422]	.057	[.053] [.055]	.038	.095	[.060]
	Experimental Setup. Following a similar evaluation as
	Mathieu et al. (2016b), we use the learned representations
	as feature vectors and train a low-capacity model estimating
	the target factors involved in each problem. Concretely, in
	the MNIST dataset we employ a set of linear-regressors
	predicting the scale, width and color parameters for each
	digit.

Pre-processing. In order to remove 2D affine transformations such as scaling or in-plane rotations, we apply an alignment process to the face images. We localize facial landmarks using the approach of [START_REF] Xiong | Supervised descent method and its applications to face alignment[END_REF]. Then, we apply Procrustes analysis in order to find an affine transformation aligning the detected landmarks with a mean shape. Finally, we apply the transformation to the image and crop it. The resulting image is then re-sized to a resolution of 96 × 96 pixels.

A.4. Network architectures

Fig. 7 illustrates the network architectures used in our experiments. CN refers to pixel-wise normalization as described in [START_REF] Karras | Progressive growing of gans for improved quality, stability, and variation[END_REF]. FC defines a fully-connected layer. For Leaky ReLU non-linearities, we have used an slope of 0.2. Given that we normalize the images in the range [-1, 1], we use an hyperbolic tangent function as the last layer of the generator. For the discriminator d γ (x, z), we use the same architecture showed for d ξ (x, z, e) but removing the input corresponding to e. For the Adam optimizer [START_REF] Kingma | A method for stochastic optimization[END_REF] , we used α = 10 -4 , β 1 = 0.5, β 2 = 0.99 and = 10 -8 . Note that the described architectures and hyper-parameters follow standard definitions according to most of GAN/VAEs previous works.

In preliminary experiments, we found that the discriminator in sRb-VAE can start to ignore the inputs corresponding to latent variables e and z while focusing only on real and generated images. In order to mitigate this problem during training, we found it effective to randomly set to zero the inputs corresponding to latent variables and images of the last fully-connected layer. Note that this strategy is only used for sRB-VAE and sVAE in our experiments and it is not necessary in the other evaluated baselines. The reason is that these two methods are the only ones employing discriminators receiving images and features as input. We set the dropout probability to 0.25. We found that this default value worked well for both methods in all the datasets and no specific fine-tuning of this hyper-parameter was necessary to mitigate the described phenomena.

A.5. Additional Results

Figures 8 and9 show additional qualitative results for conditional image generation and visual attribute transfer, in the same spirit as the figures in Section 5.4. In order to provide more results for the conditional image generation task, we also provide two videos in this supplementary material. These videos contain animations generated by interpolating over the latent space corresponding to variations e (results shown for MNIST and AffectNet dataset). In Fig. 10, we also show additional images generated by sRB-VAE trained with the AffectNet dataset. Different from the previous cases, these images have been generated by just injecting random noise to the generator (over both latent variables e and z). Note that different target factors e generate similar expressions in images generated from different common factors z. The additional results further support the conclusions drawn in the main paper.