tensorflowGANs
各类GAN综合在一起，借鉴了hwalsuklee大神的
view repo
One of the challenges in the study of generative adversarial networks is the instability of its training. In this paper, we propose a novel weight normalization technique called spectral normalization to stabilize the training of the discriminator. Our new normalization technique is computationally light and easy to incorporate into existing implementations. We tested the efficacy of spectral normalization on CIFAR10, STL10, and ILSVRC2012 dataset, and we experimentally confirmed that spectrally normalized GANs (SNGANs) is capable of generating images of better or equal quality relative to the previous training stabilization techniques.
READ FULL TEXT VIEW PDF
Generative adversarial networks(GANs) is a popular generative model. Wit...
read it
Generative Adversarial Networks (GANs), though powerful, is hard to trai...
read it
Deep Neural Networks (DNNs) have begun to thrive in the field of automat...
read it
In this paper, we propose a novel technique for generating images in the...
read it
Spectral normalization (SN) is a widelyused technique for improving the...
read it
Despite excellent progress in recent years, mode collapse remains a majo...
read it
We present a novel adversarial framework for training deep belief networ...
read it
各类GAN综合在一起，借鉴了hwalsuklee大神的
Generative adversarial networks (GANs) Goodfellow et al. (2014) have been enjoying considerable success as a framework of generative models in recent years, and it has been applied to numerous types of tasks and datasets Radford et al. (2016); Salimans et al. (2016); Ho & Ermon (2016); Li et al. (2017)
. In a nutshell, GANs are a framework to produce a model distribution that mimics a given target distribution, and it consists of a generator that produces the model distribution and a discriminator that distinguishes the model distribution from the target. The concept is to consecutively train the model distribution and the discriminator in turn, with the goal of reducing the difference between the model distribution and the target distribution measured by the best discriminator possible at each step of the training. GANs have been drawing attention in the machine learning community not only for its ability to learn highly structured probability distribution but also for its theoretically interesting aspects. For example,
Nowozin et al. (2016); Uehara et al. (2016); Mohamed & Lakshminarayanan (2017)revealed that the training of the discriminator amounts to the training of a good estimator for the density ratio between the model distribution and the target. This is a perspective that opens the door to the methods of
implicit models Mohamed & Lakshminarayanan (2017); Tran et al. (2017) that can be used to carry out variational optimization without the direct knowledge of the density function.A persisting challenge in the training of GANs is the performance control of the discriminator. In high dimensional spaces, the density ratio estimation by the discriminator is often inaccurate and unstable during the training, and generator networks fail to learn the multimodal structure of the target distribution. Even worse, when the support of the model distribution and the support of the target distribution are disjoint, there exists a discriminator that can perfectly distinguish the model distribution from the target Arjovsky & Bottou (2017). Once such discriminator is produced in this situation, the training of the generator comes to complete stop, because the derivative of the soproduced discriminator with respect to the input turns out to be 0. This motivates us to introduce some form of restriction to the choice of the discriminator.
In this paper, we propose a novel weight normalization method called spectral normalization that can stabilize the training of discriminator networks. Our normalization enjoys following favorable properties.
Lipschitz constant is the only hyperparameter to be tuned, and the algorithm does not require intensive tuning of the only hyperparameter for satisfactory performance.
Implementation is simple and the additional computational cost is small.
In fact, our normalization method also functioned well even without tuning Lipschitz constant, which is the only hyper parameter. In this study, we provide explanations of the effectiveness of spectral normalization for GANs against other regularization techniques, such as weight normalization Salimans & Kingma (2016), weight clipping Arjovsky et al. (2017), and gradient penalty Gulrajani et al. (2017)
. We also show that, in the absence of complimentary regularization techniques (e.g., batch normalization, weight decay and feature matching on the discriminator), spectral normalization can improve the sheer quality of the generated images better than weight normalization and gradient penalty.
In this section, we will lay the theoretical groundwork for our proposed method. Let us consider a simple discriminator made of a neural network of the following form, with the input
:(1) 
where is the learning parameters set, , , and
is an elementwise nonlinear activation function. We omit the bias term of each layer for simplicity. The final output of the discriminator is given by
(2) 
where is an activation function corresponding to the divergence of distance measure of the user’s choice. The standard formulation of GANs is given by
where min and max of and are taken over the set of generator and discriminator functions, respectively. The conventional form of Goodfellow et al. (2014) is given by where is the data distribution and is the (model) generator distribution to be learned through the adversarial minmax optimization. The activation function that is used in the of this expression is some continuous function with range
(e.g, sigmoid function). It is known that, for a fixed generator
, the optimal discriminator for this form of is given by .The machine learning community has been pointing out recently that the function space from which the discriminators are selected crucially affects the performance of GANs. A number of works Uehara et al. (2016); Qi (2017); Gulrajani et al. (2017) advocate the importance of Lipschitz continuity in assuring the boundedness of statistics. For example, the optimal discriminator of GANs on the above standard formulation takes the form
(3) 
and its derivative
(4) 
can be unbounded or even incomputable. This prompts us to introduce some regularity condition to the derivative of .
A particularly successful works in this array are Qi (2017); Arjovsky et al. (2017); Gulrajani et al. (2017), which proposed methods to control the Lipschitz constant of the discriminator by adding regularization terms defined on input examples . We would follow their footsteps and search for the discriminator from the set of Lipschitz continuous functions, that is,
(5) 
where we mean by the smallest value such that for any , with the norm being the norm.
While input based regularizations allow for relatively easy formulations based on samples, they also suffer from the fact that, they cannot impose regularization on the space outside of the supports of the generator and data distributions without introducing somewhat heuristic means. A method we would introduce in this paper, called
spectral normalization, is a method that aims to skirt this issue by normalizing the weight matrices using the technique devised by Yoshida & Miyato (2017).Our spectral normalization controls the Lipschitz constant of the discriminator function by literally constraining the spectral norm of each layer . By definition, Lipschitz norm is equal to , where is the spectral norm of the matrix ( matrix norm of )
(6) 
which is equivalent to the largest singular value of
. Therefore, for a linear layer , the norm is given by . If the Lipschitz norm of the activation function is equal to 1 ^{1}^{1}1For examples, ReLU
Jarrett et al. (2009); Nair & Hinton (2010); Glorot et al. (2011) and leaky ReLU Maas et al. (2013) satisfies the condition, and many popular activation functions satisfy Lipschitz constraint for some predefined as well., we can use the inequality to observe the following bound on :(7) 
Our spectral normalization normalizes the spectral norm of the weight matrix so that it satisfies the Lipschitz constraint :
(8) 
If we normalize each using (8), we can appeal to the inequality (7) and the fact that to see that is bounded from above by .
Here, we would like to emphasize the difference between our spectral normalization and spectral norm ”regularization” introduced by Yoshida & Miyato (2017). Unlike our method, spectral norm ”regularization” penalizes the spectral norm by adding explicit regularization term to the objective function. Their method is fundamentally different from our method in that they do not make an attempt to ‘set’ the spectral norm to a designated value. Moreover, when we reorganize the derivative of our normalized cost function and rewrite our objective function (12), we see that our method is augmenting the cost function with a sample data dependent regularization function. Spectral norm regularization, on the other hand, imposes sample data independent regularization on the cost function, just like L2 regularization and Lasso.
As we mentioned above, the spectral norm that we use to regularize each layer of the discriminator is the largest singular value of
. If we naively apply singular value decomposition to compute the
at each round of the algorithm, the algorithm can become computationally heavy. Instead, we can use the power iteration method to estimate Golub & Van der Vorst (2000); Yoshida & Miyato (2017). With power iteration method, we can estimate the spectral norm with very small additional computational time relative to the full computational cost of the vanilla GANs. Please see Appendix A for the detail method and Algorithm 1 for the summary of the actual spectral normalization algorithm.The gradient^{2}^{2}2Indeed, when the spectrum has multiplicities, we would be looking at subgradients here. However, the probability of this happening is zero (almost surely), so we would continue discussions without giving considerations to such events. of with respect to is:
(9)  
(10) 
where is the matrix whose th entry is and zero everywhere else, and and
are respectively the first left and right singular vectors of
. If is the hidden layer in the network to be transformed by , the derivative of the calculated over the minibatch with respect to of the discriminator is given by:(11)  
(12) 
where , , and represents empirical expectation over the minibatch. when for some .
We would like to comment on the implication of (12). The first term is the same as the derivative of the weights without normalization. In this light, the second term in the expression can be seen as the regularization term penalizing the first singular components with the adaptive regularization coefficient . is positive when and are pointing in similar direction, and this prevents the column space of from concentrating into one particular direction in the course of the training. In other words, spectral normalization prevents the transformation of each layer from becoming to sensitive in one direction. We can also use spectral normalization to devise a new parametrization for the model. Namely, we can split the layer map into two separate trainable components: spectrally normalized map and the spectral norm constant. As it turns out, this parametrization has its merit on its own and promotes the performance of GANs (See Appendix E).
The weight normalization introduced by Salimans & Kingma (2016) is a method that normalizes the norm of each row vector in the weight matrix. Mathematically, this is equivalent to requiring the weight by the weight normalization :
(13) 
where is a th singular value of matrix . Therefore, up to a scaler, this is same as the Frobenius normalization, which requires the sum of the squared singular values to be 1. These normalizations, however, inadvertently impose much stronger constraint on the matrix than intended. If is the weight normalized matrix of dimension , the norm for a fixed unit vector is maximized at when and for , which means that is of rank one. Similar thing can be said to the Frobenius normalization (See the appendix for more details). Using such corresponds to using only one feature to discriminate the model probability distribution from the target. In order to retain as much norm of the input as possible and hence to make the discriminator more sensitive, one would hope to make the norm of large. For weight normalization, however, this comes at the cost of reducing the rank and hence the number of features to be used for the discriminator. Thus, there is a conflict of interests between weight normalization and our desire to use as many features as possible to distinguish the generator distribution from the target distribution. The former interest often reigns over the other in many cases, inadvertently diminishing the number of features to be used by the discriminators. Consequently, the algorithm would produce a rather arbitrary model distribution that matches the target distribution only at select few features. Weight clipping Arjovsky et al. (2017) also suffers from same pitfall.
Our spectral normalization, on the other hand, do not suffer from such a conflict in interest. Note that the Lipschitz constant of a linear operator is determined only by the maximum singular value. In other words, the spectral norm is independent of rank. Thus, unlike the weight normalization, our spectral normalization allows the parameter matrix to use as many features as possible while satisfying local Lipschitz constraint. Our spectral normalization leaves more freedom in choosing the number of singular components (features) to feed to the next layer of the discriminator.
Brock et al. (2016) introduced orthonormal regularization on each weight to stabilize the training of GANs. In their work, Brock et al. (2016) augmented the adversarial objective function by adding the following term:
(14) 
While this seems to serve the same purpose as spectral normalization, orthonormal regularization are mathematically quite different from our spectral normalization because the orthonormal regularization destroys the information about the spectrum by setting all the singular values to one. On the other hand, spectral normalization only scales the spectrum so that the its maximum will be one.
Gulrajani et al. (2017) used Gradient penalty method in combination with WGAN. In their work, they placed Lipschitz constant on the discriminator by augmenting the objective function with the regularizer that rewards the function for having local 1Lipschitz constant (i.e. ) at discrete sets of points of the form
generated by interpolating a sample
from generative distribution and a sample from the data distribution. While this rather straightforward approach does not suffer from the problems we mentioned above regarding the effective dimension of the feature space, the approach has an obvious weakness of being heavily dependent on the support of the current generative distribution. As a matter of course, the generative distribution and its support gradually changes in the course of the training, and this can destabilize the effect of such regularization. In fact, we empirically observed that a high learning rate can destabilize the performance of WGANGP. On the contrary, our spectral normalization regularizes the function the operator space, and the effect of the regularization is more stable with respect to the choice of the batch. Training with our spectral normalization does not easily destabilize with aggressive learning rate. Moreover, WGANGP requires more computational cost than our spectral normalization with singlestep power iteration, because the computation of requires one whole round of forward and backward propagation. In the appendix section, we compare the computational cost of the two methods for the same number of updates.In order to evaluate the efficacy of our approach and investigate the reason behind its efficacy, we conducted a set of extensive experiments of unsupervised image generation on CIFAR10 Torralba et al. (2008) and STL10 Coates et al. (2011)
, and compared our method against other normalization techniques. To see how our method fares against large dataset, we also applied our method on ILSVRC2012 dataset (ImageNet)
Russakovsky et al. (2015) as well. This section is structured as follows. First, we will discuss the objective functions we used to train the architecture, and then we will describe the optimization settings we used in the experiments. We will then explain two performance measures on the images to evaluate the images produced by the trained generators. Finally, we will summarize our results on CIFAR10, STL10, and ImageNet.As for the architecture of the discriminator and generator, we used convolutional neural networks. Also, for the evaluation of the spectral norm for the convolutional weight
, we treated the operator as a 2D matrix of dimension ^{3}^{3}3Note that, since we are conducting the convolution discretely, the spectral norm will depend on the size of the stride and padding. However, the answer will only differ by some predefined
.. We trained the parameters of the generator with batch normalization Ioffe & Szegedy (2015). We refer the readers to Table 3 in the appendix section for more details of the architectures.For all methods other than WGANGP, we used the following standard objective function for the adversarial loss:
(15) 
where is a latent variable,
is the standard normal distribution
, and is a deterministic generator function. We set to 128 for all of our experiments. For the updates of , we used the alternate cost proposed by Goodfellow et al. (2014) as used in Goodfellow et al. (2014) and WardeFarley & Bengio (2017). For the updates of , we used the original cost defined in (15). We also tested the performance of the algorithm with the socalled hinge loss, which is given by(16)  
(17) 
respectively for the discriminator and the generator. Optimizing these objectives is equivalent to minimizing the socalled reverse KL divergence : . This type of loss has been already proposed and used in Lim & Ye (2017); Tran et al. (2017). The algorithm based on the hinge loss also showed good performance when evaluated with inception score and FID. For Wasserstein GANs with gradient penalty (WGANGP) Gulrajani et al. (2017), we used the following objective function: , where the regularization term is the one we introduced in the appendix section D.4.
For quantitative assessment of generated examples, we used inception score Salimans et al. (2016) and Fréchet inception distance (FID) Heusel et al. (2017). Please see Appendix B.1 for the details of each score.
In this section, we report the accuracy of the spectral normalization (we use the abbreviation: SNGAN for the spectrally normalized GANs) during the training, and the dependence of the algorithm’s performance on the hyperparmeters of the optimizer. We also compare the performance quality of the algorithm against those of other regularization/normalization techniques for the discriminator networks, including: Weight clipping Arjovsky et al. (2017), WGANGP Gulrajani et al. (2017), batchnormalization (BN) Ioffe & Szegedy (2015), layer normalization (LN) Ba et al. (2016), weight normalization (WN) Salimans & Kingma (2016) and orthonormal regularization (orthonormal) Brock et al. (2016). In order to evaluate the standalone efficacy of the gradient penalty, we also applied the gradient penalty term to the standard adversarial loss of GANs (15). We would refer to this method as ‘GANGP’. For weight clipping, we followed the original work Arjovsky et al. (2017) and set the clipping constant at 0.01 for the convolutional weight of each layer. For gradient penalty, we set to 10, as suggested in Gulrajani et al. (2017). For orthonormal, we initialized the each weight of with a randomly selected orthonormal operator and trained GANs with the objective function augmented with the regularization term used in Brock et al. (2016). For all comparative studies throughout, we excluded the multiplier parameter in the weight normalization method, as well as in batch normalization and layer normalization method. This was done in order to prevent the methods from overtly violating the Lipschitz condition. When we experimented with different multiplier parameter, we were in fact not able to achieve any improvement.
For optimization, we used the Adam optimizer Kingma & Ba (2015) in all of our experiments. We tested with 6 settings for (1) , the number of updates of the discriminator per one update of the generator and (2) learning rate and the first and second order momentum parameters (, ) of Adam. We list the details of these settings in Table 1 in the appendix section. Out of these 6 settings, A, B, and C are the settings used in previous representative works. The purpose of the settings D, E, and F is to the evaluate the performance of the algorithms implemented with more aggressive learning rates. For the details of the architectures of convolutional networks deployed in the generator and the discriminator, we refer the readers to Table 3 in the appendix section. The number of updates for GAN generator were 100K for all experiments, unless otherwise noted.
Setting  

