This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

On Positive-Unlabeled Classification in GAN

Tianyu Guo1,2, Chang Xu2, Jiajun Huang2, Yunhe Wang3, Boxin Shi4,5, Chao Xu1, Dacheng Tao2
1Key Laboratory of Machine Perception (MOE), CMIC, School of EECS, Peking University, China
2UBTECH Sydney AI Centre, School of Computer Science, Faculty of Engineering, The University of Sydney, Australia
3 Huawei Noah’s Ark Lab 4National Engineering Laboratory for Video Technology, Peking University 5Peng Cheng Laboratory
{tianyuguo, shiboxin}@pku.edu.cn, [email protected], [email protected]
{c.xu, dacheng.tao}@sydney.edu.au
, [email protected]
Abstract

This paper defines a positive and unlabeled classification problem for standard GANs, which then leads to a novel technique to stabilize the training of the discriminator in GANs. Traditionally, real data are taken as positive while generated data are negative. This positive-negative classification criterion was kept fixed all through the learning process of the discriminator without considering the gradually improved quality of generated data, even if they could be more realistic than real data at times. In contrast, it is more reasonable to treat the generated data as unlabeled, which could be positive or negative according to their quality. The discriminator is thus a classifier for this positive and unlabeled classification problem, and we derive a new Positive-Unlabeled GAN (PUGAN). We theoretically discuss the global optimality the proposed model will achieve and the equivalent optimization goal. Empirically, we find that PUGAN can achieve comparable or even better performance than those sophisticated discriminator stabilization methods.

1 Introduction

Recently, deep generative models have received remarkable achievements in image generation tasks [11, 18, 21, 4]. As a representative generative model, GANs [4] approximated a target distribution via playing a min-max game. In the standard framework of GAN [4, 19], a generator takes noise vectors from a prior distribution (e.g. Gaussian distribution and normal distribution) as the input and tends to produce data that follows the distribution of the reference natural images, while the discriminator aims to distinguish the generated data from the real data. Various GAN methods have been developed in many interesting applications. For example, in the image-to-image translation task, generators in GANs map the input image to output image. Representative methods include Pix2pix [7] over paired training images and cycleGAN [26] in an unsupervised way.

In vanilla GANs, the training progress usually lacks stability, and the quality of generated images is not always satisfactory (e.g. model collapse). For instance, DCGAN [19] carefully designed the neural architectures for the generator and the discriminator to alleviate these problems. Progressive GAN [9] generated high-resolution images by progressively deepening the network. BigGAN [2] produced high-quality images by improving training methods, e.g. enlarging batch size, and truncating the latent space. WGAN [1] and WGAN-GP [5] tried to fit and optimize the Wasserstein distance to stabilize the generation process. SNGAN [17] proved the necessity and benefits of introducing Lipschitz continuity to the discriminator.

These aforementioned methods to stabilize GAN could be roughly divided into two categories: designing stable network structures and training strategies and developing new effective optimization goals. However, neither of them has stepped away from the positive-negative classification problem initially established in standard GAN. Although WGAN and WGAN-GP no longer take the discriminator as a classifier for real data and generated data, the aim of the is still to separate the real and generated data as far as possible. To the best of our knowledge, existing GAN models attempt to strictly distinguish between generated data and real data and ignore the fact that the quality of the generated samples is not the same. It is unfair to treat high-quality samples equally with low-quality samples, especially when high-quality samples are sufficiently realistic. Although there are many theoretical results proposed to justify the final equilibrium, such as vanilla GAN [4] proving the existing of the equilibrium and WGAN [1] replacing the JS divergence with the Wasserstein distance, these analysis mainly focus on the final achievement rather than the intermediate status in the training process.

In this paper, we suggest that instead of an ordinary positive and negative classification (i.e. real v.s. fake) problem, GAN is actually in the face of a positive-unlabeled classification problem. With adequate training, generated data could look real and may appear to be even more realistic than real data at times. It would then be illogical to make a stereotype of generated data as fake data. To catch up with the continuously improved quality of generated data, we thus take them as unlabeled data, which consists of low-quality data and high-quality data. These high-quality data are considered to be close to or even better than some real data. Within the framework of positive-unlabeled classification, the classification objective of standard GAN can be re-defined, and different variants can be easily obtained by considering different scoring functions (e.g. those in LSGAN [16] and HingeGAN [17]). In addition, we get rid of the class balance constraint (i.e. half of the sample are fake), and observe impressive performance improvement by increasing the share of generated data in the mini-batch. Our theoretical analysis suggests that the proposed new algorithm has a guaranteed final equilibrium. Experimental results on benchmark datasets demonstrate that we actually enjoy more stable training progress and thus achieve better generated samples.

2 Proposed Approach

In this section, we first review preliminary works about the standard Generative Adversarial Network (SGAN). Then we analyze the problem existing in GAN and define a new role for the discriminator DD. We also theoretically develop this idea into a new algorithm within the framework of SGAN, and then extended this algorithm to the general GAN, which shows the flexibility of our method.

2.1 Preliminary

GAN [4] was introduced by Goodfellow et al. (2014). It consists of two neural networks: discriminator network DD and generator network GG. The discriminator DD aims to distinguish the provided real data and the fake data generated by the generator GG. On the other hand, the generator GG aims to generate fake data that can fool the discriminator DD. Following this adversarial manner, we expect the GG can generate high-quality data in the end. Formally, the objective function of GAN can be written as

