{"id":2454,"date":"2019-08-11T19:00:33","date_gmt":"2019-08-11T19:00:33","guid":{"rendered":"https:\/\/www.aiproblog.com\/index.php\/2019\/08\/11\/a-gentle-introduction-to-the-progressive-growing-gan\/"},"modified":"2019-08-11T19:00:33","modified_gmt":"2019-08-11T19:00:33","slug":"a-gentle-introduction-to-the-progressive-growing-gan","status":"publish","type":"post","link":"https:\/\/www.aiproblog.com\/index.php\/2019\/08\/11\/a-gentle-introduction-to-the-progressive-growing-gan\/","title":{"rendered":"A Gentle Introduction to the Progressive Growing GAN"},"content":{"rendered":"<p>Author: Jason Brownlee<\/p>\n<div>\n<p>Progressive Growing GAN is an extension to the GAN training process that allows for the stable training of generator models that can output large high-quality images.<\/p>\n<p>It involves starting with a very small image and incrementally adding blocks of layers that increase the output size of the generator model and the input size of the discriminator model until the desired image size is achieved.<\/p>\n<p>This approach has proven effective at generating high-quality synthetic faces that are startlingly realistic.<\/p>\n<p>In this post, you will discover the progressive growing generative adversarial network for generating large images.<\/p>\n<p>After reading this post, you will know:<\/p>\n<ul>\n<li>GANs are effective at generating sharp images, although they are limited to small image sizes because of model stability.<\/li>\n<li>Progressive growing GAN is a stable approach to training GAN models to generate large high-quality images that involves incrementally increasing the size of the model during training.<\/li>\n<li>Progressive growing GAN models are capable of generating photorealistic synthetic faces and objects at high resolution that are remarkably realistic.<\/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_8420\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8420\" class=\"size-full wp-image-8420\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/08\/A-Gentle-Introduction-to-Progressive-Growing-Generative-Adversarial-Networks.jpg\" alt=\"A Gentle Introduction to Progressive Growing Generative Adversarial Networks\" width=\"640\" height=\"360\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/08\/A-Gentle-Introduction-to-Progressive-Growing-Generative-Adversarial-Networks.jpg 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/08\/A-Gentle-Introduction-to-Progressive-Growing-Generative-Adversarial-Networks-300x169.jpg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8420\" class=\"wp-caption-text\">A Gentle Introduction to Progressive Growing Generative Adversarial Networks<br \/>Photo by <a href=\"https:\/\/www.flickr.com\/photos\/neelsandrine\/36514207683\/\">Sandrine N\u00e9el<\/a>, some rights reserved.<\/p>\n<\/div>\n<h2>Overview<\/h2>\n<p>This tutorial is divided into five parts; they are:<\/p>\n<ol>\n<li>GANs Are Generally Limited to Small Images<\/li>\n<li>Generate Large Images by Progressively Adding Layers<\/li>\n<li>How to Progressively Grow a GAN<\/li>\n<li>Images Generated by the Progressive Growing GAN<\/li>\n<li>How to Configure Progressive Growing GAN Models<\/li>\n<\/ol>\n<h2>GANs Are Generally Limited to Small Images<\/h2>\n<p>Generative Adversarial Networks, or GANs for short, are an effective approach for training deep convolutional neural network models for generating synthetic images.<\/p>\n<p>Training a GAN model involves two models: a generator used to output synthetic images, and a discriminator model used to classify images as real or fake, which is used to train the generator model. The two models are trained together in an adversarial manner, seeking an equilibrium.<\/p>\n<p>Compared to other approaches, they are both fast and result in crisp images.<\/p>\n<p>A problem with GANs is that they are limited to small dataset sizes, often a few hundred pixels and often less than 100-pixel square images.<\/p>\n<blockquote>\n<p>GANs produce sharp images, albeit only in fairly small resolutions and with somewhat limited variation, and the training continues to be unstable despite recent progress.<\/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<p>Generating high-resolution images is believed to be challenging for GAN models as the generator must learn how to output both large structure and fine details at the same time.<\/p>\n<p>The high resolution makes any issues in the fine detail of generated images easy to spot for the discriminator and the training process fails.<\/p>\n<blockquote>\n<p>The generation of high-resolution images is difficult because higher resolution makes it easier to tell the generated images apart from training images \u2026<\/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<p>Large images, such as 1024-pixel square images, also require significantly more memory, which is in relatively limited supply on modern GPU hardware compared to main memory.<\/p>\n<p>As such, the batch size that defines the number of images used to update model weights each training iteration must be reduced to ensure that the large images fit into memory. This, in turn, introduces further instability into the training process.<\/p>\n<blockquote>\n<p>Large resolutions also necessitate using smaller minibatches due to memory constraints, further compromising training stability.<\/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<p>Additionally, the training of GAN models remains unstable, even in the presence of a suite of empirical techniques designed to improve the stability of the model training process.<\/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>Generate Large Images by Progressively Adding Layers<\/h2>\n<p>A solution to the problem of training stable GAN models for larger images is to progressively increase the number of layers during the training process.<\/p>\n<p>This approach is called Progressive Growing GAN, Progressive GAN, or PGGAN for short.<\/p>\n<p>The approach was proposed by <a href=\"https:\/\/research.nvidia.com\/person\/tero-karras\">Tero Karras<\/a>, et al. from Nvidia in the 2017 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1710.10196\">Progressive Growing of GANs for Improved Quality, Stability, and Variation<\/a>\u201d and <a href=\"https:\/\/openreview.net\/forum?id=Hk99zCeAb&#038;noteId=Hk99zCeAb\">presented at the 2018 ICLR conference<\/a>.<\/p>\n<blockquote>\n<p>Our primary contribution is a training methodology for GANs where we start with low-resolution images, and then progressively increase the resolution by adding layers to the networks.<\/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<p>Progressive Growing GAN involves using a generator and discriminator model with the same general structure and starting with very small images, such as 4\u00d74 pixels.<\/p>\n<p>During training, new blocks of convolutional layers are systematically added to both the generator model and the discriminator models.<\/p>\n<div id=\"attachment_8415\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8415\" class=\"size-full wp-image-8415\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Example-of-Progressively-Adding-Layers-to-Generator-and-Discriminator-Models.png\" alt=\"Example of Progressively Adding Layers to Generator and Discriminator Models\" width=\"640\" height=\"401\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Example-of-Progressively-Adding-Layers-to-Generator-and-Discriminator-Models.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Example-of-Progressively-Adding-Layers-to-Generator-and-Discriminator-Models-300x188.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8415\" class=\"wp-caption-text\">Example of Progressively Adding Layers to Generator and Discriminator Models.<br \/>Taken from: Progressive Growing of GANs for Improved Quality, Stability, and Variation.<\/p>\n<\/div>\n<p>The incremental addition of the layers allows the models to effectively learn coarse-level detail and later learn ever finer detail, both on the generator and discriminator side.<\/p>\n<blockquote>\n<p>This incremental nature allows the training to first discover large-scale structure of the image distribution and then shift attention to increasingly finer scale detail, instead of having to learn all scales simultaneously.<\/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<p>This approach allows the generation of large high-quality images, such as 1024\u00d71024 photorealistic faces of celebrities that do not exist.<\/p>\n<h2>How to Progressively Grow a GAN<\/h2>\n<p>Progressive Growing GAN requires that the capacity of both the generator and discriminator model be expanded by adding layers during the training process.<\/p>\n<p>This is much like the greedy layer-wise training process that was common for developing deep learning neural networks prior to the development of <a href=\"https:\/\/machinelearningmastery.com\/rectified-linear-activation-function-for-deep-learning-neural-networks\/\">ReLU<\/a> and <a href=\"https:\/\/machinelearningmastery.com\/how-to-accelerate-learning-of-deep-neural-networks-with-batch-normalization\/\">Batch Normalization<\/a>.<\/p>\n<p>For example, see the post:<\/p>\n<ul>\n<li><a href=\"https:\/\/machinelearningmastery.com\/greedy-layer-wise-pretraining-tutorial\/\">How to Develop Deep Learning Neural Networks With Greedy Layer-Wise Pretraining<\/a><\/li>\n<\/ul>\n<p>Unlike greedy layer-wise pretraining, progressive growing GAN involves adding blocks of layers and phasing in the addition of the blocks of layers rather than adding them directly.<\/p>\n<blockquote>\n<p>When new layers are added to the networks, we fade them in smoothly [\u2026] This avoids sudden shocks to the already well-trained, smaller-resolution layers.<\/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<p>Further, all layers remain trainable during the training process, including existing layers when new layers are added.<\/p>\n<blockquote>\n<p>All existing layers in both networks remain trainable throughout the training process.<\/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<p>The phasing in of a new block of layers involves using a skip connection to connect the new block to the input of the discriminator or output of the generator and adding it to the existing input or output layer with a weighting. The weighting controls the influence of the new block and is achieved using a parameter alpha (a) that starts at zero or a very small number and linearly increases to 1.0 over training iterations.<\/p>\n<p>This is demonstrated in the figure below, taken from the paper.<\/p>\n<p>It shows a generator that outputs a 16\u00d716 image and a discriminator that takes a 16\u00d716 pixel image. The models are grown to the size of 32\u00d732.<\/p>\n<div id=\"attachment_8416\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8416\" class=\"size-full wp-image-8416\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Example-of-Phasing-in-the-Addition-of-New-Layers-to-the-Generator-and-Discriminator-Models.png\" alt=\"Example of Phasing in the Addition of New Layers to the Generator and Discriminator Models\" width=\"640\" height=\"337\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Example-of-Phasing-in-the-Addition-of-New-Layers-to-the-Generator-and-Discriminator-Models.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Example-of-Phasing-in-the-Addition-of-New-Layers-to-the-Generator-and-Discriminator-Models-300x158.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8416\" class=\"wp-caption-text\">Example of Phasing in the Addition of New Layers to the Generator and Discriminator Models.<br \/>Taken from: Progressive Growing of GANs for Improved Quality, Stability, and Variation.<\/p>\n<\/div>\n<p>Let\u2019s take a closer look at how to progressively add layers to the generator and discriminator when going from 16\u00d716 to 32\u00d732 pixels.<\/p>\n<h3>Growing the Generator<\/h3>\n<p>For the generator, this involves adding a new block of convolutional layers that outputs a 32\u00d732 image.<\/p>\n<p>The output of this new layer is combined with the output of the 16\u00d716 layer that is upsampled using nearest neighbor interpolation to 32\u00d732. This is different from many GAN generators that use a transpose convolutional layer.<\/p>\n<blockquote>\n<p>\u2026 doubling [\u2026] the image resolution using nearest neighbor filtering<\/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<p>The contribution of the upsampled 16\u00d716 layer is weighted by (1 \u2013 alpha), whereas the contribution of the new 32\u00d732 layer is weighted by alpha.<\/p>\n<p>Alpha is small initially, giving the most weight to the scaled-up version of the 16\u00d716 image, although slowly transitions to giving more weight and then all weight to the new 32\u00d732 output layers over training iterations.<\/p>\n<blockquote>\n<p>During the transition we treat the layers that operate on the higher resolution like a residual block, whose weight alpha increases linearly from 0 to 1.<\/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>Growing the Discriminator<\/h3>\n<p>For the discriminator, this involves adding a new block of convolutional layers for the input of the model to support image sizes with 32\u00d732 pixels.<\/p>\n<p>The input image is downsampled to 16\u00d716 using average pooling so that it can pass through the existing 16\u00d716 convolutional layers. The output of the new 32\u00d732 block of layers is also downsampled using average pooling so that it can be provided as input to the existing 16\u00d716 block. This is different from most GAN models that use a 2\u00d72 stride in the convolutional layers to downsample.<\/p>\n<blockquote>\n<p>\u2026 halving the image resolution using [\u2026] average pooling<\/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<p>The two downsampled versions of the input are combined in a weighted manner, starting with a full weighting to the downsampled raw input and linearly transitioning to a full weighting for the interpreted output of the new input layer block.<\/p>\n<h2>Images Generated by the Progressive Growing GAN<\/h2>\n<p>In this section, we can review some of the impressive results achieved with the Progressive Growing GAN described in the paper.<\/p>\n<p>Many example images are provided in the <a href=\"https:\/\/arxiv.org\/abs\/1710.10196\">appendix of the paper<\/a> and I recommend reviewing it. Additionally, a YouTube video was also created summarizing the impressive results of the model.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=G06dEcZ-QTg\">Progressive Growing of GANs for Improved Quality, Stability, and Variation, YouTube<\/a>.<\/li>\n<\/ul>\n<p><iframe loading=\"lazy\" title=\"Progressive Growing of GANs for Improved Quality, Stability, and Variation\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/G06dEcZ-QTg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<h3>Synthetic Photographs of Celebrity Faces<\/h3>\n<p>Perhaps the most impressive accomplishment of the Progressive Growing GAN is the generation of large 1024\u00d71024 pixel photorealistic generated faces.<\/p>\n<p>The model was trained on a high-quality version of the celebrity faces dataset, called CELEBA-HQ. As such, the faces look familiar as they contain elements of many real celebrity faces, although none of the people actually exist.<\/p>\n<div id=\"attachment_8417\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8417\" class=\"size-full wp-image-8417\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Example-of-Photorealistic-Generated-Faces-using-Progressive-Growing-GAN.png\" alt=\"Example of Photorealistic Generated Faces using Progressive Growing GAN\" width=\"640\" height=\"326\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Example-of-Photorealistic-Generated-Faces-using-Progressive-Growing-GAN.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Example-of-Photorealistic-Generated-Faces-using-Progressive-Growing-GAN-300x153.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8417\" class=\"wp-caption-text\">Example of Photorealistic Generated Faces Using Progressive Growing GAN.<br \/>Taken from: Progressive Growing of GANs for Improved Quality, Stability, and Variation.<\/p>\n<\/div>\n<p>Interestingly, the model required to generate the faces was trained on 8 GPUs for 4 days, perhaps out of the range of most developers.<\/p>\n<blockquote>\n<p>We trained the network on 8 Tesla V100 GPUs for 4 days, after which we no longer observed qualitative differences between the results of consecutive training iterations. Our implementation used an adaptive minibatch size depending on the current output resolution so that the available memory budget was optimally utilized.<\/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>Synthetic Photographs of Objects<\/h3>\n<p>The model was also demonstrated on generating 256\u00d7256-pixel photorealistic synthetic objects from the LSUN dataset, such as bikes, buses, and churches.<\/p>\n<div id=\"attachment_8418\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8418\" class=\"size-full wp-image-8418\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Example-of-Photorealistic-Generated-Objects-using-Progressive-Growing-GAN.png\" alt=\"Example of Photorealistic Generated Objects using Progressive Growing GAN\" width=\"640\" height=\"472\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Example-of-Photorealistic-Generated-Objects-using-Progressive-Growing-GAN.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Example-of-Photorealistic-Generated-Objects-using-Progressive-Growing-GAN-300x221.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8418\" class=\"wp-caption-text\">Example of Photorealistic Generated Objects Using Progressive Growing GAN.<br \/>Taken from: Progressive Growing of GANs for Improved Quality, Stability, and Variation.<\/p>\n<\/div>\n<h2>How to Configure Progressive Growing GAN Models<\/h2>\n<p>The paper describes the configuration details of the model used to generate the 1024\u00d71024 synthetic photographs of celebrity faces.<\/p>\n<p>Specifically, the details are provided in Appendix A.<\/p>\n<p>Although we may not be interested or have the resources to develop such a large model, the configuration details may be useful when implementing a Progressive Growing GAN.<\/p>\n<p>Both the discriminator and generator models were grown using blocks of <a href=\"https:\/\/machinelearningmastery.com\/convolutional-layers-for-deep-learning-neural-networks\/\">convolutional layers<\/a>, each using a specific number of filters with the size 3\u00d73 and the LeakyReLU activation layer with the slope of 0.2. Upsampling was achieved via nearest neighbor sampling and downsampling was achieved using <a href=\"https:\/\/machinelearningmastery.com\/pooling-layers-for-convolutional-neural-networks\/\">average pooling<\/a>.<\/p>\n<blockquote>\n<p>Both networks consist mainly of replicated 3-layer blocks that we introduce one by one during the course of the training. [\u2026] We use leaky ReLU with leakiness 0.2 in all layers of both networks, except for the last layer that uses linear activation.<\/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<p>The generator used a 512-element latent vector of <a href=\"https:\/\/machinelearningmastery.com\/how-to-generate-random-numbers-in-python\/\">Gaussian random variables<\/a>. It also used an output layer with a 1\u00d71-sized filters and a linear activation function, instead of the more common hyperbolic tangent activation function (tanh). The discriminator also used an output layer with 1\u00d71-sized filters and a linear activation function.<\/p>\n<p>The Wasserstein GAN loss was used with the gradient penalty, so-called WGAN-GP as described in the 2017 paper titled \u201c<a href=\"https:\/\/arxiv.org\/abs\/1704.00028\">Improved Training of Wasserstein GANs<\/a>.\u201d The least squares loss was tested and showed good results, but not as good as WGAN-GP.<\/p>\n<p>The models start with a 4\u00d74 input image and grow until they reach the 1024\u00d71024 target.<\/p>\n<p>Tables were provided that list the number of layers and number of filters used in each layer for the generator and discriminator models, reproduced below.<\/p>\n<div id=\"attachment_8419\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8419\" class=\"size-full wp-image-8419\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2019\/06\/Tables-Showing-Generator-and-Discriminator-Configuration-for-the-Progressive-Growing-GAN.png\" alt=\"Tables Showing Generator and Discriminator Configuration for the Progressive Growing GAN\" width=\"640\" height=\"430\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Tables-Showing-Generator-and-Discriminator-Configuration-for-the-Progressive-Growing-GAN.png 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2019\/06\/Tables-Showing-Generator-and-Discriminator-Configuration-for-the-Progressive-Growing-GAN-300x202.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p id=\"caption-attachment-8419\" class=\"wp-caption-text\">Tables Showing Generator and Discriminator Configuration for the Progressive Growing GAN.<br \/>Taken from: Progressive Growing of GANs for Improved Quality, Stability, and Variation.<\/p>\n<\/div>\n<p><a href=\"https:\/\/machinelearningmastery.com\/how-to-accelerate-learning-of-deep-neural-networks-with-batch-normalization\/\">Batch normalization<\/a> is not used; instead, two other techniques are added, including minibatch standard deviation pixel-wise normalization.<\/p>\n<p>The standard deviation of activations across images in the mini-batch is added as a new channel prior to the last block of convolutional layers in the discriminator model. This is referred to as \u201c<em>Minibatch standard deviation<\/em>.\u201d<\/p>\n<blockquote>\n<p>We inject the across-minibatch standard deviation as an additional feature map at 4\u00d74 resolution toward the end of the discriminator<\/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<p>A pixel-wise normalization is performed in the generator after each convolutional layer that normalizes each pixel value in the activation map across the channels to a unit length. This is a type of activation constraint that is more generally referred to as \u201c<em>local response normalization<\/em>.\u201d<\/p>\n<p>The bias for all layers is initialized as zero and model weights are initialized as a random Gaussian rescaled using the He weight initialization method.<\/p>\n<blockquote>\n<p>We initialize all bias parameters to zero and all weights according to the normal distribution with unit variance. However, we scale the weights with a layer-specific constant at runtime \u2026<\/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<p>The models are optimized using the Adam version of stochastic gradient descent with a small <a href=\"https:\/\/machinelearningmastery.com\/understand-the-dynamics-of-learning-rate-on-deep-learning-neural-networks\/\">learning rate<\/a> and low momentum.<\/p>\n<blockquote>\n<p>We train the networks using Adam with a = 0.001, B1=0, B2=0.99, and eta = 10^\u22128.<\/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<p>Image generation uses a <a href=\"https:\/\/machinelearningmastery.com\/polyak-neural-network-model-weight-ensemble\/\">weighted average<\/a> of prior models rather a given model snapshot, much like a horizontal ensemble.<\/p>\n<blockquote>\n<p>\u2026 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<h2>Further Reading<\/h2>\n<p>This section provides more resources on the topic if you are looking to go deeper.<\/p>\n<ul>\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:\/\/research.nvidia.com\/publication\/2017-10_Progressive-Growing-of\">Progressive Growing of GANs for Improved Quality, Stability, and Variation, Official<\/a>.<\/li>\n<li><a href=\"https:\/\/github.com\/tkarras\/progressive_growing_of_gans\">progressive_growing_of_gans Project (official), GitHub<\/a>.<\/li>\n<li><a href=\"https:\/\/openreview.net\/forum?id=Hk99zCeAb&#038;noteId=Hk99zCeAb\">Progressive Growing of GANs for Improved Quality, Stability, and Variation. Open Review<\/a>.<\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=G06dEcZ-QTg\">Progressive Growing of GANs for Improved Quality, Stability, and Variation, YouTube<\/a>.<\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>In this post, you discovered the progressive growing generative adversarial network for generating large images.<\/p>\n<p>Specifically, you learned:<\/p>\n<ul>\n<li>GANs are effective at generating sharp images, although they are limited to small image sizes because of model stability.<\/li>\n<li>Progressive growing GAN is a stable approach to training GAN models to generate large high-quality images that involves incrementally increasing the size of the model during training.<\/li>\n<li>Progressive growing GAN models are capable of generating photorealistic synthetic faces and objects at high resolution that are remarkably realistic.<\/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\/introduction-to-progressive-growing-generative-adversarial-networks\/\">A Gentle Introduction to the Progressive Growing GAN<\/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\/introduction-to-progressive-growing-generative-adversarial-networks\/\">Go to Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Author: Jason Brownlee Progressive Growing GAN is an extension to the GAN training process that allows for the stable training of generator models that can [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/www.aiproblog.com\/index.php\/2019\/08\/11\/a-gentle-introduction-to-the-progressive-growing-gan\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":2455,"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\/2454"}],"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=2454"}],"version-history":[{"count":0,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2454\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media\/2455"}],"wp:attachment":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=2454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=2454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=2454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}