Create Any Image with C# And A Generative Adversarial Network

Mark Farragher
11 min readDec 13, 2019

In this article I’m going to build a specialized neural network architecture called a Generative Adversarial Network (GAN).

GANs are weird. Here’s what they look like:

The Generator is a convolutional neural network (CNN) laid out in reverse.

A normal CNN reads in an image and outputs a list of class probabilities which usually indicate if the image contains a person, animal, or object.

But a reverse CNN does the opposite: we create a 1-dimensional class vector (just a list of numbers) and the network will convert this information to a fully realized machine-generated color image. And by tweaking the class vector, we can make the network generate any kind of image.

Of course, these images might not be particularly good. The generator might try to generate a picture of a horse, but how would it know if the output image looks anything like a real horse?

This is where the Discriminator comes in.

The discriminator is a regular CNN that is trained to identify images of people, animals, objects, or landscapes. Its job is to look at the images created by the generator, compare them to a dataset of real images, and correctly identify every real and generated image.

--

--

Responses (3)