min𝐺max𝐷V(D,G)=𝔼𝒙pdata(𝒙)[logD(𝒙)]+𝔼𝒛p𝒛(𝒛)[log(1D(G(𝒛)))],\begin{split}\underset{G}{\min}\leavevmode\nobreak\ \underset{D}{\max}\leavevmode\nobreak\ V(D,G)&=\mathbb{E}_{\bm{x}\sim p_{data}(\bm{x})}[\log D(\bm{x})]\\ &+\mathbb{E}_{\bm{z}\sim p_{\bm{z}}(\bm{z})}[\log(1-D(G(\bm{z})))],\end{split} (1)

where pdatap_{data} indicates the distribution of real data, 𝒛\bm{z} is the random noise sampled from a prior distribution p𝒛p_{\bm{z}} (i.e. the Gaussian distribution), and D(𝒙)D(\bm{x}) is the predicted probability of 𝒙\bm{x} to be real by the discriminator. Since the minimax objective function might lead to gradient vanishing for GG when DD can perfectly distinguish two data set. More of GAN’s variants (e.g. WGAN [1] and LSGAN [15]) transform this minimax game into a non-saturating game. In general, the objective functions of these GANs can be concluded as follows:

min𝐺max𝐷V(D,G)=𝔼𝒙pdata(𝒙)[f1(D(𝒙))]𝔼𝒛p𝒛(𝒛)[f2(D(G(𝒛)))],\begin{split}\underset{G}{\min}\leavevmode\nobreak\ \underset{D}{\max}\leavevmode\nobreak\ V(D,G)&=\mathbb{E}_{\bm{x}\sim p_{data}(\bm{x})}[f_{1}(D(\bm{x}))]\\ &-\mathbb{E}_{\bm{z}\sim p_{\bm{z}}(\bm{z})}[f_{2}(D(G(\bm{z})))],\end{split} (2)

where f1f_{1} is the loss of classifying input as real and f2f_{2} is the loss of classifying input as fake.

2.2 Problem Analysis

As shown above, existing GAN variants are trained to separate the real and generated data strictly. However, this does not match the actual situation in training. Some of the generated samples can achieve higher quality and are more realistic than others. This phenomenon usually lasts until the end of the training. As a result, the quality of samples generated by GG is very different, and there are many high-quality samples and a considerable proportion of low-quality samples. For instance, as a well-known problem in GAN, the model collapse problem that GG networks often suffer can be considered as the generation space consisting of some high quality and non-repetitive samples and the rest of the repetitive samples. These duplicate samples can be considered as low-quality samples and still need to be improved. There is still a phenomenon that there is a certain proportion of unsatisfactory samples in a well-trained generation space, and the gaps in the generated samples of different quality are relatively large. Therefore, the traditional method of strictly distinguishing the real sample from the generated sample does not conform to the actual situation of the training. In this paper, we propose an algorithm that is dedicated to picking out low-quality samples from the samples generated by GG and promoting them, unlike traditional discriminators DD that are dedicated to distinguishing real samples from generated samples. Our algorithm encourages the discriminator DD to divide the generation space of GG into high-quality samples and low-quality samples so that the generator GG could improve the low-quality samples.

By doing so, the proposed method enjoys several desired properties: i) The discriminator pays more attention to poor quality samples, allowing the generator to focus on improving the quality of these bad samples. As a result, the quality of generated samples is more balanced, and the overall quality is expected to be enhanced, ii) The training strategy of our algorithm is more in line with the actual situation of samples generated by GG in the training process, so the training process is expected to be more stable, iii) More importantly, the proposed algorithm is a flexible method which means that our algorithm could be easily integrated into existing frameworks of variety GAN, and we will show this desirable feature in the following subsection, and iv) Although the proposed method changes the function of the D network, we provide some theoretical results in Section 3 which demonstrate the proposed method also enjoys the same equilibrium condition with the other GAN and provide some guarantee for performance.

2.3 Positive-Unlabeled classification (PU) in SGAN

Above, we discuss the current problem existing in the GAN framework and propose to allow some good samples to be recognized as real data. In this part, we firstly introduce how we achieve this in the framework of standard GAN, and then we extend it for general GANs.

As mentioned above, we propose to allow the discriminator DD to treat the high-quality generated samples as real data and focus on the bad generated samples. The discriminator DD is required to learn how to distinguish high-quality samples with other low-quality samples. Identifying high-quality samples from generated samples under the guidance of real samples is very similar to Positive-Unlabeled classification problems [3, 12, 23], where only some positive samples were labeled, and the classifier tried to find positive samples from unlabeled samples consisting of positive and negative samples. According to the solution of the PU classification problem, we develop an algorithm learning a discriminator to recognize high-quality samples. Firstly, we denote the generated data as 𝒙g\bm{x}_{g}, consisted with high-quality samples 𝒙gr\bm{x}_{gr} and the bad samples 𝒙gf\bm{x}_{gf}. And we consider both 𝒙gr\bm{x}_{gr} and real data 𝒙data\bm{x}_{data} to be real (i.e. ygr=ydata=1y_{gr}=y_{data}=1) while consider 𝒙gf\bm{x}_{gf} to be fake (i.e. ygf=1y_{gf}=-1). In addition, denote p(x)p(x) as the marginal density of 𝒙g\bm{x}_{g} and pgr(𝒙)=p(𝒙|1)p_{gr}(\bm{x})=p(\bm{x}|1) and pgf(𝒙)=p(𝒙|1)p_{gf}(\bm{x})=p(\bm{x}|-1) are the class conditional densities of 𝒙gr\bm{x}_{gr} and 𝒙gf\bm{x}_{gf} respectively. Then the pgp_{g} which is the marginal density of xgx_{g}, can be obtained with:

