Title: DNA-GAN: LEARNING DISENTANGLED REPRESEN-TATIONS FROM MULTI-ATTRIBUTE IMAGES

Abstract: Disentangling factors of variation has always been a challenging problem in representation learning. Existing algorithms suffer from many limitations, such as unpredictable disentangling factors, bad quality of generated images from encodings, lack of identity information, etc. In this paper, we proposed a supervised algorithm called DNA-GAN trying to disentangle different attributes of images. The latent representations of images are DNA-like, in which each individual piece represents an independent factor of variation. By annihilating the recessive piece and swapping a certain piece of two latent representations, we obtain another two different representations which could be decoded into images. In order to obtain realistic images and also disentangled representations, we introduced the discriminator for adversarial training. Experiments on Multi-PIE and CelebA datasets demonstrate the effectiveness of our method and the advantage of overcoming limitations existing in other methods.

1. INTRODUCTION:

The success of machine learning algorithms depends on data representation, because different representations can entangle different explanatory factors of variation behind the data. Although prior knowledge can help us design representations, the vast demand of AI algorithms in various domains cannot be met, since feature engineering is labor-intensive and needs domain expert knowledge. Therefore, algorithms that can automatically learn good representations of data will definitely make it easier for people to extract useful information when building classifiers or predictors.

Of all criteria of learning good representations as discussed in Bengio et al. (2013) , disentangling factors of variation is an important one that helps separate various explanatory factors. For example, given a human-face image, we can obtain various information about the person, including gender, hair style, facial expression, with/without eyeglasses and so on. All of these information are entangled in a single image, which renders the difficulty of training a single classifier to handle different facial attributes. If we could obtain a disentangled representation of the face image, we may build up only one classifier for multiple attributes.

In this paper, we propose a supervised method called DNA-GAN to obtain disentangled representations of images. The idea of DNA-GAN is motivated by the DNA double helix structure, in which different kinds of traits are encoded in different DNA pieces. We make a similar assumption that different visual attributes in an image are controlled by different pieces of encodings in its latent representations. In DNA-GAN, an encoder is used to encode an image to the attribute-relevant part and the attribute-irrelevant part, where different pieces in the attribute-relevant part encode information of different attributes, and the attribute-irrelevant part encodes other information. For example, given a facial image, we are trying to obtain a latent representation that each individual part controls different attributes, such as hairstyles, genders, expressions and so on. Though annihilating recessive pieces and swapping certain pieces, we can obtain novel crossbreeds that can be decoded into new images. By the adversarial discriminator loss and the reconstruction loss, DNA-GAN can reconstruct the input images and generate new images with new attributes. Each attribute is disentangled from others gradually though iterative training. Finally, we are able to obtain disentangled representations in the latent representations.

The summary of contributions of our work is as follows:

1. We propose a supervised algorithm called DNA-GAN, that is able to disentangle multiple attributes as demonstrated by the experiments of interpolating multiple attributes on Multi-PIE (Gross et al., 2010) and CelebA (Liu et al., 2015) datasets.

2. We introduce the annihilating operation that prevents from trivial solutions: the attributerelevant part encodes information of the whole image instead of a certain attribute.

3. We employ iterative training to address the problem of unbalanced multi-attribute image data, which was theoretically proved to be more efficient than random image pairs.

2. RELATED WORK:

Traditional representation learning algorithms focus on (1) probabilistic graphical models, characterized by Restricted Boltzmann Machine (RBM) (Smolensky, 1986) , Autoencoder (AE) and their variants;

(2) manifold learning and geometrical approaches, such as Principal Components Analysis (PCA) (Pearson, 1901) , Locally Linear Embedding (LLE) (Roweis & Saul, 2000) , Local Coordinate Coding (LCC) (Yu et al., 2009) , etc. However, recent research has actively focused on developing deep probabilistic models that learn to represent the distribution of data. Kingma & Welling ( 2013) employs an explicit model distribution and uses variational inference to learn its parameters. As the generative adversarial networks (GAN) (Goodfellow et al., 2014) has been invented, many implicit models are developed.

In the semi-supervised setting, Siddharth et al. (2016) learns a disentangled representations by using an auxiliary variable. Bouchacourt et al. (2017) proposes the ML-VAE that can learn disentangled representations from a set of grouped observations. In the unsupervised setting, InfoGAN (Chen et al., 2016) tries to maximize mutual information between a small subset of latent variables and observations by introducing an auxiliary network to approximate the posterior. However, it relies much on the a-priori choice of distributions and suffered from unstable training. Another popular unsupervised method β-VAE (Higgins et al., 2016) , adapted from VAE, lays great stress on the KL distance between the approximate posterior and the prior. However, unsupervised approaches do not anchor a specific meaning into the disentanglement.

