{"id":2490,"date":"2019-08-22T19:00:16","date_gmt":"2019-08-22T19:00:16","guid":{"rendered":"https:\/\/www.aiproblog.com\/index.php\/2019\/08\/22\/a-gentle-introduction-to-biggan-the-big-generative-adversarial-network\/"},"modified":"2019-08-22T19:00:16","modified_gmt":"2019-08-22T19:00:16","slug":"a-gentle-introduction-to-biggan-the-big-generative-adversarial-network","status":"publish","type":"post","link":"https:\/\/www.aiproblog.com\/index.php\/2019\/08\/22\/a-gentle-introduction-to-biggan-the-big-generative-adversarial-network\/","title":{"rendered":"A Gentle Introduction to BigGAN the Big Generative Adversarial Network"},"content":{"rendered":"<p>Author: Jason Brownlee<\/p>\n<div>\n<p><a href=\"https:\/\/machinelearningmastery.com\/what-are-generative-adversarial-networks-gans\/\">Generative Adversarial Networks, or GANs<\/a>, are perhaps the most effective generative model for image synthesis.<\/p>\n<p>Nevertheless, they are typically restricted to generating small images and the training process remains fragile, dependent upon specific augmentations and hyperparameters in order to achieve good results.<\/p>\n<p>The BigGAN is an approach to pull together a suite of recent best practices in training class-conditional images and scaling up the batch size and number of model parameters. The result is the routine generation of both high-resolution (large) and high-quality (high-fidelity) images.<\/p>\n<p>In this post, you will discover the BigGAN model for scaling up class-conditional image synthesis.<\/p>\n<p>After reading this post, you will know:<\/p>\n<ul>\n<li>Image size and training brittleness remain large problems for GANs.<\/li>\n<li>Scaling up model size and batch size can result in dramatically larger and higher-quality images.<\/li>\n<li>Specific model architectural and training configurations required to scale up GANs.<\/li>\n<\/ul>\n<p>Discover how to develop DCGANs, conditional GANs, Pix2Pix, CycleGANs, and more with Keras <a href=\"https:\/\/machinelearningmastery.com\/generative_adversarial_networks\/\" rel=\"nofollow\">in my new GANs book<\/a>, with 29 step-by-step tutorials and full source code.<\/p>\n<p>Let\u2019s get started.<\/p>\n<div id=\"attachment_8534\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8534\" class=\"size-full wp-image-8534\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/08\/A-Gentle-Introduction-to-the-BigGAN.jpg\" alt=\"A Gentle Introduction to the BigGAN\" width=\"640\" height=\"360\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/08\/A-Gentle-Introduction-to-the-BigGAN.jpg 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/08\/A-Gentle-Introduction-to-the-BigGAN-300x169.jpg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8534\" class=\"wp-caption-text\">A Gentle Introduction to the BigGAN<br \/>Photo by <a href=\"https:\/\/www.flickr.com\/photos\/reyperezoso\/40343937702\/\">rey perezoso<\/a>, some rights reserved.<\/p>\n<\/div>\n<h2>Overview<\/h2>\n<p>This tutorial is divided into four parts; they are:<\/p>\n<ol>\n<li>Brittleness of GAN Training<\/li>\n<li>Develop Better GANs by Scaling Up<\/li>\n<li>How to Scale-Up GANs With BigGAN<\/li>\n<li>Example of Images Generated by BigGAN<\/li>\n<\/ol>\n<h2>Brittleness of GAN Training<\/h2>\n<p>Generative Adversarial Networks, or GANs for short, are capable of generating high-quality synthetic images.<\/p>\n<p>Nevertheless, the size of generated images remains relatively small, e.g. 64\u00d764 or 128\u00d7128 pixels.<\/p>\n<p>Additionally, the model training process remains brittle regardless of the large number of studies that have investigated and proposed improvements.<\/p>\n<blockquote>\n<p>Without auxiliary stabilization techniques, this training procedure is notoriously brittle, requiring finely-tuned hyperparameters and architectural choices to work at all.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<p>Most of the improvements to the training process have focused on changes to the objective function or constraining the discriminator model during the training process.<\/p>\n<blockquote>\n<p>Much recent research has accordingly focused on modifications to the vanilla GAN procedure to impart stability, drawing on a growing body of empirical and theoretical insights. One line of work is focused on changing the objective function [\u2026] to encourage convergence. Another line is focused on constraining D through gradient penalties [\u2026] or normalization [\u2026] both to counteract the use of unbounded loss functions and ensure D provides gradients everywhere to G.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<p>More recently, work has focused on the effective application of the GAN for generating both high-quality and larger images.<\/p>\n<p>One approach is to try scaling up GAN models that already work well.<\/p>\n<div class=\"woo-sc-hr\"><\/div>\n<p><center><\/p>\n<h3>Want to Develop GANs from Scratch?<\/h3>\n<p>Take my free 7-day email crash course now (with sample code).<\/p>\n<p>Click to sign-up and also get a free PDF Ebook version of the course.<\/p>\n<p><a href=\"https:\/\/machinelearningmastery.lpages.co\/leadbox\/162526e1b172a2%3A164f8be4f346dc\/5926953912500224\/\" target=\"_blank\" style=\"background: rgb(255, 206, 10); color: rgb(255, 255, 255); text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-weight: bold; font-size: 16px; line-height: 20px; padding: 10px; display: inline-block; max-width: 300px; border-radius: 5px; text-shadow: rgba(0, 0, 0, 0.25) 0px -1px 1px; box-shadow: rgba(255, 255, 255, 0.5) 0px 1px 3px inset, rgba(0, 0, 0, 0.5) 0px 1px 3px;\" rel=\"noopener noreferrer\">Download Your FREE Mini-Course<\/a><script data-leadbox=\"162526e1b172a2:164f8be4f346dc\" data-url=\"https:\/\/machinelearningmastery.lpages.co\/leadbox\/162526e1b172a2%3A164f8be4f346dc\/5926953912500224\/\" data-config=\"%7B%7D\" type=\"text\/javascript\" src=\"https:\/\/machinelearningmastery.lpages.co\/leadbox-1562872266.js\"><\/script><\/p>\n<p><\/center><\/p>\n<div class=\"woo-sc-hr\"><\/div>\n<h2>Develop Better GANs by Scaling Up<\/h2>\n<p>The BigGAN is an implementation of the GAN architecture designed to leverage the best from what has been reported to work more generally.<\/p>\n<p>It was described by <a href=\"https:\/\/twitter.com\/ajmooch\">Andrew Brock<\/a>, et al. in their 2018 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>\u201d and presented at the <a href=\"https:\/\/openreview.net\/forum?id=B1xsqj09Fm\">ICLR 2019 conference<\/a>.<\/p>\n<p>Specifically, the BigGAN is designed for class-conditional image generation. That is, the generation of images using both a point from latent space and image class information as input. Example datasets used to train class-conditional GANs include the <a href=\"https:\/\/machinelearningmastery.com\/how-to-develop-a-cnn-from-scratch-for-cifar-10-photo-classification\/\">CIFAR<\/a> or <a href=\"https:\/\/machinelearningmastery.com\/introduction-to-the-imagenet-large-scale-visual-recognition-challenge-ilsvrc\/\">ImageNet<\/a> image classification datasets that have tens, hundreds, or thousands of image classes.<\/p>\n<p>As its name suggests, the BigGAN is focused on scaling up the GAN models.<\/p>\n<p>This includes GAN models with:<\/p>\n<ul>\n<li>More model parameters (e.g. more feature maps).<\/li>\n<li>Larger Batch Sizes<\/li>\n<li>Architectural changes<\/li>\n<\/ul>\n<blockquote>\n<p>We demonstrate that GANs benefit dramatically from scaling, and train models with two to four times as many parameters and eight times the batch size compared to prior art. We introduce two simple, general architectural changes that improve scalability, and modify a regularization scheme to improve conditioning, demonstrably boosting performance.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<p>The BigGAN architecture also introduces a \u201c<em>truncation trick<\/em>\u201d used during image generation that results in an improvement in image quality, and a corresponding regularizing technique to better support this trick.<\/p>\n<p>The result is an approach capable of generating larger and higher-quality images, such as 256\u00d7256 and 512\u00d7512 images.<\/p>\n<blockquote>\n<p>When trained on ImageNet at 128\u00d7128 resolution, our models (BigGANs) improve the state-of-the-art [\u2026] We also successfully train BigGANs on ImageNet at 256\u00d7256 and 512\u00d7512 resolution \u2026<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<h2>How to Scale-Up GANs With BigGAN<\/h2>\n<p>The contribution of the BigGAN model is the design decisions for both the models and the training process.<\/p>\n<p>These design decisions are important for both re-implementing the BigGAN, but also in providing insight on configuration options that may prove beneficial with GANs more generally.<\/p>\n<p>The focus of the BigGAN model is to increase the number of model parameters and batch size, then configure the model and training process to achieve the best results.<\/p>\n<p>In this section, we will review the specific design decisions in the BigGAN.<\/p>\n<h3>1. Self-Attention Module and Hinge Loss<\/h3>\n<p>The base for the model is the Self-Attention GAN, or SAGAN for short, described by <a href=\"https:\/\/sites.google.com\/view\/hanzhang\">Han Zhang<\/a>, et al. in the 2018 paper tilted \u201c<a href=\"https:\/\/arxiv.org\/abs\/1805.08318\">Self-Attention Generative Adversarial Networks<\/a>.\u201d This involves introducing an attention map that is applied to feature maps, allowing the generator and discriminator models to focus on different parts of the image.<\/p>\n<p>This involves adding an attention module to the deep convolutional model architecture.<\/p>\n<div id=\"attachment_8527\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8527\" class=\"size-full wp-image-8527\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Summary-of-the-Self-Attention-Module-Used-in-the-Self-Attention-GAN.png\" alt=\"Summary of the Self-Attention Module Used in the Self-Attention GAN\" width=\"640\" height=\"248\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Summary-of-the-Self-Attention-Module-Used-in-the-Self-Attention-GAN.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Summary-of-the-Self-Attention-Module-Used-in-the-Self-Attention-GAN-300x116.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8527\" class=\"wp-caption-text\">Summary of the Self-Attention Module Used in the Self-Attention GAN.<br \/>Taken from: Self-Attention Generative Adversarial Networks.<\/p>\n<\/div>\n<p>Additionally, the model is trained via <a href=\"https:\/\/machinelearningmastery.com\/how-to-choose-loss-functions-when-training-deep-learning-neural-networks\/\">hinge loss<\/a>, commonly used for training support vector machines.<\/p>\n<blockquote>\n<p>In SAGAN, the proposed attention module has been applied to both generator and discriminator, which are trained in an alternating fashion by minimizing the hinge version of the adversarial loss<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1805.08318\">Self-Attention Generative Adversarial Networks<\/a>, 2018.<\/p>\n<p>The BigGAN uses the model architecture with attention modules from SAGAN and is trained via hinge loss.<\/p>\n<p>Appendix B of the paper titled \u201c<em>Architectural Details<\/em>\u201d provides a summary of the modules and their configurations used in the generator and discriminator models. There are two versions of the model described BigGAN and BigGAN-deep, the latter involving deeper <a href=\"https:\/\/machinelearningmastery.com\/how-to-implement-major-architecture-innovations-for-convolutional-neural-networks\/\">resnet modules<\/a> and, in turn, achieving better results.<\/p>\n<h3>2. Class Conditional Information<\/h3>\n<p>The class information is provided to the generator model via class-conditional batch normalization.<\/p>\n<p>This was described by <a href=\"https:\/\/vdumoulin.github.io\/\">Vincent Dumoulin<\/a>, et al. in their 2016 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1610.07629\">A Learned Representation For Artistic Style<\/a>.\u201d In the paper, the technique is referred to as \u201c<em>conditional instance normalization<\/em>\u201d that involves normalizing activations based on the statistics from images of a given style, or in the case of BigGAN, images of a given class.<\/p>\n<blockquote>\n<p>We call this approach conditional instance normalization. The goal of the procedure is [to] transform a layer\u2019s activations x into a normalized activation z specific to painting style s.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1610.07629\">A Learned Representation For Artistic Style<\/a>, 2016.<\/p>\n<p>Class information is provided to the discriminator via projection.<\/p>\n<p>This is described by <a href=\"https:\/\/twitter.com\/takeru_miyato?lang=en\">Takeru Miyato<\/a>, et al. in their 2018 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1802.05957\">Spectral Normalization for Generative Adversarial Networks<\/a>.\u201d This involves using an integer embedding of the class value that is concatenated into an intermediate layer of the network.<\/p>\n<blockquote>\n<p>Discriminator for conditional GANs. For computational ease, we embedded the integer label y in {0, . . . , 1000} into 128 dimension before concatenating the vector to the output of the intermediate layer.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1802.05957\">Spectral Normalization for Generative Adversarial Networks<\/a>, 2018.<\/p>\n<p>Instead of using one class embedding per class label, a shared embedding was used in order to reduce the number of weights.<\/p>\n<blockquote>\n<p>Instead of having a separate layer for each embedding, we opt to use a shared embedding, which is linearly projected to each layer\u2019s gains and biases. This reduces computation and memory costs, and improves training speed (in number of iterations required to reach a given performance) by 37%.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<h3>3. Spectral Normalization<\/h3>\n<p>The weights of the generator are normalized using spectral normalization.<\/p>\n<p>Spectral normalization for use in GANs was described by <a href=\"https:\/\/twitter.com\/takeru_miyato?lang=en\">Takeru Miyato<\/a>, et al. in their 2018 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1802.05957\">Spectral Normalization for Generative Adversarial Networks<\/a>.\u201d Specifically, it involves normalizing the spectral norm of the weight matrix.<\/p>\n<blockquote>\n<p>Our spectral normalization normalizes the spectral norm of the weight matrix W so that it satisfies the Lipschitz constraint sigma(W) = 1:<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1802.05957\">Spectral Normalization for Generative Adversarial Networks<\/a>, 2018.<\/p>\n<p>The efficient implementation requires a change to the weight updates during mini-batch stochastic gradient descent, described in Appendix A of the spectral normalization paper.<\/p>\n<div id=\"attachment_8528\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8528\" class=\"size-full wp-image-8528\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Algorithm-for-SGD-with-Spectral-Normalization.png\" alt=\"Algorithm for SGD with Spectral Normalization\" width=\"640\" height=\"317\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Algorithm-for-SGD-with-Spectral-Normalization.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Algorithm-for-SGD-with-Spectral-Normalization-300x149.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8528\" class=\"wp-caption-text\">Algorithm for SGD With Spectral Normalization<br \/>Taken from: Spectral Normalization for Generative Adversarial Networks<\/p>\n<\/div>\n<h3>4. Update Discriminator More Than Generator<\/h3>\n<p>In the GAN training algorithm, it is common to first update the discriminator model and then to update the generator model.<\/p>\n<p>The BigGAN slightly modifies this and updates the discriminator model twice before updating the generator model in each training iteration.<\/p>\n<h3>5. Moving Average of Model Weights<\/h3>\n<p>The generator model is evaluated based on the images that are generated.<\/p>\n<p>Before images are generated for evaluation, the model weights are averaged across prior training iterations using a <a href=\"https:\/\/machinelearningmastery.com\/polyak-neural-network-model-weight-ensemble\/\">moving average<\/a>.<\/p>\n<p>This approach to model weight moving average for generator evaluation was described and used by <a href=\"https:\/\/research.nvidia.com\/person\/tero-karras\">Tero Karras<\/a>, et al. in their 2017 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1710.10196\">Progressive Growing of GANs for Improved Quality, Stability, and Variation<\/a>.\u201d<\/p>\n<blockquote>\n<p>\u2026 for visualizing generator output at any given point during the training, we use an exponential running average for the weights of the generator with decay 0.999.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1710.10196\">Progressive Growing of GANs for Improved Quality, Stability, and Variation<\/a>, 2017.<\/p>\n<h3>6. Orthogonal Weight Initialization<\/h3>\n<p>Model weights are initialized using Orthogonal Initialization.<\/p>\n<p>This was described by <a href=\"http:\/\/decisions.psy.ox.ac.uk\/people\/saxe_site\/\">Andrew Saxe<\/a>, et al. in their 2013 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1312.6120\">Exact Solutions To The Nonlinear Dynamics Of Learning In Deep Linear Neural Networks<\/a>.\u201d This involves setting the weights to be a random orthogonal matrix.<\/p>\n<blockquote>\n<p>\u2026 the initial weights in each layer to be a random orthogonal matrix (satisfying W^T . W = I) \u2026<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1312.6120\">Exact Solutions To The Nonlinear Dynamics Of Learning In Deep Linear Neural Networks<\/a>, 2013.<\/p>\n<p>Note that Keras supports <a href=\"https:\/\/keras.io\/initializers\/\">orthogonal weight initialization directly<\/a>.<\/p>\n<h3>7. Larger Batch Size<\/h3>\n<p>Very <a href=\"https:\/\/machinelearningmastery.com\/how-to-control-the-speed-and-stability-of-training-neural-networks-with-gradient-descent-batch-size\/\">large batch sizes<\/a> were tested and evaluated.<\/p>\n<p>This includes batch sizes of 256, 512, 1024, and 2,048 images.<\/p>\n<p>Larger batch sizes generally resulted in better quality images, with the best image quality achieved with a batch size of 2,048 images.<\/p>\n<blockquote>\n<p>\u2026 simply increasing the batch size by a factor of 8 improves the state-of-the-art IS by 46%.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<p>The intuition is that the larger batch size provides more \u201c<em>modes<\/em>\u201d, and in turn, provides better gradient information for updating the models.<\/p>\n<blockquote>\n<p>We conjecture that this is a result of each batch covering more modes, providing better gradients for both networks.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<h3>8. More Model Parameters<\/h3>\n<p>The number of model parameters was also dramatically increased.<\/p>\n<p>This was achieved by doubling the number of channels or feature maps (filters) in each layer.<\/p>\n<blockquote>\n<p>We then increase the width (number of channels) in each layer by 50%, approximately doubling the number of parameters in both models. This leads to a further IS improvement of 21%, which we posit is due to the increased capacity of the model relative to the complexity of the dataset.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<h3>9. Skip-z Connections<\/h3>\n<p>Skip connections were added to the generator model to directly connect the input latent point to specific layers deep in the network.<\/p>\n<p>These are referred to as skip-z connections, where z refers to the input latent vector.<\/p>\n<blockquote>\n<p>Next, we add direct skip connections (skip-z) from the noise vector z to multiple layers of G rather than just the initial layer. The intuition behind this design is to allow G to use the latent space to directly influence features at different resolutions and levels of hierarchy. [\u2026] Skip-z provides a modest performance improvement of around 4%, and improves training speed by a further 18%.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<h3>10. Truncation Trick<\/h3>\n<p>The truncation trick involves using a different distribution for the generator\u2019s latent space during training than during inference or image synthesis.<\/p>\n<p>A <a href=\"https:\/\/machinelearningmastery.com\/statistical-data-distributions\/\">Gaussian distribution<\/a> is used during training, and a truncated Gaussian is used during inference. This is referred to as the \u201c<em>truncation trick<\/em>.\u201d<\/p>\n<blockquote>\n<p>We call this the Truncation Trick: truncating a z vector by resampling the values with magnitude above a chosen threshold leads to improvement in individual sample quality at the cost of reduction in overall sample variety.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<p>The truncation trick provides a trade-off between image quality or fidelity and image variety. A more narrow sampling range results in better quality, whereas a larger sampling range results in more variety in sampled images.<\/p>\n<blockquote>\n<p>This technique allows fine-grained, post-hoc selection of the trade-off between sample quality and variety for a given G.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/p>\n<h3>11. Orthogonal Regularization<\/h3>\n<p>Not all models respond well to the truncation trick.<\/p>\n<p>Some of the deeper models would provide saturated artifacts when the truncation trick was used.<\/p>\n<p>To better encourage a broader range of models to work well with the truncation trick, orthogonal regularization was used.<\/p>\n<p>This was introduced by <a href=\"https:\/\/twitter.com\/ajmooch?lang=en\">Andrew Brock<\/a>, et al. in their 2016 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1609.07093\">Neural Photo Editing with Introspective Adversarial Networks<\/a>.\u201d<\/p>\n<p>This is related to the orthogonal weight initialization and introduces a <a href=\"https:\/\/machinelearningmastery.com\/weight-regularization-to-reduce-overfitting-of-deep-learning-models\/\">weight regularization<\/a> term to encourage the weights to maintain their orthogonal property.<\/p>\n<blockquote>\n<p>Orthogonality is a desirable quality in ConvNet filters, partially because multiplication by an orthogonal matrix leaves the norm of the original matrix unchanged. [\u2026] we propose a simple weight regularization technique, Orthogonal Regularization, that encourages weights to be orthogonal by pushing them towards the nearest orthogonal manifold.<\/p>\n<\/blockquote>\n<p>\u2014 <a href=\"https:\/\/arxiv.org\/abs\/1609.07093\">Neural Photo Editing with Introspective Adversarial Networks<\/a>, 2016.<\/p>\n<h2>Example of Images Generated by BigGAN<\/h2>\n<p>The BigGAN is capable of generating large, high-quality images.<\/p>\n<p>In this section, we will review a few examples presented in the paper.<\/p>\n<p>Below are some examples of high-quality images generated by BigGAN.<\/p>\n<div id=\"attachment_8529\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8529\" class=\"size-full wp-image-8529\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Examples-of-High-Quality-Class-Conditional-Images-Generated-by-BigGAN.png\" alt=\"Examples of High-Quality Class-Conditional Images Generated by BigGAN\" width=\"640\" height=\"166\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-High-Quality-Class-Conditional-Images-Generated-by-BigGAN.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-High-Quality-Class-Conditional-Images-Generated-by-BigGAN-300x78.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8529\" class=\"wp-caption-text\">Examples of High-Quality Class-Conditional Images Generated by BigGAN.<br \/>Taken from: Large Scale GAN Training for High Fidelity Natural Image Synthesis.<\/p>\n<\/div>\n<p>Below are examples of large and high-quality images generated by BigGAN.<\/p>\n<div id=\"attachment_8530\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8530\" class=\"size-full wp-image-8530\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-Class-Conditional-Images-Generated-by-BigGAN.png\" alt=\"Examples of Large High-Quality Class-Conditional Images Generated by BigGAN\" width=\"640\" height=\"246\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-Class-Conditional-Images-Generated-by-BigGAN.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-Class-Conditional-Images-Generated-by-BigGAN-300x115.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8530\" class=\"wp-caption-text\">Examples of Large High-Quality Class-Conditional Images Generated by BigGAN.<br \/>Taken from: Large Scale GAN Training for High Fidelity Natural Image Synthesis.<\/p>\n<\/div>\n<p>One of the issues described when training BigGAN generators is the idea of \u201cclass leakage\u201d, a new type of failure mode.<\/p>\n<p>Below is an example of class leakage from a partially trained BigGAN, showing a cross between a tennis ball and perhaps a dog.<\/p>\n<div id=\"attachment_8531\" style=\"width: 406px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8531\" class=\"size-full wp-image-8531\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Examples-of-Class-Leakage-in-an-Image-Generated-by-Partially-Trained-BigGAN.png\" alt=\"Examples of Class Leakage in an Image Generated by Partially Trained BigGAN\" width=\"396\" height=\"402\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-Class-Leakage-in-an-Image-Generated-by-Partially-Trained-BigGAN.png 396w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-Class-Leakage-in-an-Image-Generated-by-Partially-Trained-BigGAN-296x300.png 296w\" sizes=\"(max-width: 396px) 100vw, 396px\"><\/p>\n<p id=\"caption-attachment-8531\" class=\"wp-caption-text\">Examples of Class Leakage in an Image Generated by Partially Trained BigGAN.<br \/>Taken from: Large Scale GAN Training for High Fidelity Natural Image Synthesis.<\/p>\n<\/div>\n<p>Below are some additional images generated by the BigGAN at 256\u00d7256 resolution.<\/p>\n<div id=\"attachment_8532\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8532\" class=\"size-full wp-image-8532\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-256x256-Class-Conditional-Images-Generated-by-BigGAN.png\" alt=\"Examples of Large High-Quality 256x256 Class-Conditional Images Generated by BigGAN\" width=\"640\" height=\"325\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-256x256-Class-Conditional-Images-Generated-by-BigGAN.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-256x256-Class-Conditional-Images-Generated-by-BigGAN-300x152.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8532\" class=\"wp-caption-text\">Examples of Large High-Quality 256\u00d7256 Class-Conditional Images Generated by BigGAN.<br \/>Taken from: Large Scale GAN Training for High Fidelity Natural Image Synthesis.<\/p>\n<\/div>\n<p>Below are some more images generated by the BigGAN at 512\u00d7512 resolution.<\/p>\n<div id=\"attachment_8533\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8533\" class=\"size-full wp-image-8533\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-512x512-Class-Conditional-Images-Generated-by-BigGAN.png\" alt=\"Examples of Large High-Quality 512x512 Class-Conditional Images Generated by BigGAN\" width=\"640\" height=\"326\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-512x512-Class-Conditional-Images-Generated-by-BigGAN.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Examples-of-Large-High-Quality-512x512-Class-Conditional-Images-Generated-by-BigGAN-300x153.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8533\" class=\"wp-caption-text\">Examples of Large High-Quality 512\u00d7512 Class-Conditional Images Generated by BigGAN.<br \/>Taken from: Large Scale GAN Training for High Fidelity Natural Image Synthesis.<\/p>\n<\/div>\n<h2>Further Reading<\/h2>\n<p>This section provides more resources on the topic if you are looking to go deeper.<\/p>\n<h3>Papers<\/h3>\n<ul>\n<li><a href=\"https:\/\/arxiv.org\/abs\/1809.11096\">Large Scale GAN Training for High Fidelity Natural Image Synthesis<\/a>, 2018.<\/li>\n<li><a href=\"https:\/\/openreview.net\/forum?id=B1xsqj09Fm\">Large Scale GAN Training for High Fidelity Natural Image Synthesis, ICLR 2019<\/a>.<\/li>\n<li><a href=\"https:\/\/arxiv.org\/abs\/1805.08318\">Self-Attention Generative Adversarial Networks<\/a>, 2018.<\/li>\n<li><a href=\"https:\/\/arxiv.org\/abs\/1610.07629\">A Learned Representation For Artistic Style<\/a>, 2016.<\/li>\n<li><a href=\"https:\/\/arxiv.org\/abs\/1802.05957\">Spectral Normalization for Generative Adversarial Networks<\/a>, 2018.<\/li>\n<li><a href=\"https:\/\/arxiv.org\/abs\/1710.10196\">Progressive Growing of GANs for Improved Quality, Stability, and Variation<\/a>, 2017.<\/li>\n<li><a href=\"https:\/\/arxiv.org\/abs\/1312.6120\">Exact Solutions To The Nonlinear Dynamics Of Learning In Deep Linear Neural Networks<\/a>, 2013.<\/li>\n<li><a href=\"https:\/\/arxiv.org\/abs\/1609.07093\">Neural Photo Editing with Introspective Adversarial Networks<\/a>, 2016.<\/li>\n<\/ul>\n<h3>Code<\/h3>\n<ul>\n<li><a href=\"https:\/\/tfhub.dev\/s?q=biggan\">BigGAN on TensorFlow Hub, Official<\/a>.<\/li>\n<li><a href=\"https:\/\/colab.research.google.com\/github\/tensorflow\/hub\/blob\/master\/examples\/colab\/biggan_generation_with_tf_hub.ipynb\">BigGAN Demo<\/a><\/li>\n<\/ul>\n<h3>Articles<\/h3>\n<ul>\n<li><a href=\"https:\/\/ai.googleblog.com\/2019\/03\/reducing-need-for-labeled-data-in.html\">Reducing the Need for Labeled Data in Generative Adversarial Networks, Google AI Blog<\/a>.<\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>In this post, you discovered the BigGAN model for scaling up class-conditional image synthesis.<\/p>\n<p>Specifically, you learned:<\/p>\n<ul>\n<li>Image size and training brittleness remain large problems for GANs.<\/li>\n<li>Scaling up model size and batch size can result in dramatically larger and higher-quality images.<\/li>\n<li>Specific model architectural and training configurations required to scale up GANs.<\/li>\n<\/ul>\n<p>Do you have any questions?<br \/>\nAsk your questions in the comments below and I will do my best to answer.<\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/machinelearningmastery.com\/a-gentle-introduction-to-the-biggan\/\">A Gentle Introduction to BigGAN the Big Generative Adversarial Network<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/machinelearningmastery.com\/\">Machine Learning Mastery<\/a>.<\/p>\n<\/div>\n<p><a href=\"https:\/\/machinelearningmastery.com\/a-gentle-introduction-to-the-biggan\/\">Go to Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Author: Jason Brownlee Generative Adversarial Networks, or GANs, are perhaps the most effective generative model for image synthesis. Nevertheless, they are typically restricted to generating [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/www.aiproblog.com\/index.php\/2019\/08\/22\/a-gentle-introduction-to-biggan-the-big-generative-adversarial-network\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":2491,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[24],"tags":[],"_links":{"self":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2490"}],"collection":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=2490"}],"version-history":[{"count":0,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2490\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media\/2491"}],"wp:attachment":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=2490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=2490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=2490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}