pg(𝒙)=πpgr(𝒙)+(1π)pgf(𝒙),p_{g}(\bm{x})=\pi p_{gr}(\bm{x})+(1-\pi)p_{gf}(\bm{x}), (3)

where π\pi is the unknown class prior (i.e., the proportion of 𝒙gr\bm{x}_{gr} in 𝒙g\bm{x}_{g}). Now we successfully seperate the generated space pgp_{g} into two parts. To classify xgrx_{gr} and xgfx_{gf} from 𝒙g\bm{x}_{g} with DD as a binary classifier learned the distribution of 𝒙g\bm{x}_{g} from pp, we need to minimize its expected miss-classification rate R(D)R(D). The loss function for minimizing R(D)R(D) by a given π\pi could be:

min𝐷R(D)=π𝔼xpgr(𝒙)[(D(𝒙),1)]+(1π)𝔼𝒙pgf(𝒙)[(D(𝒙),1)],\begin{split}\underset{D}{\min}R(D)&=\pi\mathbb{E}_{x\sim p_{gr}(\bm{x})}[\ell(D(\bm{x}),1)]\\ &+(1-\pi)\mathbb{E}_{\bm{x}\sim p_{gf}(\bm{x})}[\ell(D(\bm{x}),-1)],\end{split} (4)

where (D(𝒙),t)\ell(D(\bm{x}),t) is the loss function measuring the loss of prediction D(x)D(x) when the ground true label is tt. However, we has less idea about which is 𝒙gr\bm{x}_{gr}. In our definition, the good samples are similar to the real data, which means that pgrp_{gr} can be replaced by pdatap_{data}. Thus, the pg(𝒙)p_{g}(\bm{x}) can be calculated by:

pg(𝒙)=πpdata(𝒙)+(1π)pgf(𝒙).p_{g}(\bm{x})=\pi p_{data}(\bm{x})+(1-\pi)p_{gf}(\bm{x}). (5)

Similarity, the bad generated samples xgfx_{gf} are also unknown, and we can only access the generated samples 𝒙g\bm{x}_{g} and the real data 𝒙data\bm{x}_{data}. R(D)R(D) should be modified to avoid the term of pgfp_{gf}. From Eq. (5), the low-quality part pgfp_{gf} can be expressed as follows,

(1π)pgf(𝒙)=pg(𝒙)πpdata(𝒙).\begin{split}(1-\pi)p_{gf}(\bm{x})=p_{g}(\bm{x})-\pi p_{data}(\bm{x}).\end{split} (6)

Then we can find out the follow equation:

(1π)𝔼pgf[(D(𝒙),1)]=𝔼pg[(D(𝒙),1)]π𝔼pdata[(D(𝒙),1)].\begin{split}(1-\pi)\mathbb{E}_{p_{gf}}[\ell(D(\bm{x}),-1)]&=\mathbb{E}_{p_{g}}[\ell(D(\bm{x}),-1)]\\ &-\pi\mathbb{E}_{p_{data}}[\ell(D(\bm{x}),-1)].\end{split} (7)

By combining Eqs. (4) and (7), the new objective function will be:

min𝐷R(D)=π𝔼pdata[(D(𝒙),1)]+𝔼pg[(D(𝒙),1)]π𝔼pdata[(D(𝒙),1)].\begin{split}\underset{D}{\min}\leavevmode\nobreak\ R(D)&=\pi\mathbb{E}_{p_{data}}[\ell(D(\bm{x}),1)]\\ &+\mathbb{E}_{p_{g}}[\ell(D(\bm{x}),-1)]-\pi\mathbb{E}_{p_{data}}[\ell(D(\bm{x}),-1)].\end{split} (8)
Algorithm 1 Implmeneting PU learning in GAN
0:  The number of DD iterations pre GG iteration ndn_{d} (nd=1n_{d}=1 in normal), the batch size mm, the class prior knowledge π\pi for the proportion of positive data in unlabeled data.
0:  Initialize the parameters θg\theta_{g} of the generator GG and the parameters θd\theta_{d} of the discriminator DD.
  while θg\theta_{g} has not converged do
     for t=1,,ndt=1,...,n_{d} do
        Randomly sample {𝒙i}i=1mpdata(𝒙)\{\bm{x}^{i}\}_{i=1}^{m}\sim p_{data}(\bm{x});
        Randomly sample {𝒛i}i=1mpz(𝒛)\{\bm{z}^{i}\}_{i=1}^{m}\sim p_{z}(\bm{z});
        Sample {𝒛(i)}i=1mz\{\bm{z}^{(i)}\}_{i=1}^{m}\sim\mathbb{P}_{z}
        Calculate R^p+1mi=1m[f1(D(𝒙i))]\widehat{R}_{p}^{+}\leftarrow\frac{1}{m}\sum_{i=1}^{m}[f_{1}(D(\bm{x}^{i}))]
        Calculate R^p1mi=1m[f2(D(𝒙i))]\widehat{R}_{p}^{-}\leftarrow\frac{1}{m}\sum_{i=1}^{m}[f_{2}(D(\bm{x}^{i}))]
        Calculate R^u1mi=1m[f2(D(G(𝒛i)))]\widehat{R}_{u}^{-}\leftarrow\frac{1}{m}\sum_{i=1}^{m}[f_{2}(D(G(\bm{z}^{i})))]
        Update θdθdπR^p++max(0,R^uπR^p)\theta_{d}\leftarrow\nabla_{\theta_{d}}\pi\widehat{R}_{p}^{+}+max(0,\widehat{R}_{u}^{-}-\pi\widehat{R}_{p}^{-})
     end for
     Randomly sample {zi}i=1mpz(z)\{z^{i}\}_{i=1}^{m}\sim p_{z}(z);
     Update θgθg1mi=1m[f2(D(G(zi)))]\theta_{g}\leftarrow-\nabla_{\theta_{g}}\frac{1}{m}\sum_{i=1}^{m}[f_{2}(D(G(z^{i})))]
  end while
  A generator network GG.