More closely with our method, supervised methods take the advantage of labeled data and try to disentangle the factors as expected. DC-IGN (Kulkarni et al., 2015) asks the active attribute to explain certain factor of variation by feeding the other attributes by the average in a mini-batch. TD-GAN (Wang et al., 2017) uses a tag mapping net to boost the quality of disentangled representations, which are consistent with the representations extracted from images through the disentangling network. Besides, the quality of generated images is improved by implementing the adversarial training strategy. However, the identity information should be labeled so as to preserve the id information when swapping attributes, which renders the limitation of applying it into many other datasets without id labels. IcGAN (Perarnau et al., 2016 ) is a multi-stage training algorithm that first takes the advantage of cGAN (Mirza & Osindero, 2014) to learn a map from latent representations and conditional information to real images, and then learn its inverse map from images to the latent representations and conditions in a supervised manner. The overall effect depends on each training stage, therefore it is hard to obtain satisfying images. Unlike these models, our model requires neither explicit id information in labels nor multi-stage training.

Many works have studied the image-to-image translation between unpaired image data using GANbased architectures, see Isola et al. (2016) , Taigman et al. (2016) , Zhu et al. (2017) , Liu et al. (2017) and Zhou et al. (2017) . Interestingly, these models require a form of 0/1 weak supervision that is similar to our setting. However, they are circumscribed in two image domains which are opposite to each other with respect to a single attribute. Our model differs from theirs as we generalize to the case of multi-attribute image data. Specifically, we employ the strategy of iterative training to overcome the difficulty of training on unbalanced multi-attribute image datasets.

3. DNA-GAN APPROACH:

In this section, we formally outline our method. A set X of multi-labeled images and a set of labels Y are considered in our setting. Let {(X 1 , Y 1 ), . . . , (X m , Y m )} denote the whole training dataset, where X i ∈ X is the i-th image with its label Y i ∈ Y . The small letter m denotes the number of samples in set X and n denotes the number of attributes. The label Y i = (y i 1 , . . . , y i n ) is a n-dimensional vector where each element represents whether X i has certain attribute or not. For example, in the case of labels with three candidates [Bangs, Eyeglasses, Smiling], the facial image X i whose label is Y i = (1, 0, 1) should depict a smiling face with bangs and no eyeglasses.

3.1. MODEL:

As shown in Figure 1 , DNA-GAN is mainly composed of three parts: an encoder (Enc), a decoder (Dec) and a discriminator (D). The encoder maps the real-world images A and B into two latent disentangled representations

Enc(A) = [a 1 , . . . , a i , . . . , a n , z a ], Enc(B) = [b 1 , . . . , b i , . . . , b n , z b ] (1)

where [a 1 , . . . , a i , . . . , a n ] is called the attribute-relevant part, and z a is called the attribute-irrelevant part. a i is supposed to be a DNA piece that controls y i , the i-th attribute in the label, and z a is for keeping other silent factors which do not appear in the attribute list as well as image identity information. The same thing applies for Enc(B). We focus on one attribute each time in our framework. Let's say we are at i-th attribute. A and B are required to have different labels, i.e. (y A 1 , . . . , 1 A i , . . . , y A n ) and (y B 1 , . . . , 0 B i , . . . , y B n ), respectively. In our convention, A is always for the dominant pattern, while B is for the recessive pattern. We copy Enc(A) directly as the latent representation of A 1 , and annihilate b i in the copy of Enc(B) as the latent representation of B 1 . The annihilating operation means replacing all elements with zeros, and plays a key role in disentangling the attribute, which we will discuss in detail in Section 3.3. By swapping a i and 0 i , we obtain two new latent representations [a 1 , . . . , 0 i , . . . , a n , z a ] and [b 1 , . . . , a i , . . . , b n , z b ] that are supposed to be decoded into A 2 and B 2 , respectively. Though a decoder Dec, we can get four newly generated images A 1 , B 1 , A 2 and B 2 .

Dec([a 1 , . . . , a i , . . . , a n , z a ]) = A 1 , Dec([b 1 , . . . , 0 i , . . . , b n , z b ]) = B 1 Dec([a 1 , . . . , 0 i , . . . , a n , z a ]) = A 2 , Dec([b 1 , . . . , a i , . . . , b n , z b ]) = B 2 (2)