A^{†}  0.0001  0.5  0.9  5 
B^{‡}  0.0001  0.5  0.999  1 
C^{⋆}  0.0002  0.5  0.999  1 
D  0.001  0.5  0.9  5 
E  0.001  0.5  0.999  5 
F  0.001  0.9  0.999  5 
are the hyperparameter settings following
Gulrajani et al. (2017), WardeFarley & Bengio (2017) and Radford et al. (2016), respectively.Firstly, we inspected the spectral norm of each layer during the training to make sure that our spectral normalization procedure is indeed serving its purpose. As we can see in the Figure 9 in the C.1, the spectral norms of these layers floats around – region throughout the training. Please see Appendix C.1 for more details.
In Figures 1 and 2 we show the inception scores of each method with the settings A–F. We can see that spectral normalization is relatively robust with aggressive learning rates and momentum parameters. WGANGP fails to train good GANs at high learning rates and high momentum parameters on both CIFAR10 and STL10. Orthonormal regularization performed poorly for the setting E on the STL10, but performed slightly better than our method with the optimal setting. These results suggests that our method is more robust than other methods with respect to the change in the setting of the training. Also, the optimal performance of weight normalization was inferior to both WGANGP and spectral normalization on STL10, which consists of more diverse examples than CIFAR10. Best scores of spectral normalization are better than almost all other methods on both CIFAR10 and STL10.
In Tables 2, we show the inception scores of the different methods with optimal settings on CIFAR10 and STL10 dataset. We see that SNGANs performed better than almost all contemporaries on the optimal settings. SNGANs performed even better with hinge loss (17).^{4}^{4}4As for STL10, we also ran SNGANs over twice time longer iterations because it did not seem to converge. Yet still, this elongated training sequence still completes before WGANGP with original iteration size because the optimal setting of SNGANs (setting B, ) is computationally light.. For the training with same number of iterations, SNGANs fell behind orthonormal regularization for STL10. For more detailed comparison between orthonormal regularization and spectral normalization, please see section 4.1.2.
Method  Inception score  FID  