By minimizing Eq. (8), the discriminator DD can distinguish not only 𝒙gr\bm{x}_{gr} but also 𝒙data\bm{x}_{data} from 𝒙gf\bm{x}_{gf}, by only learning the distribution of 𝒙data\bm{x}_{data} based on pdatap_{data} and distribution of 𝒙g\bm{x}_{g} (the generated samples) from pgp_{g}. We notice that the second and third terms of Eq. (8) are introduced from Eq. (6) and aim to calculate the loss over pgfp_{gf}. The original loss (1π)𝔼pgf[(D(𝒙),1)](1-\pi)\mathbb{E}_{p_{gf}}[\ell(D(\bm{x}),-1)] is expected to be not less than zero, but the replacement loss function 𝔼pg[(D(𝒙),1)]π𝔼pdata[(D(𝒙),1)]\mathbb{E}_{p_{g}}[\ell(D(\bm{x}),-1)]-\pi\mathbb{E}_{p_{data}}[\ell(D(\bm{x}),-1)], may be negative. This abnormal value of loss may lead to over-fitting. It is important to avoid the it to be negative. Finally, the objective function of discriminator proposed in Eq. (8) will be:

max𝐷V(D)=π𝔼pdata[log(D(𝒙))]+max{0,𝔼pz[log(1D(G(𝒛)))]π𝔼pdata[log(1D(𝒙))]}.\begin{split}\underset{D}{\max}\leavevmode\nobreak\ V(D)&=\pi\mathbb{E}_{p_{data}}[\log(D(\bm{x}))]\\ &+\max\{0,\mathbb{E}_{p_{z}}[\log(1-D(G(\bm{z})))]\\ &-\pi\mathbb{E}_{p_{data}}[\log(1-D(\bm{x}))]\}.\end{split} (9)

Here we obtain the proposed objective function of the discriminator. Considering there is also an adversarial game between the discriminator DD and the generator GG, the generator GG should still be trained to deceive the discriminator DD. As a result, we can easily lead to the objective function of GG as follows,

min𝐺V(G)=𝔼pz[log(1D(G(𝒛)))].\begin{split}\underset{G}{\min}\leavevmode\nobreak\ V(G)&=\mathbb{E}_{p_{z}}[\log(1-D(G(\bm{z})))].\end{split} (10)

Following Eqs. (9) and (10), we reached our objective to deal with the generated data in different ways, rather than treating it all as negative samples. Although we finally got a new loss function, in the next section, we theoretically prove that our proposed algorithm is also designed to minimize the distance between the generated distribution and the real distribution, which provides a theory for the effectiveness of our algorithm.

2.4 PU classification for general GANs

Above we conclude our objective function within the standard GAN framework. The proposed method can also be integrated into other general GAN frameworks flexibly. In this part, we combine the proposed method with other loss functions of discriminator in GAN.

In general, the objective function Eq. (2) contains two loss functions f1f_{1} and f2f_{2}. Those concrete loss functions can be changed for a different variance of GANs, but all these loss functions are following the same concepts that f1(𝒙)f_{1}(\bm{x}) and f2(𝒙)f_{2}(\bm{x}) are trying to separate the real data from the generated data as far as possible. Similar to SGAN, we propose that the discriminator in GAN is better to focus on generated samples with low quality and recognize the high-quality samples from the generated samples. Following this concept, we implement the proposed method for the general framework of GAN with the following equation:

max𝐺min𝐷V(D,G)=π𝔼pdata[f1(D(𝒙))]+max{0,𝔼pz[f2(D(G(𝒛)))]π𝔼pdata[f2(D(𝒙)]}.\begin{split}\underset{G}{\max}\leavevmode\nobreak\ \underset{D}{\min}\leavevmode\nobreak\ V(D,G)&=\pi\mathbb{E}_{p_{data}}[f_{1}(D(\bm{x}))]\\ &+\max\big{\{}0,\mathbb{E}_{p_{z}}[f_{2}(D(G(\bm{z})))]\\ &-\pi\mathbb{E}_{p_{data}}[f_{2}(D(\bm{x})]\big{\}}.\end{split} (11)

With the help of Eq. (11), we can now integrate the proposed method into various frameworks of GAN, such as WGAN-GP [20], LSGAN [15], and SpectualGAN [17]. This flexibility that combining with other models provides the proposed method a chance to get further improvement on existing excellent models. Loss functions corresponding to the specific model can be found in the supplementary material.

3 Theoretical Analysis

In the proposed method, the discriminator DD is encouraged to not only distinguish the real samples from the generated samples but also allow a certain proportion of generated samples of high quality to be recognized as real data, which reduces the instability problem during the training progress. Following this principle, we have obtained a novel loss function Eq. (9) and Eq. (10) in the framework of the standard GAN. Although Eq. (9) and Eq. (10) are designed to achieve the above-mentioned desirable characteristics, it is unclear whether the final convergence of the proposed method satisfies the requirements of the generation task. In this section, we provide a formal technical analysis of the convergence of the proposed objective function and prove that the proposed algorithm will perfectly lead the generated distribution to the real one. See the supplementary material for proof.

Now we consider the standard GAN based framework and analyze the optimal discriminator and generator. The discriminator DD is optimized by Eq. (9). Following the analysis proposed in GAN [4], the optimal distribution DD will balance between the true distribution pdatap_{data} and the learned distribution pgfp_{gf}.

Theorem 1.

For the generator GG fixed, the optimal discriminator DD is

D(𝒙)=pdata(𝒙)pdata(𝒙)+1ππpgf(𝒙),\begin{split}D^{*}(\bm{x})=\frac{p_{data}(\bm{x})}{p_{data}(\bm{x})+\frac{1-\pi}{\pi}p_{gf}(\bm{x})},\end{split}

where pgf(𝐱)p_{g}f(\bm{x}) is the distribution of low-quality generated samples of GG.

With the optimal discriminator DD fixed, we can reformulate the objective function by replacing D(𝒙)D(\bm{x}) in Eq. (10) according to Theorem 1. By doing so, we can summarize the behavior of GG in the following theorem.

Theorem 2.

With the optimal discriminator DD fixed, the optimization of generator GG is equivalent to minimize πlogπ+πKL(pdata||pg)+(1π)KL(pgf||pg)\pi\log\pi+\pi KL(p_{data}||p_{g})+(1-\pi)KL(p_{gf}||p_{g}).

Theorem 2 suggests that the optimal generator GG will pay attention to reducing the divergence within the generated space by minimizing the distance between pgp_{g} and pgfp_{gf}. Moreover, the generator will also guide the generated distribution pgp_{g} as close as possible to the real distribution pdatap_{data}, which ensures the quality of the generated sample. Combining Theorem 1 and Theorem 2, we can summarize the following corollary.

Refer to caption
Figure 1: Generated samples obtained by the proposed method on image datasets.
Table 1: Performance comparison on several benchmark datasets.
Loss SGAN PUSGAN HingeGAN PUHingeGAN LSGAN PULSGAN WGAN-GP PUWGAN-GP
MNIST 18.65 16.53 21.48 16.91 13.47 13.96 17.42 14.77
Fashion 25.72 24.33 28.39 25.31 32.05 26.72 26.50 23.12
CIFAR-10 43.39 31.02 43.85 36.37 27.64 22.32 36.86 31.85
CelebA-64 48.44 43.89 46.13 43.94 51.67 47.80 36.09 35.72
CAT-64 46.13 16.90 29.52 25.72 57.22 26.79 21.86 17.35
Corollary 1.

The global minimum of the proposed objective function V(G,D)V(G,D) is achieved if and only if pgf=pg=pdatap_{gf}=p_{g}=p_{data}. At that point, C(G)C(G) achieves the value of πlogπ\pi\log\pi, and D(𝐱)D(\bm{x}) achieves the value of π\pi.

The above theoretical results prove that the proposed method will achieve equilibrium if and only if pg=pdatap_{g}=p_{data}, which points out that our method enjoys the same global equilibrium point as other GAN frameworks. These results justify our approach. The next experiment section further illustrates the effectiveness of our approach.

4 Experiment

In this section, we evaluate the proposed method on a range of datasets including MNIST [14], FMNIST [22], CIFAR-10 [13], CAT [25], and LSUN-bedroom [24]. We resize images in the MNIST and FMNIST datasets to 32×3232\times 32 for convenience. For these datasets with more than one kind of resolution, we mark them with the resolution, such as CAT-64. Experiments on CAT-128, CAT-256, CelebA-128, and LSUN-128 datasets are also conducted to evaluate the high-resolution generation ability of the proposed approach. Moreover, due to the limitation of computational resource, for LUSN-128 we randomly sample 100,000 images from the dataset as training set, instead of using all of them. The experiment is implemented in pytorch, and we use FID (Fréchet Inception Distance) as the quantitative indicator to evaluate the performance based the quality of the generated results (lower value of FID indicating higher generated quality). FID scores are calculated with 10,000 generated samples and 10,000 real images randomly sampled from the dataset in advance.

As mentioned in Section 2, our approach enjoys a high degree of flexibility can be integrated into most kind of GAN frameworks. We chose some variants of GAN as basic frameworks, such as standard GAN (SGAN) [4], LSGAN [15], WGAN-GP [5], and HingeGAN [17], and then integrate our method into these frameworks for comparison. For a fair comparison, we follow the same settings and architectures of GANs when we integrate our method and make sure the loss functions are the only changed part. We also compare our method with Relativistic GAN [8], which is another flexible GAN framework, and we use the average version (RaGAN) in the experiment. All objective function of the proposed frameworks could be found in the supplementary material.

All models used in experiments will be trained with Adam optimizer [10], and the random selecting seed is set to 1. In addition, the discriminator follows the CNN structure described by Miyato, et al. (2018) [17] while the generator will follow the structure of standard DCGAN [19] for all models generating images whose resolution less than 128 except WGAN-GP whose structure we leave in the Supplementary material. We use the stable setting for DCGAN [19] as the basic setting for training, which the learning rate lrlr is set to 0.0002, the β1=0.5\beta_{1}=0.5 and β2=0.999\beta_{2}=0.999 for Adam optimizer, and the number of training time for discriminator and generator will both equal to 1. In addition, batch normalization [6] is also implemented. Moreover, we set a general case for the hyper-parameter π\pi growth pattern called the basic pattern in this experiment. The basic pattern will be initialized π\pi with 0.1 and will increase smoothly at each iteration until it reaches 0.7. Detailed network structures used on other datasets could be found in the supplementary material.

Table 2: Stability experiment results (reported by FID) on the CAT dataset with three resolution.
Loss Min Max Mean SD Min Max Mean SD Min Max Mean SD
64×\times64 images (N=9304) 128×\times128 images (N=6645) 256×\times256 images (N=2011)
SGAN 19.32 95.31 48.36 33.92 - - - - - - - -
RaSGAN 19.11 42.20 32.39 7.53 23.18 38.74 26.12 5.66 33.67 133.94 60.42 23.66
PUSGAN 12.71 18.99 16.38 1.99 17.76 28.91 23.61 3.43 35.75 63.68 50.76 9.9
LSGAN 21.84 69.03 39.22 13.64 22.75 62.39 43.48 12.68 - - - -
RaLSGAN 15.73 25.20 19.85 4.47 16.52 43.87 23.74 7.33 42.02 282.15 72.32 86.11
PULSGAN 12.86 26.79 21.28 4.36 18.27 38.52 26.24 6.06 33.23 269.27 73.68 89.04
WGAN-GP 17.73 31.62 24.61 5.19 21.91 43.06 34.48 8.24 58.31 262.24 109.21 64.38
RaSGAN-GP 16.83 24.32 20.59 2.84 18.78 44.53 31.63 10.04 39.42 115.07 69.65 24.19
PUWGAN-GP 13.60 20.67 17.13 1.73 17.32 36.17 27.32 5.52 35.29 93.48 59.01 17.71

4.1 Quantitative Image Generation Results

In this section, we evaluate the generation ability of the proposed method on multi-category image sets MNIST [14], FMNIST [22], and CIFAR-10 [13] and single-category image sets CAT [25] and LSUN-bedroom [24]. In this part, the resolution of images in the MNIST, FMNIST, and CIFAR-10 is 32 and is 64 in the rest datasets. We choose four representative adversarial models SGAN, HingeGAN, LSGAN, and WGAN-GP as basic frameworks and compare them with our algorithms, which are denoted as PUSGAN, PUHingeGAN, PULSGAN, and PUWGAN-GP, respectively.

Table 1 reports a comparison of the FID score obtained by the proposed method and basic models. Our models enjoy the ability to combine with most variants of GAN, which allows us to achieve the best performance on most data sets. Table 1 shows that most of our methods exceed their corresponding basic frameworks, which demonstrates the effectiveness and the flexibility of our approach. In Figure 1, we show a few images generated by the PUSGAN models. We observe that the proposed method generates high-quality images on various datasets, which is consistent with the quantitative results in Table 1.

Table 3: Performance comparison based on FID on the CIFAR-10 dataset with different settings.
Loss basic lr=.001lr=.001 No BN Tanh
SGAN 43.39 74.75 47.83 57.42
RaSGAN 33.63 44.67 42.21 55.38
PUSGAN 31.02 40.93 37.85 54.70
LSGAN 27.64 56.36 40.81 68.40
RaLSGAN 23.48 35.75 37.28 55.92
PULSGAN 22.32 37.65 37.34 51.45
HingeGAN 43.85 41.66 39.57 58.43
RaHingeGAN 38.03 44.25 41.54 51.70
PUHingeGAN 36.37 35.60 38.09 50.84

4.2 Evaluating Stability

We evaluate the stability of the proposed method on three resolution of the CAT dataset, such as 64 ×\times 64, 128 ×\times 128, and 256 ×\times 256 pixels. As there are only 6654 and 2011 samples in the CAT-128 dataset and CAT-256 dataset respectively, some variants of GAN are unable to converge on these datasets. We choose SGAN, LSGAN, and WGAN-GP as basic models. We compare the proposed method with both these basic models as well as the corresponding Relativistic GAN (RaGAN). For each model, We calculate the FID score of the current model every 10,000 iterations. The results will be presented with the minimum, maximum, mean, and standard deviation (SD) of these obtained FID values. Table 2 shows the FID results for different networks in different resolutions of data sets.

For 64×\times64 resolution dataset, all models trained by the proposed method except PULSGAN, can achieve much lower FID in minimum, maximum and mean compared with its original version and even can further achieve lower FID values than their relativistic versions, which indicates that our algorithm can effectively improve the training stability and improve the quality of the generation.

For higher resolution data sets, SGAN failed to converge in 128x128 and 256x256 resolution datasets while LSGAN will be stuck at the early stage in 256x256 resolution dataset [8]. The standard version of our model (PUSGAN) shows further stability with lower values of maximum, mean, and SD in all three resolution datasets. On the most challenging 256 resolution dataset, the proposed method achieves both the satisfactory quality and stability. In experiments, we found that although the PULSGAN can converge in the CAT-256 dataset, the convergence is much slower than other GANs. Nevertheless, PULSGAN still can achieve competitive results compared with other states of arts GANs such as WGAN-GP and RaGAN.

Overall, our algorithm presents desirable stability for all three data sets, and it can achieve similar or even better results compare to relativistic versions. It is impressive that all these GANs trained by the proposed method have improved. As a result, we conclude that the above stability experiment demonstrates that the proposed method provides could provide stability for the training progress for a variety of GANs and thus improve the quality of generated images.

Refer to caption
Figure 2: High-resolution generated samples.
Refer to caption
Figure 3: High-resolution generated samples.

4.3 Evaluating on Hard Training Setting

As we have claimed, our approach focuses on improving low-quality samples and lead to more stable training progress. Thus our approach enjoys the ability to generalize to many training settings. To demonstrate this, we evaluate the proposed method on several hard training settings and compare it with the other GAN frameworks. In this part, we implement SGAN (RaSGAN, PUSGAN), LSGAN (RaLSGAN, PULSGAN), and HingeGAN (RaHingeGAN, PUHingeGAN) on the CIFAR-10 dataset. The experiment is conducted on one basic setting and three hard settings. The basic setting is same as above, and three hard settings are i) changing learning rate to 0.0010.001 (lr=.001), ii) removing Batch normalization layers in GG and DD (No BN), and iii) replacing all activation functions with Tanh in GG and DD (Tanh).