Out of these four children, A 1 and B 1 are reconstructions of A and B, while A 2 and B 2 are novel crossbreeds. The reconstruction losses between A and A 1 , B and B 1 ensure the quality of reconstructed samples. Besides, using an adversarial discriminator D that helps make generated samples A 2 indistinguishable from B, and B 2 indistinguishable from A, we can enforce attribute-related information to be encoded in a i .

3.2. LOSS FUNCTIONS:

Given two images A and B and their labels Y A = (y A 1 , . . . , 1 A i , . . . , y A n ) and Y B = (y B 1 , . . . , 0 B i , . . . , y B n ) which are different at the i-th position, the data flow can be summarized by ( 1) and (2). We force the i-th latent encoding of B to be zero in order to prevent from trivial solutions as we will discuss in Section 3.3.

The encoder and decoder receive two types of losses: (1) the reconstruction loss,

L reconstruct = A -A 1 1 + B -B 1 1

(3) which measures the reconstruction quality after a sequence of encoding and decoding;

(2) the standard GAN loss,

EQUATION

which measures how realistic the generated images are. The discriminator takes the generated image and the i-th element of its label as inputs, and outputs a number which indicates how realistic the input image is. The larger the number is, the more realistic the image is. Omitting the coefficient, the loss function for the encoder and decoder is

EQUATION

The discriminator D receives the standard GAN discriminator loss

EQUATION

EQUATION

where L D1 drives D to tell A from B 2 , and L D0 drives D to tell B from A 2 .

3.3. ANNIHILATING OPERATION PREVENTS FROM TRIVIAL SOLUTIONS:

Through experiments, we observe that there exist trivial solutions to our model without the annihilating operation. We just take the single-attribute case as an example. Suppose that Enc(A) = [a, z a ] and Enc(B) = [b, z b ], we can get four children without annihilating operation

EQUATION

The reconstruction loss makes it invertible between the latent encoding space and image space. The adversarial discriminator D is supposed to disentangle the attribute from other information by telling whether A 2 looks as real as B and B 2 looks as real as A or not. As we know that the generative adversarial networks give the best solution when achieving the Nash equilibrium. But without the annihilating operation, information of the whole image could be encoded into the attribute-relevant part, which means

EQUATION

Therefore, we obtain the following four children

EQUATION

In this situation, the discriminator D cannot discriminate A 2 from B, since they share the same latent encodings. By reconstruction loss, A 2 and B are exactly the same image, which is against our expectation that A 2 should depict the person from A with the attribute borrowed from B. The same thing happens to B 2 and A as well.

To prevent from learning trivial solutions, we adopt the annihilating operation by replacing the recessive pattern b with a zero tensor of the same size1 . If information of the whole image were encoded into the attribute-relevant part, the four children in this case are

EQUATION

The encodings of B 1 and A 2 contain no information at all, thus neither the person in B 1 nor A 2 who is supposed to be the same as in B can be reconstructed by Dec. This forces the attribute-irrelevant part to encode some information of images.

3.4. ITERATIVE TRAINING:

To reduce the difficulty of disentangling multiple attributes, we take the strategy of iterative training: we update our model using a pair of images with opposite labels at a certain position each time. Suppose that we are at the i-th position, the label of image A is (y A 1 , . . . , 1 A i , . . . , y A n ), while the label of image B is (y B 1 , . . . , 0 B i , . . . , y B n ). During each iteration, as i goes through from 1 to n repeatedly, our model fed with such a pair of images can disentangle multiple attributes one-by-one.

Compared with training with random pairs of images, iterative training is proved to be more effective. Random pairs of images means randomly selecting pairs of images each time without label constraints. A pair of images with different labels is called a useful pair.

We theoretically show that our iterative training is much more efficient than random image pairs especially when the dataset is unbalanced. All proofs can be found in the Appendix. Theorem 1. Let X = {(X 1 , Y 1 ), . . . , (X m , Y m )} denote the whole multi-attribute image dataset, where X i is a multi-attribute image and its label Y i = (y i 1 , . . . , y i n ) is an n-dimensional vector. There are totally 2 n kinds of labels, denoted by L = {l 1 , . . . , l 2 n }. The number of images with label l i is m i , and

2 n i=1 m i = m.

To select all useful pairs at least once, the expected numbers of iterations needed for randomly selecting pairs and for iterative training are denoted by E 1 and E 2 respectively. Then,

EQUATION

where I s represents the indices of labels where the s-th element is 1, and J s represents the indices of labels where the s-th element is 0. Definition 1. (Balancedness) Define the balancedness of a dataset X described above with respect to the s-th attribute as follows:

EQUATION

)

