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 pix2pix network

Like any other GAN, training the pix2pix network is a two-step process. In the first step, we train the discriminator network. In the second step, we train the adversarial network, which eventually trains the generator network. Let's start training the network.

Perform the following steps to train an SRGAN network:

  1. Start by defining the hyperparameters that are required for training:
epochs = 500
num_images_per_epoch = 400
batch_size = 1
img_width = 256
img_height = 256
num_channels = 1
input_img_dim = (256, 256, 1)
patch_dim = (256, 256)

# Specify dataset directory path
dataset_dir = "pix2pix-keras/pix2pix/data/facades_bw"
  1. Next, define the common optimizer, shown as follows:
common_optimizer = Adam(lr=1E-4, beta_1=0.9, beta_2=0.999,  
epsilon=1e-08)

For all networks, we will use the Adam optimizer with the learning...