The results are showed in Table 3. In the stable setting, we can find that the PUSGAN has better performance than SGAN and its other variants. The PUHingeGAN has a huge improvement compared with the original HingeGAN with a gap of 14, and it also performs better than RaHingeGAN. On the other hands, the performance of PULSGAN is slightly worse than other LSGAN versions.

When the learning rate is increased to 0.001, all three PU versions of GANs perform well, compared with the original one. While PUSGAN and PUHingeGAN can perform better than their relativistic versions. However, by changing optimization settings such as removing batch normalization or replace ReLU activation function with Tanh activation function (No BN and Tanh in columns respectively), the performances of PUGANs will be worse. It might indicate that the PUGANs rely on optimization terms for stable training.

4.4 High-resolution Results

Generating high-resolution images is a complicated task. To demonstrate the generation ability of our algorithm, we evaluate the proposed method on CAT-128, CelebA-128, and LSUN-128 datasets with 128 ×\times 128 pixels and the CAT-256 dataset with 256 ×\times 256 pixels. There are 202,599 images in the CelebA-128 dataset, and 3,033,042 in the LSUN-128 dataset (only 100,000 samples are used for training). As mentioned above, the CAT-128 and CAT-256 datasets are considered as more challenging high-resolution datasets because there are only 6,645 and 2,011 samples, respectively. Images shown in Figure 2 are generated by the proposed method within the architecture of SGAN (PUSGAN), while SGAN failed to generate such high-resolution images, especially on the CAT-256 dataset. Moreover, interpolation is also an impressive feature of the generative models, which indicates that the generative model successfully learns to fit the distribution of natural images instead of overfitting to the training samples. We show high-resolution interpolation results obtained by the proposed method in Figure 3. It shows that our model generates smooth interpolation images. Figures 2 and  3 demonstrate that the proposed method could provide improvement on the quality of generated samples.

