Generative Adversarial Networks GANs 2 How Generative Adversarial Networks Work

Mondo Technology Updated on 2024-02-06

How does the Generative Adversarial Network GANs work?

A generative adversarial network (GANs) is a framework consisting of two neural networks that are trained adversarially at the same time—a discriminator and a generator. The discriminator separates the generated data from the real data, while the generator generates synthetic data that attempts to model the real data. Training makes the generator better at generating real samples to trick the discriminator, thus enhancing the generator's discriminating ability. GANs are an effective tool for producing realistic, high-quality output in multiple domains, including text and image generation, as this back-and-forth competition leads to the production of increasingly convincing and indistinguishable synthetic data.

Let's take an example of generating an image of a dog.

Step 1 - Training of the discriminator

First, some random noise signal is sent to a generator, which generates some useless images that contain noise.

The discriminator has two inputs. The first is a sample output image generated by the generator, and the second is a sample of a real-world dog image.

Thereafter, the discriminator populates some values (probabilities) after comparing the two images, which can be seen in Figure 2. It outputs image calculations for the generator. 3 and 05. Calculate for real-world images. 9 and 02。

Now, the error is calculated by comparing the probability of the generated image to 0 (zero) and comparing the probability of the real word image to 1 (one). (Example-0.)5 and -02)。

After calculating the individual errors, it calculates the cumulative error (loss) of backpropagation and adjusts the weights of the discriminators. This is how discriminators are trained.

Step 2Builder training

As previously described in step 1, the loss is backpropagated to the discriminator to adjust its weights. Now we also need to backpropagate the error to the generator so that it can also adjust its weights and train itself to generate improved images.

Now, the image generated by the generator is used as input to the generator itself, rather than random noise.

The newly generated image from the generator will now be fed into the discriminator, which again calculates the probability, for example. 1 and 02。

The error will now be calculated by comparing the probability of the resulting image to 1 (one).

After calculating the individual errors, it calculates the cumulative error (loss) of the backpropagation and adjusts the weights of the generator. That's how the generator is trained.

After a few iterations, you'll see that the generator starts generating images that are close to real-world images.

Gans addresses this challenge with a unique setup, viewing it as a supervised learning problem involving two key components: the generator, which learns to generate new instances, and the discriminator, which is responsible for distinguishing between real instances and generated instances. With adversarial training, these models interact competitively until the generator expertly creates real samples, which tricks the discriminator about half the time.

This dynamic area of Gans has grown rapidly, demonstrating an extraordinary ability to generate photorealistic content across a variety of domains. Notable applications include image-to-image translation tasks and the creation of photorealistic images that are indistinguishable from the real**, demonstrating the transformative potential of GANs in the field of generative modeling.

Related Pages