where I s represents the indices of labels where the s-th element is 1, and J s represents the indices of labels where the s-th element is 0.

Theorem 2. We have

EQUATION

)

Specifically, E 2 ≤ E 1 holds true for all n ≤ 2.

The property of the function (ρ + 1) 2 /(2ρ) suits well with the definition of balancedness, because it attains the same value for ρ and 1/ρ, which is invariant to different labeling methods. Its value gets larger as the dataset becomes more unbalanced. The minimum is obtained at ρ = 1, which is the case of a balanced dataset.

Theorem 2 demonstrates that the iterative training mechanism is always more efficient than random pairs of images when the number of attributes met the criterion ( 16). As the dataset becomes more unbalanced, (ρ s + 1) 2 /(2ρ s ) goes larger, which means ( 16) can be more easily satisfied. More importantly, iterative training helps stabilize the training process on unbalanced datasets. For example, given a two-attribute dataset, the number of data of each kind is as follows: Table 1 : The example of an unbalanced two-attribute dataset.

Label (0, 0) (0, 1) (1, 0) (1, 1) Number of data 1 1 m m

If m 1 is a very large number, then it is highly likely that we will select a pair of images whose labels are (1, 0) and (1, 1) each time by randomly selecting pairs. We ignore the pair of images whose labels are (1, 0) and (1, 0) or (1, 1) and (1, 1), though these two cases have equal probabilities of being chosen. Because they are not useful pairs, thus do not participated in training. In this case, most of the time the model is trained with respect to the second attribute, which will cause the final learnt model less effective to the first attribute. However, iterative training can prevent this from happening, since we update our model evenly with respect to two attributes.

A B A 2 B 2 A 1 B 1

4. EXPERIMENTS:

In this section, we perform different kinds of experiments on two real-world datasets to validate the effectiveness of our methods. We use the RMSProp (Sutskever et al., 2013) optimization method initialized by a learning rate of 5e-5 and momentum 0. All neural networks are equipped with Batch Normalization (Ioffe & Szegedy, 2015) after convolutions or deconvolutions. We used Leaky Relu (Maas et al., 2013) as the activation function in the encoder. Besides, we adopt strategies mentioned in Wasserstein GAN (Arjovsky et al., 2017) for stable training. More details will be available online. We divide all images into training images and test images according to the ratio of 9:1. All of the following results are from test images without cherry-picking.

4.1. MULTI-PIE DATABASE:

The Multi-PIE (Gross et al., 2010) face database contains over 750,000 images of 337 subjects captured under 15 view points and 19 illumination conditions. We collecte all front faces images of different illuminations and align them based on 5-point landmarks on eyes, nose and mouth. All aligned images are resized into 128 × 128 as inputs in our experiments. We label the light illumination face images by 1 and the dark illumination face images by 0. As shown in Figure 2 , the illumination on one face is successfully transferred into the other face without modifying any other information in the images. This demonstrates that DNA-GAN can effectively disentangle the illumination factor from other factors in the latent space.

4.2 CELEBA DATASET CelebA (Liu et al., 2015) is a dataset composed of 202599 face images and 40 attribute binary vectors and 5 landmark locations. We use the aligned and cropped version and scaled all images down to 64 × 64. To better demonstrate the advantage of our method, we choose TD-GAN (Wang et al., 2017) and IcGAN (Perarnau et al., 2016) for comparisons.

As we mentioned before, TD-GAN requires the explicit id information in the label, thus cannot be applied to the CelebA dataset directly. To overcome this limitation, we use some channels to encode the id information in its latent representations. In our experiments, the id information is preserved when swapping the attribute information in the latent encodings. We also compared the experimental results of IcGAN with ours in the celebA dataset. The following results are obtained using the the official code and pre-trained celebA model provided by the author2 . 

5. CONCLUSION:

In this paper, we propose a supervised algorithm called DNA-GAN that can learn disentangled representations from multi-attribute images. The latent representations of images are DNA-like, consisting of attribute-relevant and attribute-irrelevant parts. By the annihilating operation and attribute hybridization, we are able to create new latent representations which could be decoded into novel images with designed attributes. The iterative training strategy effectively overcomes the difficulty of training on unbalanced datasets and helps disentangle multiple attributes in the latent space.

The experimental results not only demonstrate that DNA-GAN is effective in learning disentangled representations and image editing, but also point out its potential in interpretable deep learning, image understanding and transfer learning.

