What are generative adversarial networks?

A generative adversarial network (GAN) is an AI model composed of two neural networks—the generator and discriminator—that compete to improve their functions; the generator creates fake data resembling the training set, while the discriminator attempts to determine whether the data is authentic.

Demo AI
Things to know about generative adversarial networks
Why GAN? What are the benefits of GANs? What is the GAN structure? What are different categories of GANs? How do generative adversarial networks work? How are generative adversarial networks implemented? What are some of the challenges of GANs? ServiceNow for generative adversarial networks

Generative AI (GenAI) represents one of the most significant advancements in artificial intelligence in recent years. On the surface, this leap forward may feel like it occurred overnight—transforming the world through the introduction of powerful, capable and widely available AI solutions. However, the reality is that AI's new generative capabilities are the culmination of decades of research and development in several supporting technologies. The concept of the generative adversarial network, or GAN, is one such innovation that has played a pivotal role in shaping the landscape of artificial intelligence.

 

GAN origins

GANs were first conceptualised by Ian Goodfellow and several colleagues in 2014. The problem they were facing was the question of how to develop a computer system capable of producing original, realistic looking 'photographs' based on provided data. When faced with the daunting prospect of the sheer mathematical number crunching that would be involved, Goodfellow hit on an idea: Why not simply task one network with creating the images, and another with finding fault in the images? The two would then work in tandem, iteratively presenting new versions and identifying errors until the fake images could pass inspection.

The first generative adversarial network was born from that idea. As proposed, this innovative framework involves two opposing systems engaged in a contest where one's gain is the other's loss. Over time, both networks enhance their capabilities, leading to increasingly sophisticated data generation.

Expand All Collapse All Why GAN?

Generative adversarial networks have sparked considerable interest due to their unique ability to generate high-quality, realistic data across various domains—from creating AI-generated artwork and synthetic images or videos to assisting with product personalisation and probabilistic distribution modelling. Simply put, what began as an impromptu thought experiment has grown into a proven technology that carries significant practical applications. This has transformed how machines learn and create—and how businesses can benefit from them.

Introducing Now Intelligence Find out how ServiceNow is taking AI and analytics out of the labs to transform the way enterprises work and accelerate digital transformation. Get Ebook
What are the benefits of GANs?

There are several compelling advantages of applying GAN solutions for business applications. Consider the following:

Synthetic data generation

GANs excel in generating new data that mimics real data distributions. This is incredibly useful for data augmentation, enhancing machine learning models without additional real data. It also allows for effective anomaly detection and fosters creativity in generating new designs and concepts.

Improved results

Known for producing photorealistic and high-fidelity results, GANs are crucial in fields requiring detailed image and video synthesis. Whether for generating realistic environments in virtual systems or for creating new audio sequences in music, the quality of GAN outputs is often indistinguishable from actual recordings or images. This carries over into non-media data as well; the GAN process can refine synthetic information of all types until it matches the quality of actual data sets.

Reduced need for supervision

One of the standout features of GANs is their ability to learn without labelled datasets. This proves valuable in scenarios where labelled data is limited or expensive to obtain. GAN autonomy eliminates one of the major barriers that might otherwise prevent certain organisations or individuals from working within the framework.

Increased data production

GANs have the unique capability to autonomously imitate complex data distributions, enabling the efficient production of highly specific datasets. This feature is particularly useful in use cases requiring the rapid generation of large volumes of data, significantly reducing the need for manual data creation.

Reduced labour costs

By automating parts of the data generation and enhancement processes, GANs can significantly cut down on the hours typically associated with these tasks. This reduction in labour not only lowers costs but also allows human resources to be redirected towards more strategic activities, thereby optimising workforce allocation and enhancing productivity.

What is the GAN structure?

As addressed, generative adversarial networks are composed of two main neural network models trained simultaneously through adversarial processes. These opposing networks are called the generator model and the discriminator model.

Generator model

The generator's main task is to create data that is indistinguishable from genuine data. Starting from a random noise input, it uses this input to generate data outputs through a network of layers designed to progressively refine the data's details and quality. The generator improves over time, guided by the feedback from the discriminator on the authenticity of its outputs, with the ultimate goal being to produce data so convincing that it can fool the discriminator into thinking it is genuine.

Discriminator model

The discriminator acts as a judge in the GAN setup. It evaluates data to determine whether it is real (from the actual dataset) or fake (from the generator). The discriminator's objective is to accurately classify the input data, providing critical feedback to the generator on the quality of its outputs. This model helps in refining the generator by pushing it to produce better and more realistic outputs.

What are different categories of GANs?

In the decade or so that they have been around, generative adversarial networks have evolved into several distinct variants, each suited for different applications and challenges. Again, while many of these variations are specifically tailored towards image generation, they can often be applied to other uses as well.

Common types of GANs include: 

  • Vanilla GAN 
    This is the simplest form of GAN, where the generator and discriminator are straightforward neural networks. Vanilla GANs lay the foundational architecture for more complex models but might not be sufficient for high-complexity tasks.

  • Conditional GAN (cGAN) 
    These GANs condition both the generator and discriminator on additional information, allowing the model to generate data specific to given labels or tags. This approach makes possible more targeted and relevant data generation.

  • Deep convolutional GAN (DCGAN) 
    Integrating convolutional neural networks, DCGANs are particularly effective in tasks involving images. They utilise convolutional and convolutional-transpose layers in the generator and discriminator, enhancing the quality of image generation.

  • Laplacian pyramid GAN (LAPGAN) 
    LAPGAN uses a series of GANs arranged in a pyramid structure to generate images in a coarse-to-fine fashion. Each level of the pyramid refines the details of the image, allowing for the generation of higher resolution outputs.

  • Super-resolution GAN (SRGAN) 
    Focused on converting low-resolution images to high-resolution ones, SRGANs apply adversarial training to learn a mapping from low-res to high-res, which helps in recovering photo-realistic textures from heavily downsampled pictures.

