{"id":8512,"date":"2022-05-20T13:52:02","date_gmt":"2022-05-20T13:52:02","guid":{"rendered":"https:\/\/wealthrevelation.com\/data-science\/2022\/05\/20\/generative-adversarial-networks\/"},"modified":"2022-05-20T13:52:02","modified_gmt":"2022-05-20T13:52:02","slug":"generative-adversarial-networks","status":"publish","type":"post","link":"https:\/\/wealthrevelation.com\/data-science\/2022\/05\/20\/generative-adversarial-networks\/","title":{"rendered":"Generative Adversarial Networks"},"content":{"rendered":"<div>\n<p>After\u00a0<a href=\"https:\/\/data-science-blog.com\/blog\/2022\/03\/15\/deep-autoregressive-models\/\">Deep Autoregressive Models<\/a>, <a href=\"https:\/\/data-science-blog.com\/blog\/2022\/02\/19\/deep-generative-modelling\/\">Deep Generative Modelling<\/a> and <a href=\"https:\/\/data-science-blog.com\/blog\/2022\/04\/19\/variational-autoencoders\/\">Variational Autoencoders<\/a> we now continue the discussion with <strong>G<\/strong>enerative <strong>A<\/strong>dversarial <strong>N<\/strong>etworks (GANs).<\/p>\n<h3><strong>Introduction<\/strong><\/h3>\n<p>So far, in the series of deep generative modellings (DGMs [Yad22a]), we have covered autoregressive modelling [?], which estimates the exact log likelihood defined by the model and variational autoencoders [?], which was variational approximations for lower bound optimization. Both of these modelling techniques were explicitly defining density functions and optimizing the likelihood of the training data. However, in this blog, we are going to discuss generative adversarial networks (GANs), which are likelihood-free models and do not define density functions explicitly. GANs follow a game-theoretic approach and learn to generate from the training distribution through a set up of a two-player game.<\/p>\n<div id=\"attachment_6125\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-6125\" loading=\"lazy\" class=\"size-full wp-image-6125\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/uploads\/sites\/4\/2022\/05\/two-player-GAN-deep-learning-unsupervised.png\" alt=\"A two player model of GAN along with the generator and discriminators.\" width=\"2547\" height=\"941\"><\/p>\n<p id=\"caption-attachment-6125\" class=\"wp-caption-text\">A two player model of GAN along with the generator and discriminators.<\/p>\n<\/div>\n<p>GAN tries to learn the distribution of high dimensional training data and generates high-quality synthetic data which has a similar distribution to training data. However, learning the training distribution is a highly complex task therefore GAN utilizes a two-player game approach to overcome the high dimensional complexity problem. GAN has two different neural networks (as shown in Figure ??) the generator and the discriminator. The generator takes a random input <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-7ecb092c5ad5b5328dd4396cfc0adb1d_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"zsim p(z)\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"63\"> and produces a sample that has a similar distribution as <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-ad9f0d65bc1036de8b8f5d755f5bef6a_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"p_d\" title=\"Rendered by QuickLaTeX.com\" height=\"12\" width=\"18\">. To train this network efficiently, there is the other network that is utilized as the second player and known as the discriminator. The generator network (player one) tries to fool the discriminator by generating real looking images. Moreover, the discriminator network tries to distinguish between real (training data <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-ebb5ebc36906361c50a3fbd13994e08f_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"xsim p_d(x)\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"74\">) and fake images effectively. Our main aim is to have an efficiently trained discriminator to be able to distinguish between real and fake images (the generator\u2019s output) and on the other hand, we would like to have a generator, which can easily fool the discriminator by generating real-looking images.<\/p>\n<h2>Objective function and training<\/h2>\n<h3>Objective function<\/h3>\n<p>Simultaneous training of these two networks is one of the main challenges in GANs and a minimax loss function is defined for this purpose. To understand this minimax function, firstly, we would like to discuss the concept of two sample testing by Aditya grover [Gro20]. Two sample testing is a method to compute the discrepancy between the training data distribution and the generated data distribution:<\/p>\n<p class=\"ql-center-displayed-equation\"><span class=\"ql-right-eqno\"> (1) <\/span><span class=\"ql-left-eqno\"> \u00a0 <\/span><img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-7980edcee550a3814c1f817f58e1bfb3_l3.png\" height=\"31\" width=\"379\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"begin{equation*} min_{p_{theta_g}}: max_{D_{theta_d}in F} : mathbb{E}_{xsim p_d}[D_{theta_d}(x)] - mathbb{E}_{xsim p_{theta_g}} [D_{theta_d}(G_{theta_g}(x))], end{equation*}\" title=\"Rendered by QuickLaTeX.com\"><\/p>\n<p>\nwhere <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-bfc76cfa1f53715d8206fe702f4b9d59_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"p_{theta_g}\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"22\"> and <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-ad9f0d65bc1036de8b8f5d755f5bef6a_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"p_d\" title=\"Rendered by QuickLaTeX.com\" height=\"12\" width=\"18\"> are the distribution functions of generated and training data respectively. The term <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-2510519bbe1660dfdffb4195c7287343_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"F\" title=\"Rendered by QuickLaTeX.com\" height=\"12\" width=\"14\"> is a set of functions. The textit{max} part is computing the discrepancies between two distribution using a function <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-9777eba568c8f97a6f4553822dd453cc_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d} in F\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"65\"> and this part is very similar to the term <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-4e8716946f6a868f015e0d62f28bc540_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"d\" title=\"Rendered by QuickLaTeX.com\" height=\"13\" width=\"10\"> (discrepancy measure) from our first article cite{?} and KL-divergence is applied to compute this measure in second cite{?} and third articles cite{?}. However, in GANs, for a given set of functions <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-2510519bbe1660dfdffb4195c7287343_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"F\" title=\"Rendered by QuickLaTeX.com\" height=\"12\" width=\"14\">, we would like compute the distribution <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-bfc76cfa1f53715d8206fe702f4b9d59_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"p_{theta_g}\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"22\">, which minimizes the overall discrepancy even for a worse function <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-1027a5d8929977bc69877b20d9b0136e_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d}in F\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"65\">. The above mentioned objective function does not use any likelihood function and utilizing two different data samples from training and generated data respectively.<\/p>\n<p>By combining Figure ?? and Equation <a href=\"#id1680534526\">1<\/a>, the first term <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-1c4b4cb35296fdd7dc76bf9166842c48_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"mathbb{E}_{xsim p_d}[D_{theta_d}(x)]\" title=\"Rendered by QuickLaTeX.com\" height=\"20\" width=\"106\"> corresponds to the discriminator, which has direct access to the training data and the second term <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-9271a567a190dfafd06b4f7d53f5ffa8_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"mathbb{E}_{xsim p_{theta_g}}[D_{theta_d}(G_{theta_g}(x))]\" title=\"Rendered by QuickLaTeX.com\" height=\"23\" width=\"155\"> represents the generator part as it relies only on the latent space and produces synthetic data. Therefore, Equation <a href=\"#id1680534526\">1<\/a> can be rewritten in the form of GAN\u2019s two players as:<\/p>\n<p class=\"ql-center-displayed-equation\"><span class=\"ql-right-eqno\"> (2) <\/span><span class=\"ql-left-eqno\"> \u00a0 <\/span><img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-768b9dece98731bd7d56aaa85d15a3d9_l3.png\" height=\"31\" width=\"369\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"begin{equation*} min_{p_{theta_g}}: max_{D_{theta_d}in F} : mathbb{E}_{xsim p_d}[D_{theta_d}(x)] - mathbb{E}_{zsim p_z}[D_{theta_d}(G_{theta_g}(z))], end{equation*}\" title=\"Rendered by QuickLaTeX.com\"><\/p>\n<p>\nThe above equation can be rearranged in the form of log loss:<br \/>\n<a name=\"id4008028607\"><\/a><\/p>\n<p class=\"ql-center-displayed-equation\"><span class=\"ql-right-eqno\"> (3) <\/span><span class=\"ql-left-eqno\"> \u00a0 <\/span><img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-bac04040928a64b0805eb863ec4e2864_l3.png\" height=\"29\" width=\"457\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"begin{equation*} min_{theta_g}: max_{theta_d} : (mathbb{E}_{xsim p_d} [log : D_{theta_d} (x)] + mathbb{E}_{zsim p_z}[log(1 - D_{theta_d}(G_{theta_g}(z))]), end{equation*}\" title=\"Rendered by QuickLaTeX.com\"><\/p>\n<p>In the above equation, the arguments are modified from <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-bfc76cfa1f53715d8206fe702f4b9d59_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"p_{theta_g}\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"22\"> and <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-f18da63612edfd4144e4f4d51c1eebbf_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d} in F\" title=\"Rendered by QuickLaTeX.com\" height=\"17\" width=\"60\"> to <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-a4e8e15abe4669fd3bd834e145dff4c3_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_g\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"15\"> and\u00a0 <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-97d53a4c11bf6a669fdc70b5d0ba9b37_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_d\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"16\"> respectively as we would like to approximate the network parameters, which are represented by <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-a4e8e15abe4669fd3bd834e145dff4c3_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_g\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"15\"> and <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-97d53a4c11bf6a669fdc70b5d0ba9b37_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_d\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"16\"> for the both generator and discriminator respectively. The discriminator wants to maximize the above objective for <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-97d53a4c11bf6a669fdc70b5d0ba9b37_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_d\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"16\"> such that <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-3593ff65c77b2f3dfb6aadc5ec437d7e_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d}(x) approx 1\" title=\"Rendered by QuickLaTeX.com\" height=\"19\" width=\"85\">, which indicates that the outcome is close to the real data. Furthermore, <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-cf4195fd05c51ae824416af04350fd3b_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d}(G_{theta_g}(z))\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"93\"> should be close to zero as it is fake data, therefore, the maximization of the above objective function for <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-97d53a4c11bf6a669fdc70b5d0ba9b37_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_d\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"16\"> will ensure that the discriminator is performing efficiently in terms of separating real and fake data. From the generator point of view, we would like to minimize this objective function for <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-a4e8e15abe4669fd3bd834e145dff4c3_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_g\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"15\"> such that <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-a5ac15616dde5703f4605152ef5775bb_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d}(G_{theta_g}(z)) approx 1\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"125\">. If the minimization of the objective function happens effectively for <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-a4e8e15abe4669fd3bd834e145dff4c3_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_g\" title=\"Rendered by QuickLaTeX.com\" height=\"18\" width=\"15\"> then the discriminator will classify a fake data into a real data that means that the generator is producing almost real-looking samples.<\/p>\n<h3>Training<\/h3>\n<p>The training procedure of GAN can be explained by using the following visualization from Goodfellow et al. [GPAM+14]. In Figure 2(a), <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-4586e340cb83d5b642972e97a288fec2_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"z\" title=\"Rendered by QuickLaTeX.com\" height=\"8\" width=\"9\"> is a random input vector to the generator to produce a synthetic outcome <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-4569a9ebe4574a5f25769b6d5487c79d_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"xsim p_{theta_g}\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"55\"> (green curve). The generated data distribution is not close to the original data distribution <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-ad9f0d65bc1036de8b8f5d755f5bef6a_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"p_d\" title=\"Rendered by QuickLaTeX.com\" height=\"12\" width=\"18\"> (dotted black curve). Therefore, the discriminator classifies this image as a fake image and forces generator to learn the training data distribution (Figure 2(b) and (c)). Finally, the generator produces the image which could not detected as a fake data by discriminator(Figure 2(d)).<\/p>\n<div id=\"attachment_6136\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-6136\" loading=\"lazy\" class=\"size-full wp-image-6136\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/uploads\/sites\/4\/2022\/05\/GAN-deep-learning-training-visualization.png\" alt=\"GAN\u2019s training visualization: the dotted black, solid green lines represents pd and p\u03b8 respectively. The discriminator distribution is shown in dotted blue. This image taken from Goodfellow et al.\" width=\"2989\" height=\"1003\"><\/p>\n<p id=\"caption-attachment-6136\" class=\"wp-caption-text\">GAN\u2019s training visualization: the dotted black, solid green lines represents pd and p\u03b8<br \/>respectively. The discriminator distribution is shown in dotted blue. This image taken from Goodfellow<br \/>et al. [GPAM+14].<\/p>\n<\/div>\n<p>The optimization of the objective function mentioned in Equation <a href=\"#id4008028607\">3<\/a> is performed in th following two steps repeatedly:<br \/>begin{enumerate}<br \/>item Firstly, the gradient ascent is utilized to maximize the objective function for <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-97d53a4c11bf6a669fdc70b5d0ba9b37_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"theta_d\" title=\"Rendered by QuickLaTeX.com\" height=\"15\" width=\"16\"> for discriminator.<br \/><a name=\"id4011462234\"><\/a><\/p>\n<p class=\"ql-center-displayed-equation\"><span class=\"ql-right-eqno\"> (4) <\/span><span class=\"ql-left-eqno\"> \u00a0 <\/span><img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-79cc0abf65c2730d44630b9e9078c251_l3.png\" height=\"28\" width=\"415\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"begin{equation*} max_{theta_d} : (mathbb{E}_{xsim p_d} [log : D_{theta_d}(x)] + mathbb{E}_{zsim p_z}[log(1 - D_{theta_d}(G_{theta_g}(z))]) end{equation*}\" title=\"Rendered by QuickLaTeX.com\"><\/p>\n<p>\nitem In the second step, the following function is minimized for the generator using gradient descent.<\/p>\n<p class=\"ql-center-displayed-equation\"><span class=\"ql-right-eqno\"> (5) <\/span><span class=\"ql-left-eqno\"> \u00a0 <\/span><img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-1a5f55cfe2aa160fc40a567edc93237d_l3.png\" height=\"29\" width=\"255\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"begin{equation*} min_{theta_g} : ( mathbb{E}_{zsim p_z}[log(1 - D_{theta_d}(G_{theta_g}(z))]) end{equation*}\" title=\"Rendered by QuickLaTeX.com\"><\/p>\n<p>\nend{enumerate}<\/p>\n<p>However, in practice the minimization for the generator does now work well because when <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-4cf09ec74ebcdbea82743b9569357f61_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d}(G_{theta_g}(z) approx 1\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"119\"> then the term <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-2cd5adcfa0c2fd89b8e5942feecd3a5f_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"log : (1-D_{theta_d}(G_{theta_g}(z)))\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"165\"> has the dominant gradient and vice versa.<\/p>\n<p>However, we would like to have the gradient behaviour completely opposite because <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-4cf09ec74ebcdbea82743b9569357f61_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d}(G_{theta_g}(z) approx 1\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"119\"> means the generator is well trained and does not require dominant gradient values. However, in case of <img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-1860118269870c23e2da21b79d3a42e2_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"D_{theta_d}(G_{theta_g}(z) approx 0\" title=\"Rendered by QuickLaTeX.com\" height=\"21\" width=\"120\">, the generator is not well trained and producing low quality outputs therefore, it requires a dominant gradient for an efficient training. To fix this problem, the gradient ascent method is applied to maximize the modified generator\u2019s objective:<br \/>In the second step, the following function is minimized for the generator using gradient descent alternatively.<br \/><a name=\"id1349565101\"><\/a><\/p>\n<p class=\"ql-center-displayed-equation\"><span class=\"ql-right-eqno\"> (6) <\/span><span class=\"ql-left-eqno\"> \u00a0 <\/span><img loading=\"lazy\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/ql-cache\/quicklatex.com-20421f265a98722e9835849d78d80269_l3.png\" height=\"29\" width=\"220\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"begin{equation*} max_{theta_g} : mathbb{E}_{zsim p_z}[log : (D_{theta_d}(G_{theta_g}(z))] end{equation*}\" title=\"Rendered by QuickLaTeX.com\"><\/p>\n<p>\ntherefore, during the training, Equation <a href=\"#id4011462234\">4<\/a> and <a href=\"#id1349565101\">6<\/a> will be maximized using the gradient ascent algorithm until the convergence.<\/p>\n<h2>Results<\/h2>\n<p>The quality of the generated images using GANs depends on several factors. Firstly, the joint training of GANs is not a stable procedure and that could severely decrease the quality of the outcome. Furthermore, the different neural network architecture will modify the quality of images based on the sophistication of the used network. For example, the vanilla GAN [GPAM+14] uses a fully connected deep neural network and generates a quite decent result. Furthermore, DCGAN [RMC15] utilized deep convolutional networks and enhanced the quality of outcome significantly. Furthermore, different types of loss functions are applied to stabilize the training procedure of GAN and to produce high-quality outcomes. As shown in Figure 3, StyleGAN [KLA19] utilized Wasserstein metric [Yad22b] to generate high-resolution face images. As it can be seen from Figure 3, the quality of the generated images are enhancing with time by applying more sophisticated training techniques and network architectures.<\/p>\n<div id=\"attachment_6139\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-6139\" loading=\"lazy\" class=\"size-full wp-image-6139\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/uploads\/sites\/4\/2022\/05\/GAN-deep-learning-variations-of-network-architecture-and-loss-function.png\" alt=\"GAN timeline with different variations in terms of network architecture and loss functions.\" width=\"3419\" height=\"813\"><\/p>\n<p id=\"caption-attachment-6139\" class=\"wp-caption-text\">GAN timeline with different variations in terms of network architecture and loss functions.<\/p>\n<\/div>\n<h2>Summary<\/h2>\n<p>This article covered the basics and mathematical concepts of GANs. However, the training of two different networks simultaneously could be complex and unstable. Therefore, researchers are continuously working to create a better and more stable version of GANs, for example, WGAN. Furthermore, different types of network architectures are introduced to improve the quality of outcomes. We will discuss this further in the upcoming blog about these variations.<\/p>\n<h2>References<\/h2>\n<p><strong>[GPAM+14]<\/strong> Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, DavidWarde-Farley, Sherjil<br \/>Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. Advances in<br \/>neural information processing systems, 27, 2014.<\/p>\n<p><strong>[Gro20]<\/strong> Aditya Grover. Generative adversarial networks.<br \/>https:\/\/deepgenerativemodels.github.io\/notes\/gan\/, 2020.<\/p>\n<p><strong>[KLA19]<\/strong> Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for<br \/>generative adversarial networks. In Proceedings of the IEEE\/CVF conference on computer<br \/>vision and pattern recognition, pages 4401\u20134410, 2019.<\/p>\n<p><strong>[RMC15]<\/strong> Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation<br \/>learning with deep convolutional generative adversarial networks. arXiv preprint<br \/>arXiv:1511.06434, 2015.<\/p>\n<p><strong>[Yad22a]<\/strong> Sunil Yadav. Deep generative modelling. https:\/\/data-scienceblog.<br \/>com\/blog\/2022\/02\/19\/deep-generative-modelling\/, 2022.<\/p>\n<p><strong>[Yad22b]<\/strong> Sunil Yadav. Necessary probability concepts for deep learning: Part 2.<br \/>https:\/\/medium.com\/@sunil7545\/kl-divergence-js-divergence-and-wasserstein-metricin-<br \/>deep-learning-995560752a53, 2022.<\/p>\n<div id=\"author-bio-box\">\n<h3><a href=\"https:\/\/data-science-blog.com\/en\/blog\/author\/sunilyadav\/\" title=\"All posts by Sunil Yadav\" rel=\"author\">Sunil Yadav<\/a><\/h3>\n<div class=\"bio-gravatar\"><img loading=\"lazy\" data-del=\"avatar\" src=\"https:\/\/data-science-blog.com\/en\/wp-content\/uploads\/sites\/4\/2022\/05\/Sunil_yadav-80x80.jpg\" class=\"avatar pp-user-avatar avatar-70 photo \" height=\"70\" width=\"70\"><\/div>\n<p><a target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\/\/www.linkedin.com\/in\/sunil-yadav-9804315a?miniProfileUrn=urnlifs_miniProfileACoAAAyFjzABioeldpBaEuO5tOpf0utOM-kzYdk&amp;lipi=urnlipaged_flagship3_search_srp_all4iVlVv0TnKvm3Q9n4xIA\" class=\"bio-icon bio-icon-linkedin\"><\/a><\/p>\n<p class=\"bio-description\">Sunil Yadav is an experienced researcher with a keen focus on applying academic research to solve real-world problems. He believes a research paper has more value if it can be used for the welfare of society in general and the wellness of people in particular. He finished his PhD in mathematics and computer science and has a focus on computer vision, 3D data modelling, and medical imaging. His research interests revolve around understanding the visual data and producing meaningful output using the different areas of mathematics, including Deep learning, Machine learning, and computer vision.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/data-science-blog.com\/en\/blog\/2022\/05\/20\/generative-adversarial-networks\/<\/p>\n","protected":false},"author":0,"featured_media":8513,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/posts\/8512"}],"collection":[{"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/comments?post=8512"}],"version-history":[{"count":0,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/posts\/8512\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/media\/8513"}],"wp:attachment":[{"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/media?parent=8512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/categories?post=8512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wealthrevelation.com\/data-science\/wp-json\/wp\/v2\/tags?post=8512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}