Book Image

Hands-On Generative Adversarial Networks with PyTorch 1.x

By : John Hany, Greg Walters
Book Image

Hands-On Generative Adversarial Networks with PyTorch 1.x

By: John Hany, Greg Walters

Overview of this book

With continuously evolving research and development, Generative Adversarial Networks (GANs) are the next big thing in the field of deep learning. This book highlights the key improvements in GANs over generative models and guides in making the best out of GANs with the help of hands-on examples. This book starts by taking you through the core concepts necessary to understand how each component of a GAN model works. You'll build your first GAN model to understand how generator and discriminator networks function. As you advance, you'll delve into a range of examples and datasets to build a variety of GAN networks using PyTorch functionalities and services, and become well-versed with architectures, training strategies, and evaluation methods for image generation, translation, and restoration. You'll even learn how to apply GAN models to solve problems in areas such as computer vision, multimedia, 3D models, and natural language processing (NLP). The book covers how to overcome the challenges faced while building generative models from scratch. Finally, you'll also discover how to train your GAN models to generate adversarial examples to attack other CNN and GAN models. By the end of this book, you will have learned how to build, train, and optimize next-generation GAN models and use them to solve a variety of real-world problems.
Table of Contents (15 chapters)
Free Chapter
1
Section 1: Introduction to GANs and PyTorch
5
Section 2: Typical GAN Models for Image Synthesis

What this book covers

Chapter 1, Generative Adversarial Networks Fundamentals, exploits the new features of PyTorch. You will also learn how to build a simple GAN with NumPy to generate sine signals.

Chapter 2, Getting Started with PyTorch 1.3, introduces how to install CUDA in order to take advantage of the GPU for faster training and evaluation. We will also look into the step-by-step installation process of PyTorch on Windows and Ubuntu and build PyTorch from source.

Chapter 3, Best Practices in Model Design and Training, looks at the overall design of the model architecture and the steps that need to be followed to choose the required convolutional operation.

Chapter 4, Building Your First GAN with PyTorch, introduces you to a classic and well-performing GAN model, called DCGAN, for generating 2D images. You will also be introduced to the architecture of DCGANs and learn how to train and evaluate them. Following this, you will learn how to use a DCGAN to generate hand-written digits and human faces, and take a look at adversarial learning with autoencoders. You will also be shown how to efficiently organize your source code for easy adjustments and extensions.

Chapter 5, Generating Images Based on Label Information, shows how to use a CGAN to generate images based on a given label and how to implement adversarial learning with autoencoders.

Chapter 6, Image-to-Image Translation and Its Applications, shows how to use pixel-wise label information to perform image-to-image translation with pix2pix and how to translate high-resolution images with pix2pixHD. You will also learn how to flexibly design model architectures to accomplish your goals, including generating larger images and transferring textures between different types of images.

Chapter 7, Image Restoration with GANs, shows you to how to perform image super-resolution with SRGAN to generate high-resolution images from low-resolution ones and how to use a data prefetcher to speed up data loading and increase your GPU's efficiency during training. You will also learn how to train a GAN model to perform image inpainting and fill in the missing parts of an image.

Chapter 8, Training Your GANs to Break Different Models, looks into the fundamentals of adversarial examples and how to attack and confuse a CNN model with FGSM (Fast Gradient Sign Method). After this, we will look at how to use an accimage library to speed up your image loading even more and train a GAN model to generate adversarial examples and fool the image classifier.

Chapter 9, Image Generation from Description Text, provides basic knowledge on word embeddings and how are they used in the NLP field. You will also learn how to design a text-to-image GAN model to generate images based on one sentence of description text.

Chapter 10, Sequence Synthesis with GANs, covers commonly used techniques in the NLP field, such as RNN and LSTM. You will also learn some of the basic concepts of reinforcement learning and see how it differ from supervised learning (such as SGD-based CNNs). You will also learn how to use SEGAN to remove background noise and enhance the quality of speech audio.

Chapter 11, Reconstructing 3D Models with GANs, shows how 3D objects are represented in computer graphics (CG). We will also look at the fundamental concepts of CG, including camera and projection matrices. You will then learn how to construct a 3D-GAN model with 3D convolutions and train it to generate 3D objects.