CIFAR10  STL10  CIFAR10  STL10  
Real data  11.24.12  26.08.26  7.8  7.9 
Standard CNN  
Weight clipping  6.41.11  7.57.10  42.6  64.2 
GANGP  6.93.08  37.7  
WGANGP  6.68.06  8.42.13  40.2  55.1 
Batch Norm.  6.27.10  56.3  
Layer Norm.  7.19.12  7.61.12  33.9  75.6 
Weight Norm.  6.84.07  7.16.10  34.7  73.4 
Orthonormal  7.40.12  8.56.07  29.0  46.7 
(ours) SNGANs  7.42.08  8.28.09  29.3  53.1 
Orthonormal (2x updates)  8.67.08  44.2  
(ours) SNGANs (2x updates)  8.69.09  47.5  
(ours) SNGANs, Eq.(17)  7.58.12  25.5  
(ours) SNGANs, Eq.(17) (2x updates)  8.79.14  43.2  
ResNet^{5}^{5}5 For our ResNet experiments, we trained the same architecture with multiple random seeds for weight initialization and produced models with different parameters. We then generated 5000 images 10 times and computed the average inception score for each model. The values for ResNet on the table are the mean and standard deviation of the score computed over the set of models trained with different seeds. 

Orthonormal, Eq.(17)  7.92.04  8.72.06  23.8.58  42.4.99 
(ours) SNGANs, Eq.(17)  8.22.05  9.10.04  21.7.21  40.1.50 
DCGAN^{†}  6.64.14  7.84.07  
LRGANs^{‡}  7.17.07  
WardeFarley et al.^{∗}  7.72.13  8.51.13  
WGANGP (ResNet)^{††}  7.86.08 
In Figure 6 we show the images produced by the generators trained with WGANGP, weight normalization, and spectral normalization. SNGANs were consistently better than GANs with weight normalization in terms of the quality of generated images. To be more precise, as we mentioned in Section 3, the set of images generated by spectral normalization was clearer and more diverse than the images produced by the weight normalization. We can also see that WGANGP failed to train good GANs with high learning rates and high momentums (D,E and F). The generated images with GANGP, batch normalization, and layer normalization is shown in Figure 12 in the appendix section.
We also compared our algorithm against multiple benchmark methods ans summarized the results on the bottom half of the Table 2. We also tested the performance of our method on ResNet based GANs used in Gulrajani et al. (2017). Please note that all methods listed thereof are all different in both optimization methods and the architecture of the model. Please see Table 8 and 5 in the appendix section for the detail network architectures. Our implementation of our algorithm was able to perform better than almost all the predecessors in the performance.
In Figure 3, we show the squared singular values of the weight matrices in the final discriminator produced by each method using the parameter that yielded the best inception score. As we predicted in Section 3
, the singular values of the first to fifth layers trained with weight clipping and weight normalization concentrate on a few components. That is, the weight matrices of these layers tend to be rank deficit. On the other hand, the singular values of the weight matrices in those layers trained with spectral normalization is more broadly distributed. When the goal is to distinguish a pair of probability distributions on the lowdimensional nonlinear data manifold embedded in a high dimensional space, rank deficiencies in lower layers can be especially fatal. Outputs of lower layers have gone through only a few sets of rectified linear transformations, which means that they tend to lie on the space that is linear in most parts. Marginalizing out many features of the input distribution in such space can result in oversimplified discriminator. We can actually confirm the effect of this phenomenon on the generated images especially in Figure
5(b). The images generated with spectral normalization is more diverse and complex than those generated with weight normalization.On CIFAR10, SNGANs is slightly slower than weight normalization (about 110 120% computational time), but significantly faster than WGANGP. As we mentioned in Section 3, WGANGP is slower than other methods because WGANGP needs to calculate the gradient of gradient norm . For STL10, the computational time of SNGANs is almost the same as vanilla GANs, because the relative computational cost of the power iteration (18) is negligible when compared to the cost of forward and backward propagation on CIFAR10 (images size of STL10 is larger ()). Please see Figure 10 in the appendix section for the actual computational time.
In order to highlight the difference between our spectral normalization and orthonormal regularization, we conducted an additional set of experiments. As we explained in Section 3, orthonormal regularization is different from our method in that it destroys the spectral information and puts equal emphasis on all feature dimensions, including the ones that ’shall’ be weeded out in the training process. To see the extent of its possibly detrimental effect, we experimented by increasing the dimension of the feature space ^{6}^{6}6More precisely, we simply increased the input dimension and the output dimension by the same factor. In Figure 4, ‘relative size’ = 1.0 implies that the layer structure is the same as the original., especially at the final layer (7th conv) for which the training with our spectral normalization prefers relatively small feature space (dimension ; see Figure 2(b)). As for the setting of the training, we selected the parameters for which the orthonormal regularization performed optimally. The figure 4 shows the result of our experiments. As we predicted, the performance of the orthonormal regularization deteriorates as we increase the dimension of the feature maps at the final layer. Our SNGANs, on the other hand, does not falter with this modification of the architecture. Thus, at least in this perspective, we may such that our method is more robust with respect to the change of the network architecture.
To show that our method remains effective on a large high dimensional dataset, we also applied our method to the training of conditional GANs on ILRSVRC2012 dataset with 1000 classes, each consisting of approximately 1300 images, which we compressed to pixels. Regarding the adversarial loss for conditional GANs, we used practically the same formulation used in Mirza & Osindero (2014), except that we replaced the standard GANs loss with hinge loss (17). Please see Appendix B.3 for the details of experimental settings.
GANs without normalization and GANs with layer normalization collapsed in the beginning of training and failed to produce any meaningful images. GANs with orthonormal normalization Brock et al. (2016) and our spectral normalization, on the other hand, was able to produce images. The inception score of the orthonormal normalization however plateaued around 20Kth iterations, while SN kept improving even afterward (Figure 5.) To our knowledge, our research is the first of its kind in succeeding to produce decent images from ImageNet dataset with a single pair of a discriminator and a generator (Figure 7). To measure the degree of modecollapse, we followed the footstep of Odena et al. (2017) and computed the intra MSSSIM Odena et al. (2017) for pairs of independently generated GANs images of each class. We see that our SNGANs ((intra MSSSIM)=0.101) is suffering less from the modecollapse than ACGANs ((intra MSSSIM)0.25).
To ensure that the superiority of our method is not limited within our specific setting, we also compared the performance of SNGANs against orthonormal regularization on conditional GANs with projection discriminator Miyato & Koyama (2018) as well as the standard (unconditional) GANs. In our experiments, SNGANs achieved better performance than orthonormal regularization for the both settings (See Figure 15 in the appendix section).
This paper proposes spectral normalization as a stabilizer of training of GANs. When we apply spectral normalization to the GANs on image generation tasks, the generated examples are more diverse than the conventional weight normalization and achieve better or comparative inception scores relative to previous studies. The method imposes global regularization on the discriminator as opposed to local regularization introduced by WGANGP, and can possibly used in combinations. In the future work, we would like to further investigate where our methods stand amongst other methods on more theoretical basis, and experiment our algorithm on larger and more complex datasets.
We would like to thank the members of Preferred Networks, Inc., particularly Shinichi Maeda, Eiichi Matsumoto, Masaki Watanabe and Keisuke Yahata for insightful comments and discussions. We also would like to thank anonymous reviewers and commenters on the OpenReview forum for insightful discussions.
Journal of Multivariate Analysis
, 12(3):450–455, 1982.Generative adversarial imitation learning.
In NIPS, pp. 4565–4573, 2016.ICML Workshop on Deep Learning for Audio, Speech and Language Processing
, 2013.Conditional image synthesis with auxiliary classifier GANs.
In ICML, pp. 2642–2651, 2017.International Journal of Computer Vision
, 115(3):211–252, 2015.80 million tiny images: A large data set for nonparametric object and scene recognition.
IEEE Transactions on Pattern Analysis and Machine Intelligence, 30(11):1958–1970, 2008.Let us describe the shortcut in Section 2.1 in more detail. We begin with vectors that is randomly initialized for each weight. If there is no multiplicity in the dominant singular values and if is not orthogonal to the first left singular vectors^{7}^{7}7In practice, we are safe to assume that
generated from uniform distribution on the sphere is not orthogonal to the first singular vectors, because this can happen with probability
. , we can appeal to the principle of the power method and produce the first left and right singular vectors through the following update rule:(18) 
We can then approximate the spectral norm of with the pair of soapproximated singular vectors:
(19) 
If we use SGD for updating , the change in at each update would be small, and hence the change in its largest singular value. In our implementation, we took advantage of this fact and reused the computed at each step of the algorithm as the initial vector in the subsequent step. In fact, with this ‘recycle’ procedure, one round of power iteration was sufficient in the actual experiment to achieve satisfactory performance. Algorithm 1 in the appendix summarizes the computation of the spectrally normalized weight matrix with this approximation. Note that this procedure is very computationally cheap even in comparison to the calculation of the forward and backward propagations on neural networks. Please see Figure 10 for actual computational time with and without spectral normalization.
Initialize with a random vector (sampled from isotropic distribution).
For each update and each layer :
Apply power iteration method to a unnormalized weight :
(20)  
(21) 
Calculate with the spectral norm:
(22) 
Update with SGD on minibatch dataset with a learning rate :
(23) 
Inception score is introduced originally by Salimans et al. (2016): , where is approximated by and is the trained Inception convolutional neural network Szegedy et al. (2015), which we would refer to Inception model for short. In their work, Salimans et al. (2016) reported that this score is strongly correlated with subjective human judgment of image quality. Following the procedure in Salimans et al. (2016); WardeFarley & Bengio (2017), we calculated the score for randomly generated 5000 examples from each trained generator to evaluate its ability to generate natural images. We repeated each experiment 10 times and reported the average and the standard deviation of the inception scores.
Fréchet inception distance Heusel et al. (2017) is another measure for the quality of the generated examples that uses 2nd order information of the final layer of the inception model applied to the examples. On its own, the Frećhet distance Dowson & Landau (1982) is 2Wasserstein distance between two distribution and
assuming they are both multivariate Gaussian distributions:
(24) 
where , are the mean and covariance of samples from and , respectively. If is the output of the final layer of the inception model before the softmax, the Fréchet inception distance (FID) between two distributions and on the images is the distance between and . We computed the Fréchet inception distance between the true distribution and the generated distribution empirically over 10000 and 5000 samples. Multiple repetition of the experiments did not exhibit any notable variations on this score.
For the comparative study, we experimented with the recent ResNet architecture of Gulrajani et al. (2017) as well as the standard CNN. For this additional set of experiments, we used Adam again for the optimization and used the very hyper parameter used in Gulrajani et al. (2017) (). For our SNGANs, we doubled the feature map in the generator from the original, because this modification achieved better results. Note that when we doubled the dimension of the feature map for the WGANGP experiment, however, the performance deteriorated.
The images used in this set of experiments were resized to pixels. The details of the architecture are given in Table 6. For the generator network of conditional GANs, we used conditional batch normalization (CBN) Dumoulin et al. (2017); de Vries et al. (2017). Namely we replaced the standard batch normalization layer with the CBN conditional to the label information . For the optimization, we used Adam with the same hyperparameters we used for ResNet on CIFAR10 and STL10 dataset. We trained the networks with 450K generator updates, and applied linear decay for the learning rate after 400K iterations so that the rate would be 0 at the end.


