{"id":25338,"date":"2025-01-01T13:00:00","date_gmt":"2025-01-01T13:00:00","guid":{"rendered":"https:\/\/pl.server2.purelogics.net\/?p=25338"},"modified":"2025-10-20T12:06:47","modified_gmt":"2025-10-20T12:06:47","slug":"advanced-architectures-for-generative-adversarial-networks","status":"publish","type":"post","link":"https:\/\/pl.server2.purelogics.net\/?p=25338","title":{"rendered":"Advanced Architectures for Generative Adversarial Networks (GANs)"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Understanding_GAN_Architecture\" title=\"Understanding GAN Architecture\">Understanding GAN Architecture<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Basic_GAN_Architecture\" title=\"Basic GAN Architecture\">Basic GAN Architecture<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Advanced_GAN_Architectures\" title=\"Advanced GAN Architectures\">Advanced GAN Architectures<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#1_Deep_Convolutional_GAN_DCGAN\" title=\"1. Deep Convolutional GAN (DCGAN)\">1. Deep Convolutional GAN (DCGAN)<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Key_Features\" title=\"Key Features\">Key Features<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Architecture_Breakdown\" title=\"Architecture Breakdown\">Architecture Breakdown<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Code_Example\" title=\"Code Example\">Code Example<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Transform_Your_Image_Tasks\" title=\"Transform Your Image Tasks\">Transform Your Image Tasks<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#2_Wasserstein_GAN_WGAN\" title=\"2. Wasserstein GAN (WGAN)\">2. Wasserstein GAN (WGAN)<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Key_Features-2\" title=\"Key Features\">Key Features<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Architecture_Breakdown-2\" title=\"Architecture Breakdown\">Architecture Breakdown<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#3_Progressive_Growing_GAN_PGGAN\" title=\"3. Progressive Growing GAN (PGGAN)\">3. Progressive Growing GAN (PGGAN)<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Key_Features-3\" title=\"Key Features\">Key Features<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Architecture_Breakdown-3\" title=\"Architecture Breakdown\">Architecture Breakdown<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Code_Example-2\" title=\"Code Example\">Code Example<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#4_StyleGAN\" title=\"4. StyleGAN\">4. StyleGAN<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Key_Features-4\" title=\"Key Features\">Key Features<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Architecture_Breakdown-4\" title=\"Architecture Breakdown\">Architecture Breakdown<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Create_Without_Limits\" title=\"Create Without Limits!\">Create Without Limits!<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#5_Conditional_GAN_cGAN\" title=\"5. Conditional GAN (cGAN)\">5. Conditional GAN (cGAN)<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Key_Features-5\" title=\"Key Features\">Key Features<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Architecture_Breakdown-5\" title=\"Architecture Breakdown\">Architecture Breakdown<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Summary_of_Architectures\" title=\"Summary of Architectures\">Summary of Architectures<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\/#Final_Remarks\" title=\"Final Remarks\">Final Remarks<\/a><\/li><\/ul><\/nav><\/div>\n<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p class=\"wp-block-paragraph\">Ian Goodfellow et al. introduced Generative Adversarial Networks (GANs) in 2014. Since then, they have reinvented generative modeling and opened up an innovative area of research. In addition to this, advancements in machine learning have enhanced the architectures of GANs. This has led to showing more promising results in creating realistic images. Generated adversarial networks have also shown significant success in computer vision. Today, they have been showing extraordinary results in text and audio as well.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This blog post sheds light on five popular GAN architectures, their features, architecture breakdown, code examples, applications, and a comparative summary of GAN architectures.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Namely:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Deep Convolutional GAN (DCGAN)<\/li>\n\n\n\n<li>Wasserstein GAN (WGAN)<\/li>\n\n\n\n<li>Progressive Growing GAN (PGGAN)<\/li>\n\n\n\n<li>StyleGAN<\/li>\n\n\n\n<li>Conditional GAN (cGAN)<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">But first, let\u2019s understand what a GAN architecture is.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Understanding_GAN_Architecture\"><\/span>Understanding GAN Architecture<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A standard GAN consists of two neural networks: the Generator (G) and the Discriminator (D). The Generator creates synthetic data from random noise. On the other hand, the Discriminator evaluates the data\u2019s authenticity. The two networks engage in a competitive process and push each other toward better performance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Basic_GAN_Architecture\"><\/span>Basic GAN Architecture<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before we discuss advanced architectures, let&#8217;s have a quick review of the basic GAN structure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">import torch<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">import torch.nn as nn<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">class Generator(nn.Module):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self, input_dim, output_dim):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(Generator, self).__init__()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.model = nn.Sequential(<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(input_dim, 128),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ReLU(),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(128, output_dim),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Tanh()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def forward(self, z):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.model(z)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">class Discriminator(nn.Module):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self, input_dim):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(Discriminator, self).__init__()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.model = nn.Sequential(<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(input_dim, 128),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.LeakyReLU(0.2),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(128, 1),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Sigmoid()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def forward(self, x):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.model(x)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Advanced_GAN_Architectures\"><\/span>Advanced GAN Architectures<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now, let&#8217;s discuss the five most popular GAN architectures in detail.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Deep_Convolutional_GAN_DCGAN\"><\/span>1. Deep Convolutional GAN (DCGAN)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">DCGAN is one of the most well-known GAN architectures. It has convolutional layers for both neural networks: the Generator and Discriminator. This GAN architecture is widely popular because of its ability to formulate quality images and stabilize training.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Key_Features\"><\/span>Key Features<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Convolutional Layers:<\/strong> DCGAN has convolutional layers, which makes it more effective for image data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Batch Normalization:<\/strong> It helps normalize inputs to layers and allows for faster convergence.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>ReLU and LeakyReLU:<\/strong> ReLU is used in the Generator. On the other hand, LeakyReLU (which handles negative inputs) is used in the Discriminator.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Architecture_Breakdown\"><\/span>Architecture Breakdown<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Layer<\/strong><\/td><td><strong>Output Size<\/strong><\/td><\/tr><tr><td>ConvTranspose2d<\/td><td>(N, 256, 8, 8)<\/td><\/tr><tr><td>ReLU<\/td><td><\/td><\/tr><tr><td>ConvTranspose2d<\/td><td>(N, 128, 16, 16)<\/td><\/tr><tr><td>BatchNorm2d<\/td><td><\/td><\/tr><tr><td>ReLU<\/td><td><\/td><\/tr><tr><td>ConvTranspose2d<\/td><td>(N, 64, 32, 32)<\/td><\/tr><tr><td>BatchNorm2d<\/td><td><\/td><\/tr><tr><td>ReLU<\/td><td><\/td><\/tr><tr><td>Conv2d<\/td><td>(N, 1, 64, 64)<\/td><\/tr><tr><td>Tanh<\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Code_Example\"><\/span>Code Example<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">class DCGANGenerator(nn.Module):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self, noise_dim):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(DCGANGenerator, self).__init__()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.model = nn.Sequential(<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ConvTranspose2d(noise_dim, 256, 4, 1, 0, bias=False),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ReLU(True),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ConvTranspose2d(256, 128, 4, 2, 1, bias=False),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.BatchNorm2d(128),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ReLU(True),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ConvTranspose2d(128, 64, 4, 2, 1, bias=False),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.BatchNorm2d(64),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ReLU(True),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ConvTranspose2d(64, 1, 4, 2, 1, bias=False),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Tanh()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def forward(self, input):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.model(input)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">class DCGANDiscriminator(nn.Module):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(DCGANDiscriminator, self).__init__()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.model = nn.Sequential(<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Conv2d(1, 64, 4, 2, 1, bias=False),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.LeakyReLU(0.2, inplace=True),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Conv2d(64, 128, 4, 2, 1, bias=False),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.BatchNorm2d(128),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.LeakyReLU(0.2, inplace=True),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Conv2d(128, 256, 4, 2, 1, bias=False),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.BatchNorm2d(256),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.LeakyReLU(0.2, inplace=True),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Conv2d(256, 1, 4, 1, 0, bias=False),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Sigmoid()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def forward(self, input):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.model(input)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Applications:<\/strong> DCGANs are commonly used in tasks like generating images for art, facial recognition, and style transfer.<\/p>\n\n\n\n<div class=\"cta-section\" style=\"background-image: url('https:\/\/pl.server2.purelogics.net\/wp-content\/uploads\/2024\/05\/image_2024_05_27T12_40_05_229Z.jpg'); padding: 30px; border-radius: 15px; color: white; background-size: cover; background-position: center;\">\n  <div style=\"text-align: left;\">\n    <h3 style=\"margin-top: 0; color: white;\"><span class=\"ez-toc-section\" id=\"Transform_Your_Image_Tasks\"><\/span>Transform Your Image Tasks<span class=\"ez-toc-section-end\"><\/span><\/h3>\n    <p>Achieve superior results with DCGAN\u2019s powerful convolutional network and normalization techniques.<\/p>\n  <\/div>\n  <div style=\"text-align: left;\">\n    <a href=\"javascript:void(0);\"class=\"cta-button\">Start building better GAN models today!\n      <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"white\" class=\"arrow-icon\"><path d=\"M12 2L10.59 3.41 17.17 10H2v2h15.17l-6.58 6.59L12 22l10-10L12 2z\"\/><\/svg>\n    <\/a>\n  <\/div>\n<\/div>\n\n<style>\nbody, .cta-section {\n  font-family: 'Sen', sans-serif;\n}\n\n.cta-section {\n  background-size: cover;\n  background-position: center;\n  border-radius: 15px;\n  padding: 50px;\n  color: white;\n  display: block; \n}\n.cta-section h2 {\n  font-size: 2.5em;\n  margin-bottom: 5px !important; \n  color: white;\n}\n.cta-section p {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        margin-bottom: 30px !important; \n}\n.cta-button {\n  display: inline-flex; \n  align-items: center; \n  padding: 8px 16px;\n  font-size: 0.8em;\n  color: white !important; \n  background-color: #4aba6a;\n  text-decoration: none;\n  border-radius: 10px;\n  position: relative;\n}\n.cta-button .arrow-icon {\n  margin-left: 10px; \n  vertical-align: middle; \n}\n.cta-button:hover {\n  background-color: #3b8e54;\n}\n<\/style>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Wasserstein_GAN_WGAN\"><\/span>2. Wasserstein GAN (WGAN)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">WGAN addresses several limitations of traditional GANs, particularly issues related to mode collapse and training instability. By using the Wasserstein distance as the loss metric, WGAN provides more meaningful gradients during training.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Key_Features-2\"><\/span>Key Features<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Wasserstein Loss:<\/strong> Measures the distance between the real and generated distributions, which is more stable than traditional GAN losses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Weight Clipping:<\/strong> Ensures that the weights of the Discriminator remain within a constrained range, helping to satisfy the Lipschitz constraint.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Improved Training Dynamics:<\/strong> Convergence is more stable, leading to better quality generated samples.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Architecture_Breakdown-2\"><\/span>Architecture Breakdown<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Layer<\/strong><\/td><td><strong>Output Size<\/strong><\/td><\/tr><tr><td>Dense<\/td><td>(N, 512)<\/td><\/tr><tr><td>LeakyReLU<\/td><td><\/td><\/tr><tr><td>Dense<\/td><td>(N, 256)<\/td><\/tr><tr><td>LeakyReLU<\/td><td><\/td><\/tr><tr><td>Dense<\/td><td>(N, 1)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">class WGANDiscriminator(nn.Module):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(WGANDiscriminator, self).__init__()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.model = nn.Sequential(<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(784, 512),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.LeakyReLU(0.2),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(512, 256),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.LeakyReLU(0.2),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(256, 1)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def forward(self, x):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.model(x)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Applications:<\/strong> WGANs are suitable for generating images. It is particularly used in scenarios where the training data is scarce or imbalanced.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Progressive_Growing_GAN_PGGAN\"><\/span>3. Progressive Growing GAN (PGGAN)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">PGGAN employs a unique training methodology where the model progressively increases the resolution of generated images. This technique allows the model to focus on learning the essential features of lower-resolution images before tackling higher resolutions.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Key_Features-3\"><\/span>Key Features<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Incremental Training:<\/strong> Starts with low-resolution images (e.g., 4&#215;4), progressively adding layers to increase resolution (e.g., 8&#215;8, 16&#215;16) as training stabilizes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Better Detail:<\/strong> This GAN architecture focuses on learning broad features first and then refines details. It leads to premium outputs with fewer artifacts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Control Over Training:<\/strong> It also enables manual adjustments in resolution, enabling a fine-tuned approach to training.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Architecture_Breakdown-3\"><\/span>Architecture Breakdown<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Resolution<\/strong><\/td><td><strong>Layers<\/strong><\/td><\/tr><tr><td>4&#215;4<\/td><td>1 Conv, 1 LeakyReLU<\/td><\/tr><tr><td>8&#215;8<\/td><td>1 Conv, 1 LeakyReLU, 1 ConvTranspose<\/td><\/tr><tr><td>16&#215;16<\/td><td>2 Conv, 2 LeakyReLU<\/td><\/tr><tr><td>32&#215;32<\/td><td>2 Conv, 2 LeakyReLU<\/td><\/tr><tr><td>64&#215;64<\/td><td>2 Conv, 2 LeakyReLU<\/td><\/tr><tr><td>128&#215;128<\/td><td>2 Conv, 2 LeakyReLU<\/td><\/tr><tr><td>256&#215;256<\/td><td>2 Conv, 2 LeakyReLU<\/td><\/tr><tr><td>512&#215;512<\/td><td>2 Conv, 2 LeakyReLU<\/td><\/tr><tr><td>1024&#215;1024<\/td><td>Final layers for high-resolution output<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Code_Example-2\"><\/span>Code Example<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">class PGGANGenerator(nn.Module):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(PGGANGenerator, self).__init__()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Define layers for each resolution progressively&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def forward(self, z):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Forward pass through progressively growing layers&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Applications:<\/strong> PGGANs are particularly effective for high-resolution image synthesis, such as generating realistic human faces.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_StyleGAN\"><\/span>4. StyleGAN<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">StyleGAN extends PGGAN&#8217;s ideas with a novel approach to image generation that emphasizes style. It allows for independent control over different aspects of the generated image through a style-based architecture.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Key_Features-4\"><\/span>Key Features<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Mapping Network:<\/strong> Transforms a latent vector into a style vector that influences the synthesis process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Adaptive Instance Normalization (AdaIN):<\/strong> Applies styles at different levels of the synthesis network. It enables more control over fine details and broader features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>High-Quality Outputs:<\/strong> Produces images with improved quality and diversity, capable of generating highly realistic faces.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Architecture_Breakdown-4\"><\/span>Architecture Breakdown<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Layer<\/strong><\/td><td><strong>Output Size<\/strong><\/td><\/tr><tr><td>Mapping Network<\/td><td>Latent Style Vector<\/td><\/tr><tr><td>Style Injection<\/td><td>Various resolutions<\/td><\/tr><tr><td>Synthesis Network<\/td><td>Output Image<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">class StyleGANGenerator(nn.Module):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(StyleGANGenerator, self).__init__()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Define the mapping and synthesis networks&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def forward(self, z):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Process through mapping and synthesis networks&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Applications:<\/strong> StyleGANs are widely used in creative applications such as character design, fashion design, and any domain requiring fine-grained control over generated imagery.<\/p>\n\n\n\n<div class=\"cta-section\" style=\"background-image: url('https:\/\/pl.server2.purelogics.net\/wp-content\/uploads\/2024\/05\/image_2024_05_27T12_40_05_229Z.jpg'); padding: 30px; border-radius: 15px; color: white; background-size: cover; background-position: center;\">\n  <div style=\"text-align: left;\">\n    <h3 style=\"margin-top: 0; color: white;\"><span class=\"ez-toc-section\" id=\"Create_Without_Limits\"><\/span>Create Without Limits!<span class=\"ez-toc-section-end\"><\/span><\/h3>\n    <p>StyleGAN makes image generation feel like magic\u2014control the details, enhance the quality, and create the unreal.\u00a0<\/p>\n  <\/div>\n  <div style=\"text-align: left;\">\n    <a href=\"javascript:void(0);\"class=\"cta-button\">Get started and transform your designs today!\n      <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"white\" class=\"arrow-icon\"><path d=\"M12 2L10.59 3.41 17.17 10H2v2h15.17l-6.58 6.59L12 22l10-10L12 2z\"\/><\/svg>\n    <\/a>\n  <\/div>\n<\/div>\n\n<style>\nbody, .cta-section {\n  font-family: 'Sen', sans-serif;\n}\n\n.cta-section {\n  background-size: cover;\n  background-position: center;\n  border-radius: 15px;\n  padding: 50px;\n  color: white;\n  display: block; \n}\n.cta-section h2 {\n  font-size: 2.5em;\n  margin-bottom: 5px !important; \n  color: white;\n}\n.cta-section p {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        margin-bottom: 30px !important; \n}\n.cta-button {\n  display: inline-flex; \n  align-items: center; \n  padding: 8px 16px;\n  font-size: 0.8em;\n  color: white !important; \n  background-color: #4aba6a;\n  text-decoration: none;\n  border-radius: 10px;\n  position: relative;\n}\n.cta-button .arrow-icon {\n  margin-left: 10px; \n  vertical-align: middle; \n}\n.cta-button:hover {\n  background-color: #3b8e54;\n}\n<\/style>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Conditional_GAN_cGAN\"><\/span>5. Conditional GAN (cGAN)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Conditional GANs allow the generation of data conditioned on additional information, such as class labels or text descriptions. This architecture extends traditional GANs by incorporating extra input.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Key_Features-5\"><\/span>Key Features<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conditioning Variable:<\/strong> The Generator and Discriminator both receive a conditioning variable. Resultantly, it allows for more controlled generation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Flexibility:<\/strong> This GAN architecture can be used for various applications. It includes text-to-image synthesis, image-to-image translation, and more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Improved Control:<\/strong> cGAN also enables the generation of data that adheres to specific requirements. It enhances usability in targeted applications.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Architecture_Breakdown-5\"><\/span>Architecture Breakdown<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Layer<\/strong><\/td><td><strong>Output Size<\/strong><\/td><\/tr><tr><td>Input (Condition)<\/td><td>(N, c)<\/td><\/tr><tr><td>Concatenate<\/td><td>Combined input to G and D<\/td><\/tr><tr><td>Conv\/Deconv layers<\/td><td>Depends on the task (e.g., images)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">class cGANGenerator(nn.Module):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def __init__(self, input_dim, condition_dim):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(cGANGenerator, self).__init__()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.model = nn.Sequential(<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(input_dim + condition_dim, 128),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.ReLU(),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Linear(128, output_dim),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nn.Tanh()<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;def forward(self, z, c):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input = torch.cat((z, c), dim=1)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.model(input)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Applications:<\/strong> cGANs are widely used in tasks such as generating images based on specific labels (e.g., generating handwritten digits based on labels) or modifying existing images according to given constraints.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary_of_Architectures\"><\/span>Summary of Architectures<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here\u2019s a table summarizing the discussed architectures:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Architecture<\/strong><\/td><td><strong>Key Features<\/strong><\/td><td><strong>Use Cases<\/strong><\/td><\/tr><tr><td><strong>DCGAN<\/strong><\/td><td>Convolutional layers, batch normalization, stable training<\/td><td>Image generation, art synthesis<\/td><\/tr><tr><td><strong>WGAN<\/strong><\/td><td>Wasserstein distance, weight clipping, better stability<\/td><td>Text-to-image generation<\/td><\/tr><tr><td><strong>PGGAN<\/strong><\/td><td>Progressive training of resolutions, detail refinement<\/td><td>High-resolution image synthesis<\/td><\/tr><tr><td><strong>StyleGAN<\/strong><\/td><td>Style-based generation, control over features<\/td><td>Character design, portrait generation<\/td><\/tr><tr><td><strong>cGAN<\/strong><\/td><td>Conditioning for controlled generation<\/td><td>Text-to-image synthesis, image modification<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Final_Remarks\"><\/span>Final Remarks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Advanced GAN architectures have undoubtedly broadened the scope and potential of <a href=\"https:\/\/pl.server2.purelogics.net\/generative-ai-services\/\">generative modeling<\/a>. Each GAN architecture has some challenges while offering colossal benefits. Whether it is a stable training of WGANs or the style control of StyleGANs, these advanced architectures have numerous new avenues in creative applications, data generation, data augmentation and more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019re looking to take advantage of these GAN architectures for your projects, our team at PureLogics can assist you in implementing personalized solutions as per your specific organizational needs.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PureLogics is one of the popular names in GenAI development companies in the U.S.A. Our <a href=\"https:\/\/pl.server2.purelogics.net\/generative-ai-services\/\">generative AI services<\/a> have helped hundreds of small- and -large-scale companies worldwide. <a href=\"https:\/\/pl.server2.purelogics.net\/contact-us\/\">Fill out the form<\/a> to get a free consultation from the best AI\/ML experts in the USA!<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> Ian Goodfellow et al. introduced Generative Adversarial Networks (GANs) in 2014. Since then, they have reinvented generative modeling and opened up an innovative area of research. In addition to this, advancements in machine learning have enhanced the architectures of GANs. This has led to showing more promising results in creating realistic images. Generated adversarial networks <a href=\"https:\/\/pl.server2.purelogics.net\/?p=25338\" class=\"more-link\">&#8230;<\/a><\/p>\n","protected":false},"author":11,"featured_media":25343,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[565,8],"tags":[],"class_list":["post-25338","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-generative-ai","category-artificial-intelligence"],"_links":{"self":[{"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=\/wp\/v2\/posts\/25338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25338"}],"version-history":[{"count":4,"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=\/wp\/v2\/posts\/25338\/revisions"}],"predecessor-version":[{"id":33662,"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=\/wp\/v2\/posts\/25338\/revisions\/33662"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=\/wp\/v2\/media\/25343"}],"wp:attachment":[{"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pl.server2.purelogics.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}