How do generative adversarial networks work?

GANs function through a dynamic and competitive process between the generator and the discriminator models. This process ensures that the generated outputs progressively improve in quality and realism. Here is a breakdown of the steps involved:

  1. Initialisation
    The generator and discriminator are initialised with random training parameters so as to eliminate the risk of bias toward any specific outcome—these 'weights' are fine-tuned throughout the process

  2. Generator presents synthetic data
    The generator creates data from a random noise input, attempting to mimic the real data distribution.

  3. Discriminator evaluates and responds
    This model assesses both real data and the synthetic data from the generator. It tries to correctly classify what data is real and what is fake.

  4. Rewards are provided as data is identified and feedback given
    Rewards in GAN training refer to the adjustments made to the model parameters based on the discriminator's performance. If the discriminator correctly identifies real or fake data, it is 'rewarded' by having fewer adjustments needed in its parameters. Conversely, if it fails, more significant changes are made to improve its accuracy. The generator is also adjusted based on whether it successfully fools the discriminator.

  5. Iterative learning process continues
    The process is repeated with continuous exchanges between the generator and discriminator, improving through each cycle until the discriminator can no longer reliably distinguish the synthetic data from the actual data.

How are generative adversarial networks implemented?

Implementing GANs involves several key processes designed to ensure the network functions effectively and efficiently. Each of the following is integral to the GAN's architecture and function:

  • Importing the required libraries
    Setting up the coding environment by importing necessary software libraries provides the tools and functions needed for machine learning and data processing.

  • Defining a transform
    Transforms are used to preprocess the data into a format suitable for the neural network, ensuring that input data is normalised or augmented to improve training.

  • Loading the dataset
    This involves preparing and loading the data that the GAN will learn from, which could be images, texts or any other form of data applicable to the problem.

  • Defining parameters to be used in later processes
    Establishing key parameters—such as learning rate, number of epochs and batch sizes—helps dictate how the model trains.

  • Defining a utility class to build the generator
    This class encapsulates the architecture of the generator, detailing the layers and their functions that are crucial for generating new data.

  • Defining a utility class to build the discriminator
    Similar to the generator, this class outlines the structure of the discriminator, which will judge the authenticity of the generated data.

  • Building the GAN
    This involves integrating the generator and discriminator into a single model framework, ready for training.

  • Training the GAN
    The element sees the discriminator and generator trained through their adversarial dynamics, each improving in response to the other's performance.

What are some of the challenges of GANs?

Generative adversarial networks are powerful tools in AI, and have helped lay the foundation for modern generative solutions—but they are not without their faults. GANs present several challenges that can impact their effectiveness and application. The following potential obstacles require thoughtful consideration and tailored approaches to ensure that GANs are being used both effectively and responsibly:

Training instability

GANs are prone to instability during training, where the generator and discriminator may not learn effectively. To address this, researchers typically modify loss functions and optimise the architecture to better match the needs of the network.

Computational cost

While GANs can help organisations save money in terms of labour hours and enhanced productivity, the significant computational investments required for training GANs—especially with large and complex datasets—can be a barrier. Using more efficient network designs and leveraging hardware accelerations to manage these demands may provide a solution.

Overfitting

Like many machine learning models, GANs can overfit to training data (especially when data diversity is low), making them less effective on new, unseen data. Regularisation techniques, data augmentation and increasing dataset diversity can help mitigate this risk.

Bias and fairness

There is a danger of GANs replicating or amplifying biases present in the training data, leading to issues of unfairness or discrimination. To combat this, organisations and researchers should prioritise diverse training datasets while also implementing algorithms designed to identify and correct possible biases.

Interpretability and accountability

The 'black box' nature of GANs can make it hard to interpret their decision-making processes, which can be especially problematic in certain sensitive applications. Developing methods for better tracing, understanding, and explaining the behaviours of GANs is essential for ensuring accountability and trust in their applications.

ServiceNow Pricing ServiceNow offers competitive product packages that scale with you as your enterprise business grows and your needs change. Get Pricing
ServiceNow for generative adversarial networks

As a foundational technology of modern GenAI, generative adversarial networks have demonstrated significant potential across a range of industries and fields—from data augmentation and synthetic data generation to more complex applications like unsupervised learning. These networks offer promising prospects for businesses seeking to enhance data realism and diversity.

The Now Platform® by ServiceNow incorporates advanced AI capabilities that are ideal for supporting GANs and other AI-driven initiatives. It offers features such as natural language understanding, predictive analytics and intelligent automation—streamlining decision-making and operational efficiencies so businesses can focus more of their time and resources on growth. Additionally, the platform's ability to handle complex AI tasks securely and at scale ensures that businesses can leverage the full potential of GenAI technologies without compromising on performance or security.

See for yourself how ServiceNow and AI can transform your business; demo ServiceNow today!

Dive deeper into generative AI Accelerate productivity with Now Assist – generative AI built right into the Now Platform. Explore AI Contact Us
Resources Articles What is AI? What is Generative AI? What is a LLM? Analyst Reports IDC InfoBrief: Maximise AI Value with a Digital Platform Generative AI in IT Operations Implementing GenAI in the Telecommunication Industry Data Sheets AI Search Predict and prevent outages with ServiceNow® Predictive AIOps Ebooks Modernise IT Services and Operations with AI GenAI: Is it really that big of a deal? Unleash Enterprise Productivity with GenAI White Papers Enterprise AI Maturity Index GenAI for Telco