Nearly everyone is aware of how hot the field of machine learning is now. Google is doing machine learning. Amazon is doing machine learning. Facebook is doing machine learning. Every company on the planet wants to do something with machine learning. Mark Cuban, an American businessman, investor (including on the Shark Tank reality TV show), and owner of the Dallas Mavericks NBA team, recently said everyone should learn machine learning.

If machine learning is something we should learn and GAN is the hottest idea in machine learning, it stands to reason that it's a good idea to learn more about GAN.

There are plenty of interesting articles, videos, and other learning materials available on the internet that explain GAN. This article is a very introductory guide to GAN and some of the open source projects and resources where you can expand your knowledge about it and machine learning in general.

If you want to jump in quickly, I highly recommend beginning with Stanford University's lecture on Generative Models on YouTube. Also, Ian Goodfellow's original paper, "Generative Adversarial Networks" is downloadable as a PDF. Otherwise, continue reading for some of the background information and other tools and resources that should help you.

Statistical classification models

Before learning about GAN, it is important to know the differences between the models of statistical classification that are widely used in machine learning and statistics. In statistical classification, which is an area of study seeking to identify where a new observation belongs among a set of categories, there are two main models: the discriminative model and the generative model. The discriminative model belongs to supervised learning and the generative model belongs to unsupervised learning. This slide from Stanford's lecture explains the difference:

Discriminative models

The discriminative model tries to identify where a particular new item belongs in a category based on the features discovered from the new item. For example, let's say we want to create a very simple discriminative model system that will assign a given piece of dialogue to a particular movie category, and, in this case, whether it is from the movie The Avengers. Here is a line of sample dialogue:

"He's part of the Avengers, and the group will do everything in its power to keep the world safe. Loki better watch out."

Our pre-defined Avengers keywords group could include "Avengers" and "Loki." Our discriminative model algorithm will try to match the keywords associated with The Avengers from the given text and report the probability between 0.0 and 1.0, where a number closer to 1 indicates that the dialogue is most likely from The Avengers and a number closer to 0 indicates that it is not.

This was an extremely simple example of a discriminative model, but you probably get the idea. You can see that the discriminative model is heavily dependent on the quality of pre-defined categories but makes just a few assumptions.

Generative models

The generative model, instead of labeling the data, works by trying to draw some insight from a certain data set. If you remember the Gaussian distribution you probably learned in high school, you might get the idea right away.

For example, let's say this is the list of final exam scores in a class of 100 students.

10 students got 80% or above

80 students got 70% to 80%

10 students got 70% or lower

From this data, we can infer that most students scored in the 70s. This insight is based on the statistical distribution of a certain data set. If we see other patterns, we can also gather that data and make other inferences.

Generative models you may have heard of include the Gaussian mixture model, Bayesian models, the Hidden Markov model, and the variational encoder model. GAN also falls into the generative model but with a twist.

GAN's model

GAN attempts to combine the discriminatory model and the generative model by randomly generating the data through the generative model, then letting the discriminative model evaluate the data and use the result to improve the next output.

GAN's real implementation is much more complicated than this, but this is a general idea.

The easiest way to understand GAN is to think of a scenario where a detective and a counterfeiter are playing a repetitive guessing game where the counterfeiter tries to create a forgery of a $100 bill and the detective judges whether each item is real or fake. Here is a hypothetical dialogue of this scenario:

Counterfeiter: "Does this $100 look like real money?"Detective: "No! That does not look like a real $100 bill at all."Counterfeiter [holding a new design]: "Does this $100 bill look like real money?"Detective: "That is better but still not quite like real."Counterfeiter [holding a variation of the design]: "What about now?"Detective: "That is very close but still not like real."Counterfeiter [holding yet another variation]: "This should be like real, right?"Detective: "Yes! That is very close!"

OK. So, the detective is actually a partner-in-crime. In this example, the counterfeiter is the generator while the detective is the discriminator. As the play is iterated over and over, the probability that the forged currency is similar to the real currency likely gets better and better.

The primary difference between the counterfeiter–detective example and GAN is that the main purpose of GAN is not to create a 100% real output where there can be one and only one answer. Instead, you can think of GAN as some sort of super-creative engine that can generate many unexpected outputs that can surprise you but also satisfy your curiosity and expectations.

Machine learning

Before you start using GAN, you need some background knowledge on machine learning and the mathematics behind it.

If you are new to machine learning, you can access Goodfellow's Deep Learning textbook for free or buy a hard copy through the Amazon link from his website if you prefer.

Get started with GAN

Now that we understand some basics about machine learning and GAN, you may be ready to start using GAN. First, access Goodwell's original GAN code on GitHub under the BSD 3-Clause "New" or "Revised" License.

Topics

About the author

Bryant Son - Bryant Jimin Son is a Consultant at Red Hat, a technology company known for its Linux server and opensource contributions. At work, he is working on building the technology for clients leveraging the Red Hat technology stacks like BPM, PAM, Openshift, Ansible, and full stack development using Java, Spring Framework, AngularJS, Material design. Prior to joining Red Hat, Bryant was at Citi Group's Citi Cloud team, building the private Infrastructure as a Service (IaaS) cloud platform serving 8,...

Footer

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat.

Opensource.com aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. Red Hat and the Red Hat logo are trademarks of Red Hat, Inc., registered in the United States and other countries.