dense, ResBlock up 256 ResBlock up 256 ResBlock up 256 BN, ReLU, 33 conv, 3 Tanh RGB image ResBlock down 128 ResBlock down 128 ResBlock 128 ResBlock 128 ReLU Global sum pooling dense 1 





Figure 9 shows the spectral norm of each layer in the discriminator over the course of the training. The setting of the optimizer is C in Table 1 throughout the training. In fact, they do not deviate by more than 0.05 for the most part. As an exception, 6 and 7th convolutional layers with largest rank deviate by more than 0.1 in the beginning of the training, but the norm of this layer too stabilizes around after some iterations.
Figure 11 shows the effect of on the performance of weight normalization and spectral normalization. All results shown in Figure 11 follows setting D, except for the value of . For WN, the performance deteriorates with larger , which amounts to computing minimax with better accuracy. Our SN does not suffer from this unintended effect.
This section is dedicated to the comparative study of spectral normalization and other regularization methods for discriminators. In particular, we will show that contemporary regularizations including weight normalization and weight clipping implicitly impose constraints on weight matrices that places unnecessary restriction on the search space of the discriminator. More specifically, we will show that weight normalization and weight clipping unwittingly favor lowrank weight matrices. This can force the trained discriminator to be largely dependent on select few features, rendering the algorithm to be able to match the model distribution with the target distribution only on very low dimensional feature space.
The weight normalization introduced by Salimans & Kingma (2016) is a method that normalizes the norm of each row vector in the weight matrix^{8}^{8}8In the original literature, the weight normalization was introduced as a method for reparametrization of the form where is to be learned in the course of the training. In this work, we deal with the case so that we can assess the methods under the Lipschitz constraint. :
(25) 
where and are the th row vector of and , respectively.
Still another technique to regularize the weight matrix is to use the Frobenius norm:
(26) 
where .
Originally, these regularization techniques were invented with the goal of improving the generalization performance of supervised training Salimans & Kingma (2016); Arpit et al. (2016). However, recent works in the field of GANs Salimans et al. (2016); Xiang & Li (2017) found their another raison d’etat as a regularizer of discriminators, and succeeded in improving the performance of the original.
These methods in fact can render the trained discriminator to be Lipschitz for a some prescribed and achieve the desired effect to a certain extent. However, weight normalization (25) imposes the following implicit restriction on the choice of :
(27) 
where is a th singular value of matrix . The above equation holds because . Under this restriction, the norm for a fixed unit vector is maximized at when and for , which means that is of rank one. Using such corresponds to using only one feature to discriminate the model probability distribution from the target. Similarly, Frobenius normalization requires , and the same argument as above follows.
Here, we see a critical problem in these two regularization methods. In order to retain as much norm of the input as possible and hence to make the discriminator more sensitive, one would hope to make the norm of large. For weight normalization, however, this comes at the cost of reducing the rank and hence the number of features to be used for the discriminator. Thus, there is a conflict of interests between weight normalization and our desire to use as many features as possible to distinguish the generator distribution from the target distribution. The former interest often reigns over the other in many cases, inadvertently diminishing the number of features to be used by the discriminators. Consequently, the algorithm would produce a rather arbitrary model distribution that matches the target distribution only at select few features.
Our spectral normalization, on the other hand, do not suffer from such a conflict in interest. Note that the Lipschitz constant of a linear operator is determined only by the maximum singular value. In other words, the spectral norm is independent of rank. Thus, unlike the weight normalization, our spectral normalization allows the parameter matrix to use as many features as possible while satisfying local Lipschitz constraint. Our spectral normalization leaves more freedom in choosing the number of singular components (features) to feed to the next layer of the discriminator.
To see this more visually, we refer the reader to Figure (16). Note that spectral normalization allows for a wider range of choices than weight normalization.
In summary, weight normalization and Frobenius normalization favor skewed distributions of singular values, making the column spaces of the weight matrices lie in (approximately) low dimensional vector spaces. On the other hand, our spectral normalization does not compromise the number of feature dimensions used by the discriminator. In fact, we will experimentally show that GANs trained with our spectral normalization can generate a synthetic dataset with wider variety and higher inception score than the GANs trained with other two regularization methods.
Still another regularization technique is weight clipping introduced by Arjovsky et al. (2017) in their training of Wasserstein GANs. Weight clipping simply truncates each element of weight matrices so that its absolute value is bounded above by a prescribed constant . Unfortunately, weight clipping suffers from the same problem as weight normalization and Frobenius normalization. With weight clipping with the truncation value , the value for a fixed unit vector is maximized when the rank of is again one, and the training will again favor the discriminators that use only select few features. Gulrajani et al. (2017) refers to this problem as capacity underuse problem. They also reported that the training of WGAN with weight clipping is slower than that of the original DCGAN Radford et al. (2016).
One direct and straightforward way of controlling the spectral norm is to clip the singular values Saito et al. (2017), Jia et al. (2017). This approach, however, is computationally heavy because one needs to implement singular value decomposition in order to compute all the singular values.
A similar but less obvious approach is to parametrize as follows from the getgo and train the discriminators with this constrained parametrization:
(28) 
where , , and is a diagonal matrix. However, it is not a simple task to train this model while remaining absolutely faithful to this parametrization constraint. Our spectral normalization, on the other hand, can carry out the updates with relatively low computational cost without compromising the normalization constraint.
Recently, Gulrajani et al. (2017) introduced a technique to enhance the stability of the training of Wasserstein GANs Arjovsky et al. (2017). In their work, they endeavored to place Lipschitz constraint (5
) on the discriminator by augmenting the adversarial loss function with the following regularizer function:
(29) 
where is a balancing coefficient and is:
(30)  
(31) 
Using this augmented objective function, Gulrajani et al. (2017) succeeded in training a GAN based on ResNet He et al. (2016) with an impressive performance. The advantage of their method in comparison to spectral normalization is that they can impose local Lipschitz constraint directly on the discriminator function without a rather roundabout layerwise normalization. This suggest that their method is less likely to underuse the capacity of the network structure.
At the same time, this type of method that penalizes the gradients at sample points suffers from the obvious problem of not being able to regularize the function at the points outside of the support of the current generative distribution. In fact, the generative distribution and its support gradually changes in the course of the training, and this can destabilize the effect of the regularization itself.
On the contrary, our spectral normalization regularizes the function itself, and the effect of the regularization is more stable with respect to the choice of the batch. In fact, we observed in the experiment that a high learning rate can destabilize the performance of WGANGP. Training with our spectral normalization does not falter with aggressive learning rate.
Moreover, WGANGP requires more computational cost than our spectral normalization with singlestep power iteration, because the computation of requires one whole round of forward and backward propagation. In Figure 10, we compare the computational cost of the two methods for the same number of updates.
Having said that, one shall not rule out the possibility that the gradient penalty can compliment spectral normalization and vice versa. Because these two methods regularizes discriminators by completely different means, and in the experiment section, we actually confirmed that combination of WGANGP and reparametrization with spectral normalization improves the quality of the generated examples over the baseline (WGANGP only).
We can take advantage of the regularization effect of the spectral normalization we saw above to develop another algorithm. Let us consider another parametrization of the weight matrix of the discriminator given by: ~W:= γ¯W_SN where is a scalar variable to be learned. This parametrization compromises the Lipschitz constraint at the layer of interest, but gives more freedom to the model while keeping the model from becoming degenerate. For this reparametrization, we need to control the Lipschitz condition by other means, such as the gradient penalty Gulrajani et al. (2017). Indeed, we can think of analogous versions of reparametrization by replacing in (E) with normalized by other criterions. The extension of this form is not new. In Salimans & Kingma (2016), they originally introduced weight normalization in order to derive the reparametrization of the form (E) with replaced (E) by and vectorized .
In this part of the addendum, we experimentally compare the reparametrizations derived from two different normalization methods (weight normalization and spectral normalization). We tested the reprametrization methods for the training of the discriminator of WGANGP. For the architecture of the network in WGANGP, we used the same CNN we used in the previous section. For the ResNetbased CNN, we used the same architecture provided by Gulrajani et al. (2017) ^{9}^{9}9We implement our method based on the opensourced code provided by the author Gulrajani et al. (2017) https://github.com/igul222/improved_wgan_training/blob/master/gan_cifar_resnet.py.
Tables 7, 8 summarize the result. We see that our method significantly improves the inception score from the baseline on the regular CNN, and slightly improves the score on the ResNet based CNN.
Figure 17 shows the learning curves of (a) critic losses, on train and validation sets and (b) the inception scores with different reparametrization methods. We can see the beneficial effect of spectral normalization in the learning curve of the discriminator as well. We can verify in the figure 16(a) that the discriminator with spectral normalization overfits less to the training dataset than the discriminator without reparametrization and with weight normalization, The effect of overfitting can be observed on inception score as well, and the final score with spectral normalization is better than the others. As for the best inception score achieved in the course of the training, spectral normalization achieved 7.28, whereas the spectral normalization and vanilla normalization achieved 7.04 and 6.69, respectively.
Method  Inception score  FID 