Refer to caption
Figure 4: The trend of Fréchet Inception Distance (FID) of PUSGAN using different π\pi growth pattern.

4.5 Evaluating the impact of class prior π\pi

In Eq. (3), we introduce a class prior π\pi into our algorithm. The π\pi indicates the proportion of high-quality fake data in fake data, and we treat it as a hyper-parameter. In this section, we further evaluate the impact of class prior π\pi with PUSGAN framework on the CAT-64 dataset. The structure and training settings are the same as the previous sections. We set four different increasing patterns for π\pi during training. The first pattern is the basic pattern we used in previous sections. The second version will set π\pi to be 0.3 at the beginning, and it will be increased with 0.1 at every 10k iterations until 0.7 is reached. The second version is used to evaluate the impact of the fast growth of π\pi. For the third and fourth patterns, π\pi will be fixed at 0.3 and 0.5 during the training process.

In Figure 4, we found that the fast-growing pattern achieves the worst average performance, and its FID scores remain relatively high. As a comparison, the basic pattern can reach lower FID values than the fast pattern, and it is also relatively stable in the later training stage. The fixed π\pi value of 0.3 could present more stability and generate a competitive result, compared with the previous two patterns. In addition, the fourth version has the worst performance at the beginning, but it was keep going better and achieved the best performance in the end, within all four patterns. The shortage of this version mainly lies in the large fluctuations and slow convergence. It is interesting that all first three patterns have similar FID values at the early stage, while the performance with a higher π\pi is much worse at the same stage. This may be because the proportion of high-quality samples in the GG network at the beginning of training is far from 0.5, and setting π\pi to 0.5 is against the real situation, leading to an unstable training. On the other hands, the fourth one achieves a lower FID value in the end, while others have similar values at the same time. It might show a too large (e.g. 0.7), or a too small (e.g. 0.3) values of π\pi reduce the performances. The result shows that the π\pi can affect the performance of the generation. We also present the result obtained by RaGAN for comparison. It shows that all the four versions of the model obtained by our algorithm produce both higher quality images and show better stability. As a result, the proposed method enjoys considerable tolerance for the selection of hyperparameters.

