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 SRGAN

Training the SRGAN 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 the SRGAN network:

  1. Start by defining the hyperparameters required for the training:
# Define hyperparameters
data_dir = "Paht/to/the/dataset/img_align_celeba/*.*"
epochs = 20000
batch_size = 1

# Shape of low-resolution and high-resolution images
low_resolution_shape = (64, 64, 3)
high_resolution_shape = (256, 256, 3)
  1. Next, define the training optimizer. For all networks, we will use Adam optimizer with the learning rate equal to 0.0002 and beta_1 equal to 0.5:
# Common optimizer for all networks
common_optimizer = Adam(0.0002, 0.5)
...