There also exist some limitations of our model. Without strong guidance on the attribute-irrelevant parts, some background information is encoded into the attribute-relevant part. As we can see in Figure 4 , the background color gets changed when swapping attributes. Besides, our model may fail when several attributes are highly correlated with each other. For example, Male and Mustache are statistically dependent, which are hard to disentangle in the latent representations. These are left as our future work.

and the number of useful pairs is k1 =k2

EQUATION

)

Therefore, the expectation to select all useful pairs at least once regardless of the s-th element in the label is

E \s = 2

i∈Is,j∈Js 

EQUATION

EQUATION

)

Proof. (of Theorem 2) We firstly show that 

:

Use tf.zeros like() in TensorFlow implementation.

https://github.com/Guim3/IcGAN

Figures and Tables:

Figure 1: DNA-GAN architecture.

Figure 2: Manipulating illumination factors on the Multi-PIE dataset. From left to right, the six images in a row are: original images A with light illumination and B with the dark illumination, newly generated images A 2 and B 2 by swapping the illumination-relevant piece in disentangled representations, and reconstructed images A 1 and B 1 .

Figure 3: The experimental results of TD-GAN and IcGAN on CelebA dataset. Three rows indicates the swapping attributes of Bangs, Eyeglasses and Smiling. For each model, the four images in a row are: two original images, and two newly generated images by swapping the attributes. The third image is generated by adding the attribute to the first one, and the fourth image is generated by removing the attribute from the second one.

Figure 4: The interpolation results of DNA-GAN. Figure 4a, 4b and 4c display the disentangled attribute subspaces spanned by any two attributes of Bangs, Eyeglasses and Smiling. Figure 4d shows the attribute subspaces spanned by several Bangs feature vectors. Besides, the top-left image in Figure 4d is outside the CelebA dataset.

Male and Smiling (h) Male and Wearing Hat (i) Male and Wearing Hat (j) Male and Wearing Hat (k) Smiling and Wearing Hat (l) Smiling and Wearing Hat (m) Smiling and Wearing Hat (n) Smiling and Wearing Hat (o) Wearing Hat and Mustache (p) Wearing Hat and Mustache

Figure 5: More experimental results of DNA-GAN.

19)Since we rotate the subscript s from 1 to n, the expected number of iterations for iterative training to select all useful pairs at least once isE 2 ≤ n • max

Table content: <table><tr><td>s=1,...,n</td><td colspan="2">E \s</td></tr><tr><td colspan="2">= 2n • max s=1,...,n</td><td>i∈Is,j∈Js</td></tr></table>

Peer review (iclr2018):
 Summary: This paper investigated the problem of attribute-conditioned image generation using generative adversarial networks. More specifically, the paper proposed to generate images from attribute and latent code as high-level representation. To learn the mapping from image to high-level representations, an auxiliary encoder was introduced. The model was trained using a combination of reconstruction (auto-encoding) and adversarial loss. To further encourage effective disentangling (against trivial solution), an annihilating operation was proposed together with the proposed training pipeline. Experimental evaluations were conducted on standard face image databases such as Multi-PIE and CelebA. == Novelty and Significance == Multi-attribute image generation is an interesting task but has been explored to some extent. The integration of generative adversarial networks with auto-encoding loss is not really a novel contribution. -- Autoencoding beyond pixels using a learned similarity metric. Larsen et al., In ICML 2016. == Technical Quality == First, it is not clear how was the proposed annihilating operation used in the experiments (there is no explanation in the experimental section). Based on my understanding, additional loss was added to encourage effective disentangling (prevent trivial solution). I would appreciate the authors to elaborate this a bit. Second, the iterative training (section 3.4) is not a novel contribution since it was explored in the literature before (e.g., Inverse Graphics network). The proof developed in the paper provides some theoretical analysis but cannot be considered as a significant contribution. Third, it seems that the proposed multi-attribute generation pipeline works for binary attribute only. However, such assumption limits the generality of the work. Since the title is quite general, I would assume to see the results (1) on datasets with real-valued attributes, mixture attributes or even relative attributes and (2) not specific to face images. -- Learning to generate chairs with convolutional neural networks. Dosovitskiy et al., In CVPR 2015. -- Deep Convolutional Inverse Graphics Network. Kulkarni et al., In NIPS 2015. -- Attribute2Image: Conditional Image Generation from Visual Attributes. Yan et al., In ECCV 2016. -- InfoGAN: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets. Chen et al., In NIPS 2016. Additionally, considering the generation quality, the CelebA samples in the paper are not the state-of-the-art. I suspect the proposed method only works in a more constrained setting (such as Multi-PIE where the images are all well aligned). Overall, I feel that the submitted version is not ready for publication in the current form.