WGANGP (Standard CNN, Baseline)  6.68.06  40.1 
w/ Frobenius Norm.  N/A  N/A 
w/ Weight Norm.  6.36.04  42.4 
w/ Spectral Norm.  7.20.08  32.0 
(WGANGP, ResNet, Gulrajani et al. (2017))  7.86.08  
WGANGP (ResNet, Baseline)  7.80.11  24.5 
w/ Spectral norm.  7.85.06  23.6 
w/ Spectral norm. (1.5x feature maps in )  7.96.06  22.5 
Method (ResNet)  Inception score  FID 

(ACWGANGP, Gulrajani et al. (2017))  8.42.10  
ACWGANGP (Baseline)  8.29.12  19.5 
w/ Spectral norm.  8.59.12  18.6 
w/ Spectral norm. (1.5x feature maps in )  8.60.08  17.5 
Let us denote to be the normalized weight where to be a scalar normalized coefficient (e.g. Spectral norm or Frobenius norm). In general, we can write the derivative of loss with respect to unnormalized weight as follows:
(32)  
(33)  
(34) 
where and . The gradient is calculated by where , is the hidden node in the network to be transformed by and represents empirical expectation over the minibatch. When , the derivative is:
(35) 
and when ,
(36) 
Notice that, at least for the case or , the point of this gradient is given by :
(37) 
where
Comments
There are no comments yet.