Refer to caption
Figure 5: The trend of Fréchet Inception Distance (FID) of PUSGAN trained by different batch sizes of fake data.

4.6 Evaluating the impact of increasing number of fake data for training

Normally, the size of real data is much smaller than the size of the generated data in the adversarial generative task. It is an interesting problem about how to make the most of this large amount of generated data. In general training progress of GAN, the batch size of real samples and generated samples are the same. Here, we try to increase the batch size of the generated data and maintain that of the actual data to take advantage of this large number of generated samples. We investigate the impact of increasing the batch size of the generated data for training. The evaluation is based on three versions of PUSGAN with different batch sizes of fake data. The first version is the basic version that the batch size of real and fake data are the same. The second and third versions will use twice and three times more fake data than real data, respectively. The structure and training settings are the same as the one we used in previous sections. We report these interesting results Figure 5.

From results, we find that the second and third versions of PUSGAN can reach their best performance at the very beginning, which proves that PUSGAN can converge faster by increasing the batch size of fake data. Although it shows that an increase in the number of false samples can provide a small performance boost and faster convergence, it seems to be detrimental to stability. Considering the stability and for a fair comparison, we insist on using the same batch size for both the real and generated data in the above experiments.

5 Conclusion

In this paper, we present a positive-unlabeled generative adversarial network (PUGAN), where the discriminator is trained to recognize the high-quality samples from the generated data, to obtain a more stable training progress. The proposed method addresses problems in traditional methods that neglecting the gradual increase in sample quality and the imbalance of generated sample quality, which provides more stable training progress and higher generation quality. We further demonstrate that our approach has the flexibility to combine with most existing GAN frameworks without requiring the addition of computational cost. Experiments conducted on real-world image datasets suggest that the proposed method successfully improve both the stability and the quality of generated samples. We also provide some theoretical results to illustrate the justification of our approach.

References

  • [1] Martin Arjovsky, Soumith Chintala, and Léon Bottou. Wasserstein generative adversarial networks. pages 214–223, 2017.
  • [2] Andrew Brock, Jeff Donahue, and Karen Simonyan. Large scale gan training for high fidelity natural image synthesis. arXiv preprint arXiv:1809.11096, 2018.
  • [3] Marthinus C Du Plessis, Gang Niu, and Masashi Sugiyama. Analysis of learning from positive and unlabeled data. In Advances in neural information processing systems, pages 703–711, 2014.
  • [4] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in neural information processing systems, pages 2672–2680, 2014.
  • [5] Ishaan Gulrajani, Faruk Ahmed, Martin Arjovsky, Vincent Dumoulin, and Aaron C Courville. Improved training of wasserstein gans. In Advances in neural information processing systems, pages 5767–5777, 2017.
  • [6] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. arXiv preprint arXiv:1502.03167, 2015.
  • [7] Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with conditional adversarial networks. arXiv preprint, 2017.
  • [8] Alexia Jolicoeur-Martineau. The relativistic discriminator: a key element missing from standard GAN. In Proc. of International Conference on Learning Representations, 2019.
  • [9] Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of gans for improved quality, stability, and variation. arXiv preprint arXiv:1710.10196, 2017.
  • [10] Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
  • [11] Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
  • [12] Ryuichi Kiryo, Gang Niu, Marthinus C du Plessis, and Masashi Sugiyama. Positive-unlabeled learning with non-negative risk estimator. In Advances in neural information processing systems, 2017.
  • [13] Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. 2009.
  • [14] Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 1998.
  • [15] Xudong Mao, Qing Li, Haoran Xie, Raymond YK Lau, Zhen Wang, and Stephen Paul Smolley. Least squares generative adversarial networks. In Proc. of International Conference on Computer Vision, 2017.
  • [16] Xudong Mao, Qing Li, Haoran Xie, Raymond Y. K. Lau, and Zhen Wang. Multi-class generative adversarial networks with the L2 loss function. CoRR, abs/1611.04076, 2016.
  • [17] Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. arXiv preprint arXiv:1802.05957, 2018.
  • [18] Aaron van den Oord, Nal Kalchbrenner, and Koray Kavukcuoglu. Pixel recurrent neural networks. arXiv preprint arXiv:1601.06759, 2016.
  • [19] Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv preprint arXiv:1511.06434, 2015.
  • [20] Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, and Xi Chen. Improved techniques for training gans. In Advances in neural information processing systems, pages 2234–2242, 2016.
  • [21] Aaron van den Oord, Nal Kalchbrenner, Lasse Espeholt, Oriol Vinyals, Alex Graves, et al. Conditional image generation with pixelcnn decoders. In Advances in neural information processing systems, 2016.
  • [22] Han Xiao, Kashif Rasul, and Roland Vollgraf. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms, 2017.
  • [23] Yixing Xu, Chang Xu, Chao Xu, and Dacheng Tao. Multi-positive and unlabeled learning. In IJCAI, 2017.
  • [24] Fisher Yu, Yinda Zhang, Shuran Song, Ari Seff, and Jianxiong Xiao. Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop. arXiv preprint arXiv:1506.03365, 2015.
  • [25] Weiwei Zhang, Jian Sun, and Xiaoou Tang. Cat head detection-how to effectively exploit shape and texture features. In Proc. of European Conference on Computer Vision, pages 802–816. Springer, 2008.
  • [26] Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. arXiv preprint, 2017.