Book Image

Generative Adversarial Networks Projects

By : Kailash Ahirwar
Book Image

Generative Adversarial Networks Projects

By: Kailash Ahirwar

Overview of this book

Generative Adversarial Networks (GANs) have the potential to build next-generation models, as they can mimic any distribution of data. Major research and development work is being undertaken in this field since it is one of the rapidly growing areas of machine learning. This book will test unsupervised techniques for training neural networks as you build seven end-to-end projects in the GAN domain. Generative Adversarial Network Projects begins by covering the concepts, tools, and libraries that you will use to build efficient projects. You will also use a variety of datasets for the different projects covered in the book. The level of complexity of the operations required increases with every chapter, helping you get to grips with using GANs. You will cover popular approaches such as 3D-GAN, DCGAN, StackGAN, and CycleGAN, and you’ll gain an understanding of the architecture and functioning of generative models through their practical implementation. By the end of this book, you will be ready to build, train, and optimize your own end-to-end GAN models at work or in your own projects.
Table of Contents (11 chapters)

Training the CycleGAN

We have already covered the training objective function in the An Introduction to CycleGANs section. We have also created the respective Keras models for both networks. Training the CycleGAN is a multi-step process. We will perform the following steps to train the network:

  1. Loading the dataset
  2. Creating the generator and the discriminator networks
  3. Training the network for a specified number of epochs
  4. Plotting the losses
  5. Generating new images

Let's define the essential variables before starting to train the network, as follows:

data_dir = "/Path/to/dataset/directory/*.*"
batch_size = 1
epochs = 500

Loading the dataset

Before doing anything else, load the dataset by performing the following...