<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vaishak Bhuvan M R on Medium]]></title>
        <description><![CDATA[Stories by Vaishak Bhuvan M R on Medium]]></description>
        <link>https://medium.com/@imvbhuvan64?source=rss-151ac49a861e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*U69yCQzxFfM3WdPw3aI7qg.jpeg</url>
            <title>Stories by Vaishak Bhuvan M R on Medium</title>
            <link>https://medium.com/@imvbhuvan64?source=rss-151ac49a861e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 15:38:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@imvbhuvan64/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[“Regularized Linear Models — Ridge and Lasso”]]></title>
            <link>https://medium.com/@imvbhuvan64/regularized-linear-models-ridge-and-lasso-63ece38548b8?source=rss-151ac49a861e------2</link>
            <guid isPermaLink="false">https://medium.com/p/63ece38548b8</guid>
            <dc:creator><![CDATA[Vaishak Bhuvan M R]]></dc:creator>
            <pubDate>Sun, 12 Mar 2023 11:47:08 GMT</pubDate>
            <atom:updated>2023-03-12T12:06:52.901Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Regularized Linear Models — Ridge and Lasso Regression”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fA5D1NCUo1fSnjBoFkiJKQ.png" /></figure><blockquote><strong>Recap — Linear Regression</strong></blockquote><p>Linear Regression is a type of regression analysis that is used to model the relationship between a dependent variable (also known as the response variable) and one or more independent variables (also known as predictor variables).</p><p>In a simple linear regression model, there is only one independent variable, while in a multiple linear regression model, there are two or more independent variables.</p><p>The goal of linear regression is to find the equation of a straight line (also known as the regression line) that best fits the data. This is done by minimizing the sum of the squared differences between the predicted values of the dependent variable and the actual values of the dependent variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*VgbzqJ-POHjR6zTiHJ6ueQ.png" /><figcaption><strong>Linear Regression</strong></figcaption></figure><p>The equation of the regression line is given by:</p><p>y = b0 + b1<em>x1 + b2</em>x2 + … + bn*xn</p><p>where y is the dependent variable, x1, x2, …, xn are the independent variables, b0 is the intercept, and b1, b2, …, bn are the coefficients (also known as regression coefficients or weights).</p><p>The most widely used cost function for Linear Regression is the Mean Square Error(MSE):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cV8l0ej_8CY8GEjTf6-SMw.png" /><figcaption><strong>MSE</strong></figcaption></figure><p>Now let us understand what is regularization and why do we need it ….</p><blockquote><strong>What is Regularization ??!</strong></blockquote><p>Regularization is a technique used in machine learning to prevent overfitting and improve the generalization performance of a model.</p><p>In linear models, regularization involves adding a penalty term to the cost function, which controls the size of the model coefficients (also known as weights or parameters), the goal is to find the set of coefficients that best fit the training data. However, if the model is too complex or the number of features is large relative to the number of observations, the model can overfit the training data, meaning it captures noise and randomness in the data instead of the underlying patterns. This can lead to poor performance on new, unseen data.</p><p>Regularization helps to mitigate this problem by adding a penalty term to the cost function that discourages large coefficients.</p><blockquote><strong>Why Regularization ??!!</strong></blockquote><p>Regularization can help to prevent overfitting in linear models by shrinking the magnitude of the coefficients, effectively reducing the influence of predictor variables that are not important for predicting the response variable.</p><p>By adding a <strong>Penalty term</strong> to the <strong>objective function</strong>(Here, we shall consider MSE), regularization encourages models to have smaller coefficients, effectively reducing the complexity of the model and improving its performance on new data.</p><p>There are two common types of regularization used in linear models: <strong>L1 regularization — Lasso regularization</strong> and <strong>L2 regularization — Ridge regularization.</strong></p><blockquote><strong>L2 regularization — Ridge Regression</strong></blockquote><p>Ridge Regression, also called Tikhonov regularization is a regularized version of Linear Regression that forces the learning algorithm to not only fit the data but also keep the model weights as small as possible by adding the sum of the squared magnitude of the coefficients as the Penalty Term.</p><p>The Penalty term is multiplied by a hyperparameter <strong>alpha(α)</strong>, which controls the regularization of the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*MWQYDZHtse5cYy4dUfPHkw.png" /></figure><p>Where,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*nl-IJ8vCHFSpKtvOnqfpDw.png" /></figure><p>The addition of the penalty term in Ridge Regression encourages the model to have smaller coefficients, effectively reducing the complexity of the model and preventing overfitting. The hyperparameter <strong>α</strong> controls the strength of the penalty term, with larger values of <strong>α</strong> resulting in smaller coefficients and a simpler model.</p><p>The optimal value of the hyperparameter <strong>α</strong> can be determined using cross-validation techniques, such as k-fold cross-validation, to choose the value of <strong>α</strong> that gives the best performance on new data.</p><p><strong>Ridge</strong> Regression is called as <strong>L2 Regularizaton</strong>, because it involves adding a penalty term to the objective function of a linear regression model that is proportional to the squared magnitude of the coefficients (weights) of the model. The L2 norm is defined as the square root of the sum of the squared magnitudes of the coefficients.</p><p>The term L2 regularization and Ridge regression are often used interchangeably in the machine learning literature, as Ridge regression is a linear regression model that uses L2 regularization. The term L2 regularization is used more broadly in the context of machine learning to refer to any linear model that uses L2 regularization, not just Ridge regression.</p><p>In summary, Ridge Regression is a regularization technique used in linear regression models to prevent overfitting by adding a penalty term to the objective function that encourages the model to have smaller coefficients.</p><blockquote><strong>L1 Regularization — LASSO Regression</strong></blockquote><p>LASSO stands for <strong>L</strong>east <strong>A</strong>bsolute <strong>S</strong>hrinkage and <strong>S</strong>election <strong>O</strong>perator Regression, is another regularization technique used in linear regression models to prevent overfitting by adding a penalty term to the objective function the penalty term added to the objective function is the sum of the absolute value of the coefficients multiplied by a hyperparameter <strong>alpha(α)</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*0HsRoiDdzOf5KSDVibM7oA.png" /></figure><p>Where,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*Cs0u_NE6b500CWi0HubXDg.png" /></figure><p>The addition of the penalty term in Lasso Regression encourages the model to have smaller coefficients and also to set some coefficients exactly to zero, effectively reducing the complexity of the model and preventing overfitting. The hyperparameter <strong>α</strong> controls the strength of the penalty term, with larger values of <strong>α</strong> resulting in smaller coefficients and more coefficients being set to zero.</p><p>An important characteristic of Lasso Regression is that it tends to eliminate the weights of the least important features by setting them to <strong>Zero</strong>, In other words, Lasso Regression automatically performs feature selection and outputs a sparse model (i.e., with few nonzero feature weights).</p><p>The optimal value of the hyperparameter <strong>α</strong> can be determined using cross-validation techniques, such as k-fold cross-validation, to choose the value of <strong>α</strong> that gives the best performance on new data.</p><p>Lasso Regression is also known as L1 regularization because the penalty term added to the objective function is the L1 norm of the coefficients multiplied by a regularization parameter. The L1 norm is defined as the sum of the absolute magnitudes of the coefficients.</p><p>In summary, Lasso Regression is a regularization technique used in linear regression models to prevent overfitting by adding a penalty term to the objective function that encourages the model to have smaller coefficients and perform feature selection.</p><blockquote>NOTE:- The penalty term should be added to the cost function only during the Training Process, not during the error calculation</blockquote><blockquote><strong>Ridge Vs Lasso !!!!</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*roTgBIe8v8Bj9WPw0xT0jg.png" /><figcaption><strong>Generalization Graph</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hn5yz3i5IG1BTRtK9newbQ.png" /></figure><blockquote><strong>Disadvantages………</strong></blockquote><p>Disadvantages of Ridge Regression:</p><ol><li>Ridge Regression does not perform feature selection, which can result in a model with many non-zero coefficients, making it more difficult to interpret.</li><li>The choice of the regularization parameter is important, and it can be challenging to find the right balance between bias and variance in the model.</li><li>Ridge Regression can be sensitive to the scaling of the predictor variables, which can affect the performance of the model.</li></ol><p>Disadvantages of Lasso Regression:</p><ol><li>Lasso Regression can be sensitive to the choice of the regularization parameter and may require more careful tuning than Ridge Regression.</li><li>Lasso Regression may not perform well in situations where there are many correlated predictors, as it tends to select only one of the correlated predictors and set the others to zero.</li><li>Lasso Regression may not be suitable for models with a large number of predictor variables, as it can be computationally expensive to fit the model.</li></ol><p>In general, the choice between Ridge Regression and Lasso Regression depends on the specific data set and the goals of the analysis, and a careful consideration of the advantages and disadvantages of each technique is necessary.</p><blockquote><strong>Future Reading — Elastic Net</strong></blockquote><p>Elastic Net is a middle ground between Ridge Regression and Lasso Regression. The regularization term is a simple mix of both Ridge and Lasso’s regularization terms, try exploring this.</p><blockquote><strong>Thank You….</strong></blockquote><p><a href="https://www.linkedin.com/in/vaishak-bhuvan-m-r-7a743520a/">LinkedIn</a> | <a href="https://twitter.com/BhuvanVaishak">Twitter</a> | <a href="https://github.com/imvbhuvan">Github</a> | <a href="https://www.instagram.com/vaishak_bhuvan_mr/">Instagram</a> |</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63ece38548b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleashing the Power of Generative AI: Understanding Generative Adversarial Networks]]></title>
            <link>https://medium.com/@imvbhuvan64/unleashing-the-power-of-generative-ai-understanding-generative-adversarial-networks-d40934b9f25b?source=rss-151ac49a861e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d40934b9f25b</guid>
            <dc:creator><![CDATA[Vaishak Bhuvan M R]]></dc:creator>
            <pubDate>Sun, 29 Jan 2023 06:03:24 GMT</pubDate>
            <atom:updated>2023-03-12T11:48:53.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*9mi0ewoenwxaXnI613vrPQ.jpeg" /></figure><blockquote>What is Generative AI ??!!</blockquote><p>Generative AI is a subfield of Artificial Intelligence that focuses on the ability of machines to generate new, previously unseen data that is similar to existing data. This can include generating images, text, speech, and other types of data. Generative AI models are trained on large datasets of existing data, and then use that knowledge to generate new, similar data. Generative Adversarial Networks (GANs) are a popular generative AI model, which use a two-part architecture to generate new data.</p><blockquote>Introduction to Generative Adversarial Networks</blockquote><p>GANs, an unsupervised generative model, worked on the principle of maximum likelihood and used adversarial training. Right from the inception of <strong>Generative adversarial networks</strong> (GANs), they have been the most discussed and researched domains in the field of computer science and other domains. GANs are an exciting and rapidly changing field, delivering on the promise of generative models in their ability to generate realistic examples across a range of problem domains,With the advent of GANs that work on the principle of generative and adversarial manner, researchers can synthesize novel and quality images. However, the synthesizing of images has not just started with GANs. There are a few research works to synthesize images using convolutional neural networks (CNN).</p><blockquote>A detailed design….</blockquote><p>A Generative Adversarial Network (GAN) has two parts:</p><ul><li>The Generator Network which learns to generate plausible data. The generated instances become negative training examples for the discriminator.</li><li>The Discriminator Network, learns to distinguish the generator’s fake data from real data. The discriminator penalizes the generator for producing implausible results.</li></ul><p>When training begins, the generator produces obviously fake data, and the discriminator quickly learns to tell that it’s fake:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*YjT9brlA4ciLL4AB9aw8TQ.png" /><figcaption>Sample Generation — 1</figcaption></figure><p>As training progresses, the generator gets closer to producing output that can fool the discriminator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*N0t7YFFm66NQVSd1JRJgiw.png" /><figcaption>Sample Generation — 2</figcaption></figure><p>Finally, if generator training goes well, the discriminator gets worse at telling the difference between real and fake. It starts to classify fake data as real, and its accuracy decreases</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*aupZaLdqoG7E1dENQHFeHA.png" /><figcaption>Sample Generation — 3</figcaption></figure><p>Both the Generator and the Discriminator are Neural Networks which compete through adversarial training, the Architecture and Training of the GAN Model is discussed in the coming sections.</p><blockquote>Architecture of the Network</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYY1I-GMPk_lS_24yCuFrQ.png" /><figcaption>Architecture</figcaption></figure><p><strong><em>Discriminator</em></strong> — It is a supervised approach means It is a simple classifier that predicts whether data is fake or real. It is trained on real data and provides feedback to a generator.</p><p><strong><em>Generator</em></strong> — It is an unsupervised learning approach. It will generate data that is fake data based on original(real) data. It is also a neural network that has hidden layers, activation, and loss function. Its aim is to generate a fake image based on feedback and make the discriminator fool that it cannot predict a fake image. And when the discriminator is made a fool by the generator, the training stops and we can say that a generalized GAN model is created.</p><p>The generative model captures the distribution of data and is trained in such a manner to generate the new sample that tries to maximize the probability of the discriminator making a mistake (maximize discriminator loss). The discriminator on other hand is based on a model that estimates the probability that the sample it receives is from training data not from the generator and tries to classify it accurately and minimize the GAN accuracy. Hence the GAN network is formulated as a minimax game where the Discriminator is trying to minimize its reward and the generator is trying to maximize the Discriminator loss, the training of the network and Loss functions are discussed in the next section</p><blockquote>Training the Generator and Discriminator…</blockquote><p>The discriminator’s training data comes from two sources:</p><ul><li><strong>Real data</strong> instances, such as real pictures of people. The discriminator uses these instances as positive examples during training.</li><li><strong>Fake data</strong> instances created by the generator. The discriminator uses these instances as negative examples during training.</li></ul><p>The discriminator connects to two loss functions. During discriminator training, the discriminator ignores the generator loss and just uses the discriminator loss. We use the generator loss during generator training, as described in the next part.</p><p>During discriminator training:</p><p>· The discriminator classifies both real data and fake data from the generator.</p><p>· The discriminator loss penalizes the discriminator for misclassifying a real instance as fake or a fake instance as real.</p><p>· The discriminator updates its weights through <a href="https://developers.google.com/machine-learning/glossary/#b">backpropagation</a> from the discriminator loss through the discriminator network.</p><p>The generator part of a GAN learns to create fake data by incorporating feedback from the discriminator. It learns to make the discriminator classify its output as real.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*CkSKehQUp6fKxXQeG1vmqQ.png" /><figcaption>Discriminator Training</figcaption></figure><p>Generator training requires tighter integration between the generator and the discriminator than discriminator training requires. The portion of the GAN that trains the generator includes:</p><ul><li>Random input</li><li>Generator network, which transforms the random input into a data instance</li><li>Discriminator network, which classifies the generated data</li><li>Discriminator output</li><li>Generator loss, which penalizes the generator for failing to fool the discriminator</li></ul><p>To train a neural net, we alter the net’s weights to reduce the error or loss of its output. In our GAN, however, the generator is not directly connected to the loss that we’re trying to affect. The generator feeds into the discriminator net, and the discriminator produces the output we’re trying to affect. The generator loss penalizes the generator for producing a sample that the discriminator network classifies as fake. This extra chunk of the network must be included in backpropagation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*d-pL0N8Yvk17RmjcWQuFLQ.png" /><figcaption>Generator Training</figcaption></figure><blockquote>Loss Functions:-</blockquote><p>A GAN can have two loss functions: one for generator training and one for discriminator training. The generator and discriminator losses look different in the end and are updated by using the gradient method whose equations are given below,</p><p><strong>MinMax Loss:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*SEbA7yFVK20TDeNH_40bxg.png" /><figcaption>Minmax loss equation</figcaption></figure><p>Where,</p><p>❏<strong>D(x)</strong> is the discriminator’s estimate of the probability that real data instance x is real.</p><p>❏<strong>Ex</strong> is the expected value over all real data instances.</p><p>❏<strong>G(z)</strong> is the generator’s output when given noise z.</p><p>❏<strong>D(G(z))</strong> is the discriminator’s estimate of the probability that a fake instance is real.</p><p>❏<strong>Ez</strong> is the expected value over all random inputs to the generator</p><p><strong>Discriminator Gradient Equation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*Ija2hS-EvTe6IsSfl-w-Zw.png" /></figure><p><strong>Generator Gradient Equation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*BzRacBurPViZRO4KrGRn0w.png" /></figure><blockquote>Evaluation Metrics !!</blockquote><p><strong>Inception Score:</strong></p><p>It is a metric to evaluate the quality and diversity of synthesized images by generative models. First, they computed the conditional probability of an instance belonging to a class. Later, these conditional probabilities are used to compute the inception score on a pre-trained inception network. If the conditional label distribution has low entropy, then the generated images are of good quality. To produce a variety of images, the network should have a low marginal conditional probability distribution. The inception score ranges between 1 and total classes. The limitation of this metric is that it does not consider the statistics (mean, variance, and standard deviation) of the original data distribution to compare with generated sample distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*mg-JxWRg1D-dswIPCAni0A.png" /><figcaption><strong>Inception score Eq.</strong></figcaption></figure><p><strong>Mode Score:</strong></p><p>This metric overcomes the limitation faced by IS metric and considers the statistics of prior distribution to evaluate the quality of images and diversity of images. The mode score can be computed using the Equation shown below represents the distribution of ground truth labels computed using the original data distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*_XBDKB6TkoPNpaRe7lDC4g.png" /><figcaption><strong>Mode Score Eq.</strong></figcaption></figure><blockquote>Implementation of GAN using the MNSIT Digit Images Dataset</blockquote><pre>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>import os <br>import tensorflow as tf<br>from tensorflow.keras.layers import Input, Dense, LeakyReLU, Dropout, BatchNormalization<br>from tensorflow.keras.models import Model<br>from tensorflow.keras.optimizers import SGD, Adam<br><br>mnist = tf.keras.datasets.mnist <br>(x_train, y_train), (x_test, y_test) = mnist.load_data()<br># Scale the inputs in range of (-1, +1) for better training<br>x_train, x_test = x_train / 255.0 * 2 - 1, x_test / 255.0 * 2 - 1<br><br>for i in range(49):<br>  plt.subplot(7, 7, i+1)<br>  plt.axis(&quot;off&quot;)<br>  #plot raw pixel data<br>  plt.imshow(x_train[i])<br>plt.show()<br><br>N, H, W = x_train.shape  #number, height, width<br>D = H * W   #dimension (28, 28)<br>x_train = x_train.reshape(-1, D) <br>x_test = x_test.reshape(-1, D)<br><br># Defining Generator Model<br>latent_dim = 100<br>def build_generator(latent_dim):<br>  i = Input(shape=(latent_dim,))<br>  x = Dense(256, activation=LeakyReLU(alpha=0.2))(i)<br>  x = BatchNormalization(momentum=0.7)(x)<br>  x = Dense(512, activation=LeakyReLU(alpha=0.2))(x)<br>  x = BatchNormalization(momentum=0.7)(x)<br>  x = Dense(1024, activation=LeakyReLU(alpha=0.2))(x)<br>  x = BatchNormalization(momentum=0.7)(x)<br>  x = Dense(D, activation=&#39;tanh&#39;)(x)  #because Image pixel is between -1 to 1.<br>  model = Model(i, x)  #i is input x is output layer<br>  return model<br><br>def build_discriminator(img_size):<br>  i = Input(shape=(img_size,))<br>  x = Dense(512, activation=LeakyReLU(alpha=0.2))(i)<br>  x = Dense(256, activation=LeakyReLU(alpha=0.2))(x)<br>  x = Dense(1, activation=&#39;sigmoid&#39;)(x)<br>  model = Model(i, x)<br>  return model<br><br># Build and compile the discriminator<br>discriminator = build_discriminator(D)<br>discriminator.compile ( loss=&#39;binary_crossentropy&#39;, optimizer=Adam(0.0002, 0.5), metrics=[&#39;accuracy&#39;])<br># Build and compile the combined model<br>generator = build_generator(latent_dim)<br><br>## Create an input to represent noise sample from latent space<br>z = Input(shape=(latent_dim,))<br>## Pass noise through a generator to get an Image<br>img = generator(z)<br>discriminator.trainable = False<br>fake_pred = discriminator(img)<br><br>combined_model_gen = Model(z, fake_pred)  #first is noise and 2nd is fake prediction<br># Compile the combined model<br>combined_model_gen.compile(loss=&#39;binary_crossentropy&#39;, optimizer=Adam(0.0002, 0.5))<br><br>batch_size = 32<br>epochs = 12000<br>sample_period = 200<br>ones = np.ones(batch_size)<br>zeros = np.zeros(batch_size)<br>#store generator and discriminator loss in each step or each epoch<br>d_losses = []<br>g_losses = []<br>#create a file in which generator will create and save images<br>if not os.path.exists(&#39;gan_images&#39;):<br>  os.makedirs(&#39;gan_images&#39;)<br>  <br>def sample_images(epoch):<br>  rows, cols = 5, 5<br>  noise = np.random.randn(rows * cols, latent_dim)<br>  imgs = generator.predict(noise)<br>  # Rescale images 0 - 1<br>  imgs = 0.5 * imgs + 0.5<br>  fig, axs = plt.subplots(rows, cols)  #fig to plot img and axis to store<br>  idx = 0<br>  for i in range(rows):  #5*5 loop means on page 25 imgs will be there<br>    for j in range(cols):<br>      axs[i,j].imshow(imgs[idx].reshape(H, W), cmap=&#39;gray&#39;)<br>      axs[i,j].axis(&#39;off&#39;)<br>      idx += 1<br>  fig.savefig(&quot;gan_images/%d.png&quot; % epoch)<br>  plt.close()<br>  <br># Main training loop<br>for epoch in range(epochs):<br>  ### Train discriminator ###<br>  # Select a random batch of images<br>  idx = np.random.randint(0, x_train.shape[0], batch_size)<br>  real_imgs = x_train[idx]  #MNIST dataset<br>  # Generate fake images<br>  noise = np.random.randn(batch_size, latent_dim)  #generator to generate fake imgs<br>  fake_imgs = generator.predict(noise)<br>  # Train the discriminator<br>  d_loss_real, d_acc_real = discriminator.train_on_batch(real_imgs, ones)  #belong to positive class(real imgs)<br>  d_loss_fake, d_acc_fake = discriminator.train_on_batch(fake_imgs, zeros)  #fake imgs<br>  d_loss = 0.5 * (d_loss_real + d_loss_fake)<br>  d_acc  = 0.5 * (d_acc_real + d_acc_fake)<br>  ### Train generator ###<br>  noise = np.random.randn(batch_size, latent_dim)<br>  g_loss = combined_model_gen.train_on_batch(noise, ones)  <br> <br>  noise = np.random.randn(batch_size, latent_dim)<br>  g_loss = combined_model_gen.train_on_batch(noise, ones)<br>  # Save the losses<br>  d_losses.append(d_loss) <br>  g_losses.append(g_loss)<br>  if epoch % 100 == 0:<br>    print(f&quot;epoch: {epoch+1}/{epochs}, d_loss: {d_loss:.2f}, d_acc: {d_acc:.2f}, g_loss: {g_loss:.2f}&quot;)<br>  if epoch % sample_period == 0:<br>      sample_images(epoch)<br>      <br>plt.plot(g_losses, label=&#39;g_losses&#39;)<br>plt.plot(d_losses, label=&#39;d_losses&#39;)<br>plt.legend()</pre><blockquote>Results after Implementing the above code:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*M42IvrAxW6EjDTpPoeXAQg.png" /></figure><p>The Discriminator and Generator losses are plotted in the above Figure, as the number of epochs increases. By interpreting the graph above, it is clear that models try to fool each other in terms of generating samples. The losses of both the networks are almost the same towards the end of the epochs hence we conclude that the model is trained enough to generate samples that resemble the original samples</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*xrZfVFXHZN-5ISq3JhhbUA.png" /></figure><p>By interpreting <strong>Figure (a)</strong> It is clear that no information is extracted from the generator and the discriminator is intelligent enough to identify it as fake.</p><p>By interpreting <strong>Figure (b)</strong> Generator is slowly being capable to extract some information that can be observed.</p><p>By interpreting <strong>Figure (c)</strong>It is inferred that the Generator is capable to build as it is an image of MNIST dataset and there are high chances of the Discriminator being a Fool</p><blockquote>Scope of Generative Adversarial Networks…</blockquote><p>· Generate new data from available data — It means generating new samples from an available sample that is not similar to a real one.</p><p>· Generate realistic pictures of people that have never existed.</p><p>· GANs is not limited to Images, it can generate text, articles, songs, poems, etc.</p><p>· Generate Music by using some clone Voice — If you provide some voice then GANs can generate a similar clone feature of it. In this [2] research paper, researchers from NIT in Tokyo proposed a system that is able to generate melodies from lyrics with help of learned relationships between notes and subjects.</p><p>· Text to Image Generation (Object GAN and Object Driven GAN)</p><p>· Creation of anime characters in Game Development and animation production.</p><p>· Image to Image Translation — We can translate one Image to another without changing the background of the source image. For example, Gans can replace a dog with a cat.</p><p>· Low resolution to High resolution — If you pass a low-resolution Image or video, GAN can produce a high-resolution Image version of the same.</p><p>· Prediction of Next Frame in the video — By training a neural network on small frames of video, GANs are capable to generate or predict a small next frame of video. For example, you can have a look at below GIF</p><p>· Interactive Image Generation — It means that GANs are capable to generate images and video footage in an art form if they are trained on the right real dataset.</p><p>· Speech — Researchers from the College of London recently published a system called GAN-TTS that learns to generate raw audio through training on 567 corpora of speech data.</p><blockquote>Closing words….</blockquote><p>In conclusion, Generative Adversarial Networks (GANs) are a powerful and versatile tool for generating new data in a wide range of applications, from image and video synthesis to natural language processing. GANs have been used to generate realistic images, videos, and text, and have many potential uses in areas such as art, entertainment, and even medicine. However, GANs are still a relatively new and rapidly-evolving field, and there is much research yet to be done to fully unlock their potential. Overall, GANs are a fascinating and promising area of machine learning that will likely continue to play a major role in shaping the future of AI.</p><p>The article is written as a part of my learning process in various deep learning architectures, by referring the ocean of resources available on the Internet.</p><blockquote>Thank You…</blockquote><p><a href="https://www.linkedin.com/in/vaishak-bhuvan-m-r-7a743520a/">LinkedIn</a> | <a href="https://twitter.com/BhuvanVaishak">Twitter</a> | <a href="https://github.com/imvbhuvan">Github</a> | <a href="https://www.instagram.com/vaishak_bhuvan_mr/">Instagram</a> |</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d40934b9f25b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>