Chapter 17: Representation Learning and Generative Learning Using Autoencoders and Gans

Will Toth
3 min readJun 26, 2021

A Review of Hands-On Machine Learning with Scikit-Learn, Keras & Tensorflow by Aurélien Géron

Which one of these Obamas is delivering a real speech and which one is fake? BBC

Generative Adversarial Networks

Generative Adversarial Networks (GANs) are just that, adversarial. I like to think of GANs as a form of coevolution like one would see in nature. One example of this is the cheetah and the gazelle. We must ask ourselves how two of the fastest creatures on the planet exist in the exact same place at the same time. This is because of coevolution, or evolution where one animals evolution affects the others evolution. In this case the Cheetah that aren’t fast enough to catch gazelle reproduce at a lower rate than cheetahs that are fast enough to catch gazelle. The same thing happens with gazelle where if they are fast enough to escape cheetah they will produce more than if they are too slow to escape. Thus, these two have coevolved to both be able to achieve speeds over 60 mph.

This long-winded example is similar to GANs because GANs have a similar coevolution between the Generator (which creates fakes in an attempt to trick the discriminator) and the Discriminator (which attempts to classify images provided by the Generator as real or fake). So, as the Generator gets better at producing fakes the Discriminator gets better training data and thus gets better at detecting fakes. This feedback cycles through as many epochs as the creator designates with them improving (or stagnating) with each adversarial battle.

GANs are extremely difficult to train. The general method for doing so is in two phases. Phase one dictates that the generator creates the first round of fake images and then the Discriminator will evaluate the fake images as well as an equal number of real images. But, during phase one only the discriminator is trained. Then, during phase two the generator gets trained. To do this we turn off the training for the Discriminator and setting the Generators fake images to be considered real by the Discriminator (which isn’t currently training). Theoretically, all GANs will eventually reach a Nash Equilibrium where the Generator produces images that are effectively real and the Discriminator can detect anything that is less than absolutely perfect, reducing the contest to a mere coin flip on every image as to whether it is real or fake.

My Thoughts

This Chapter was really cool to me because I have known about GANs for a while but until now did not know how they worked. This is due to the introduction of deep fakes into the general public. This is where a photo or a video of a prevalent figure is introduced online that is nearly indistinguishable from what these people really look, act, or sound like. Notable examples of this include the reanimation of Albert Einstein as well as the changing of modern day figures like Barack Obama. These deep fakes are extremely convincing and from my understanding can be trained from a small amount of data (whether it being a few photos or a short video and audio clip). The power that this ability holds is truly astounding and can have serious implications in the future as these deep fakes become more and more prevalent. Leading to more public discourse and outrage. However, there are already efforts to get ahead of this inevitability so that we can identify what images and videos are faked to preserve peoples reputations and the general peace online. One example of this is from Facebook where they are giving out a huge prize for whoever can create the best detector for these deep fakes. But as the technology continues to progress so will the detection tools that we will need.

Thanks for reading!

If you have any questions or feedback please reach out to me on twitter @wtothdev or leave a comment!

Additionally, I wanted to give a huge thanks to Aurélien Géron for writing such an excellent book. You can purchase said book here (non-affiliate).

Disclaimer: I don’t make any money from any of the services referenced and chose to read and review this book under my own free will.

--

--