How does a generative adversarial network work?

A generative adversarial network (GAN) is a modern machine learning model that employs two neural networks to produce realistic synthetic data. GANs can generate images, text, and even music. This concept is used in various fields, including image and video generation, art, design, and data augmentation.

What does generative adversarial network mean?

A generative adversarial network, GAN for short, is a framework for generating synthetic data from the field of machine learning, primarily used for training networks in unsupervised learning. The model consists of two artificial neural networks—the generator and the discriminator—that work against each other.

  • Generator: The generator’s job is to create new data instances that look convincingly real, closely resembling the original dataset. The generative neural network starts with a random noise and achieves continuous improvements through training. The generator learns to map a vector of latent variables to the specific result space, generating outputs that fit a particular distribution. Its ultimate goal is to produce artificial data that can fool the discriminator.
  • Discriminator: This network is trained on a known dataset to differentiate between real and synthetic data until it achieves acceptable accuracy. The discriminator evaluates the authenticity of the data it receives, determining whether the instances come from the original dataset or if they are fabricated.

The competing networks are trained simultaneously, with the generator competing against the discriminator until it produces data that the discriminator can no longer identify as fake. Backpropagation is employed to optimize the weights of both networks during each training step. This process allows the two neural networks to continuously improve each other, gradually refining the generated distribution to closely match the real one given enough training time. Once training is complete, the generator can be used to produce realistic-looking synthetic data.

Note

Generative adversarial networks were initially used exclusively as a model for unsupervised learning, but have now also proven themselves when it comes to semi-supervised learning, supervised learning and reinforcement learning.

GANs compared to other machine learning models

Generative adversarial networks differ from other machine learning methods in several ways. GANs function as implicit generative models, meaning they do not model a direct likelihood function or provide a method to identify latent variables. Instead, GANs generate new data instances through the competition between the two networks, the generator and the discriminator.

In contrast to other approaches, which generate data step by step, GANs are able to generate a complete sample in just one run. In addition, there are no restrictions on the type of function used by the network.

AI Tools at IONOS
Empower your digital journey with AI
  • Get online faster with AI tools
  • Fast-track growth with AI marketing
  • Save time, maximize results

How do Generative adversarial networks work? The training process

The training process for generative adversarial networks consists of several steps. The following overview illustrates how the training of GANs works in detail:

  1. Initialization: The two neural networks—the generator and the discriminator—are created and initialized with random parameters.
  2. Generation of fake data: The generator takes a random vector as input to produce synthetic data. Since it hasn’t yet been trained, the initial output resembles random noise.
  3. Evaluation by discriminator: The discriminator receives both real data samples and the generator’s synthetic outputs. Its role is to differentiate real from fake data, though it also starts without training, so its initial evaluations are imprecise.
  4. Feedback and updating of weights: Using backpropagation, both networks adjust their parameters. The generator learns to create increasingly realistic data, while the discriminator improves its accuracy in distinguishing real from artificial samples.
  5. Iteration: The generative adversarial network cycles through steps 2 to 4, gradually refining both networks until the generator produces data so convincing that the discriminator can no longer reliably identify it as synthetic—or until the desired quality level is reached.

In which areas are GANs used?

Generative adversarial networks, which are part of artificial intelligence, are already being used successfully in various industries. The main areas of application are:

  • Image and video generation: GANs are widely used in film production and game development to create highly realistic images and video sequences. This technology also helps companies visualize products, such as shoes or clothing, more effectively and supports the creation of virtual environments.
  • Medicine: In medical imaging, GANs are valuable for both training doctors and enhancing diagnostic procedures. They also address privacy concerns by generating synthetic medical images, providing researchers with data while maintaining patient confidentiality.
  • Data augmentation: GANs can create additional training data for machine learning models, especially helpful in scenarios with limited real examples, to improve model accuracy and performance.
  • Speech recognition and synthesis: GANs enhance natural language generation and optimize speech synthesis systems, producing new, realistic audio samples beyond traditional methods.
  • Science: In scientific research, GANs support diverse applications, such as reconstructing velocity and scalar fields in turbulent flows. They’ve also been used to generate new molecules targeting inflammation, cancer, and fibrosis.
  • Art and design: Artists and designers draw on GAN architecture to create innovative artworks and designs.

Advantages and disadvantages of generative adversarial networks

Generative adversarial networks open new possibilities for creating realistic artificial data, especially in image and video generation. One key advantage is their ability to produce high-quality data without using explicit probability models, setting them apart from other generative models. This flexibility allows for many customizable features, supporting a variety of applications.

However, GANs also face challenges, particularly with training stability. A common issue, mode collapse, can occur if the generator produces only limited data variations – often a result of the generator training too frequently without corresponding updates to the discriminator. Additionally, GANs carry risks of misuse, such as generating realistic deepfakes, spreading disinformation, or enabling identity theft.

Advantages Disadvantages
High-quality data Unstable training process
Flexible model Can be misused e.g. for deepfakes
Suitable for many application scenarios
Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top