top of page
Shayaan

What are GANs?

Updated: Sep 8, 2022

What are 'Generative Adversarial Networks' and how do they work? Click here to learn more about GANs!


Figure 1: A computer with code


What are GANs?


Generative Adversarial Networks (or GANs for short) are a class of neural networks that are used for generating new, previously unseen data. This data can range from something as simple as a list of numbers to something as complex as audio or images.


How do GANs Work?


GANs contain 2 neural networks: a generator and a discriminator. The job of the generator is to learn how to generate new forms of the desired data, and the job of the discriminator is to determine whether the data given to it is real (was part of the original dataset), or fake (generated by the generator).


How are GANs Trained?


Initially, the discriminator is trained using a dataset in which each piece of data is labelled as either ‘real’ or ‘fake’. The discriminator is now able to distinguish between real data and fake data. Next, the generator is trained using the discriminator. The generator is trained so that it is able to fool the discriminator since this means the data it outputs is more realistic. The weights and biases in both neural networks are adjusted during training. This causes the discriminator to become better at distinguishing between real and fake data as well as causing the generator to produce more realistic data.



Figure 2: The generator usually takes in a randomized input (noise) and uses this to generate the data. By altering the noise, the image produced will be altered.


The Problems with GANs


If the discriminator learns too fast compared to the generator, the generator will never be able to fool it. This means that the overall loss of the network (how poorly it performs) will be very high regardless of how the weights and biases are adjusted. This means that the generator will be unable to learn.


GANs can also be affected by ‘mode collapse’ when they overfit a dataset. This occurs when the generator is learning faster than the discriminator. For example, if we are training a GAN to generate images of cats and dogs but the discriminator is poor at recognising fake dogs, the generator may begin only producing images of dogs as this will minimise its loss.


Like with most things in Computer Science, the effectiveness of a GAN depends on the processing power and memory available; The quality of data produced by a GAN can vary dramatically depending on the computer hardware being used.


Personal Opinion


To me, GANs are incredibly impressive. They are able to generate detailed images of faces, animals and much more. There are variants of GANs such as CycleGAN that perform translations on data (For example, converting a picture of a city during summer to a picture of the same city in winter) and the Wasserstein GAN which solves the problem of mode collapse.




68 views0 comments

Recent Posts

See All

Comments


bottom of page