Hands-On Generative Adversarial Networks with PyTorch 1.x
eBook - ePub

Hands-On Generative Adversarial Networks with PyTorch 1.x

Implement next-generation neural networks to build powerful GAN models using Python

  1. 312 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Generative Adversarial Networks with PyTorch 1.x

Implement next-generation neural networks to build powerful GAN models using Python

About this book

Apply deep learning techniques and neural network methodologies to build, train, and optimize generative network models

Key Features

  • Implement GAN architectures to generate images, text, audio, 3D models, and more
  • Understand how GANs work and become an active contributor in the open source community
  • Learn how to generate photo-realistic images based on text descriptions

Book Description

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.

What you will learn

  • Implement PyTorch's latest features to ensure efficient model designing
  • Get to grips with the working mechanisms of GAN models
  • Perform style transfer between unpaired image collections with CycleGAN
  • Build and train 3D-GANs to generate a point cloud of 3D objects
  • Create a range of GAN models to perform various image synthesis operations
  • Use SEGAN to suppress noise and improve the quality of speech audio

Who this book is for

This GAN book is for machine learning practitioners and deep learning researchers looking to get hands-on guidance in implementing GAN models using PyTorch. You'll become familiar with state-of-the-art GAN architectures with the help of real-world examples. Working knowledge of Python programming language is necessary to grasp the concepts covered in this book.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Hands-On Generative Adversarial Networks with PyTorch 1.x by John Hany, Greg Walters in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Science General. We have over one million books available in our catalogue for you to explore.

Information

Section 1: Introduction to GANs and PyTorch

In this section, you will be introduced to the basic concepts of GANs, how to install PyTorch 1.0, and how you can build your own models with PyTorch.
This section contains the following chapters:
  • Chapter 1, Generative Adversarial Networks Fundamentals
  • Chapter 2, Getting Started with PyTorch 1.3
  • Chapter 3, Best Practices in Model Design and Training

Generative Adversarial Networks Fundamentals

Generative Adversarial Networks (GANs) have brought about a revolutionary storm in the machine learning (ML) community. They, to some extent, have changed the way people solve practical problems in Computer Vision (CV) and Natural Language Processing (NLP). Before we dive right into the storm, let's prepare you with the fundamental insights of GANs.
In this chapter, you will understand the idea behind adversarial learning and the basic components of a GAN model. You will also get a brief understanding on how GANs work and how it can be built with NumPy.
Before we start exploiting the new features in PyTorch, we will first learn to build a simple GAN with NumPy to generate sine signals so that you may have a profound understanding of the mechanism beneath GANs. By the end of this chapter, you may relax a little as we walk you through many showcases about how GANs are used to address practical problems in CV and NLP fields.
The following topics will be covered in this chapter:
  • Fundamentals of machine learning
  • Generator and discriminator networks
  • What GAN we do?
  • References and a useful reading list

Fundamentals of machine learning

To introduce how GANs work, let's use an analogy:
A long, long time ago, there were two neighboring kingdoms on an island. One was called Netland, and the other was called Ganland. Both kingdoms produced fine wine, armor, and weapons. In Netland, the king demanded that the blacksmiths who specialized in making armor worked at the east corner of the castle, while those who made swords worked at the west side so that the lords and knights could choose the best equipment the kingdom had to offer. The king of Ganland, on the other hand, put all of the blacksmiths in the same corner and demanded that the armor makers and sword makers should test their work against each other every day. If a sword broke through the armor, the sword would sell at a good price and the armor would be melted and reforged. If it didn't, the sword would be remade and men would strive to buy the armor. One day, the two kings were arguing over which kingdom made better wine until the quarrel escalated into war. Though outnumbered, the soldiers of Ganland wore the armor and swords that had been improved for years in the daily adversarial tests, and the Netland soldiers could not break their strong armor nor withstand their sharp swords. In the end, the defeated king of Netland, however reluctant he was, agreed that Ganland had better wine and blacksmiths.

Machine learning – classification and generation

ML is the study of recognizing patterns from data without hardcoded rules given by humans. The recognizing of patterns (Pattern Recognition or PR) is the automatic discovering of the similarities and differences among raw data, which is an essential way to realize Artificial Intelligence (AI) that only exists in novels and movies. Although it is hard to tell when exactly real AI will come to birth in the future, the development of ML has given us much confidence in recent years. ML has already been vastly used in many fields, such as CV, NLP, recommendation systems, Intelligent Transportation Systems (ITS), medical diagnoses, robotics, and advertising.
A ML model is typically described as a system that takes in data and gives certain outputs based on the parameters it contains. The learning of the model is actually adjusting the parameters to get better outputs. As illustrated in the following diagram, we feed training data into the model and get a certain output. We then use one or several criteria to measure the output, to tell how well our model performs. In this step, a set of desired outputs (or ground truth) with respect to the training data would be very helpful. If ground truth data is used in training, this process is often called supervised learning. If not, it is often regarded as unsupervised learning.
We constantly adjust the model's parameters based on its performance (in other words, whether it gives us the results we want) so that it yields better results in the future. This process is called model training. The training of a model takes as long as it pleases us. Typically, we stop the training after a certain number of iterations or when the performance is good enough. When the training process has finished, we apply the trained model to predict on new data (testing data). This process is called model testing. Sometimes, people use different sets of data for training and testing to see how well the model performs on samples it never meets, which is called the generalization capability. Sometimes an additional step called model evaluation is involved, when the parameters of the model are so complicated that we need another set of data to see whether our model or training process has been designed well:
A typical machine learning system, with model training and testing
What types of problems this model can solve is essentially determined by the types of input and out...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. About Packt
  4. Contributors
  5. Preface
  6. Section 1: Introduction to GANs and PyTorch
  7. Generative Adversarial Networks Fundamentals
  8. Getting Started with PyTorch 1.3
  9. Best Practices for Model Design and Training
  10. Section 2: Typical GAN Models for Image Synthesis
  11. Building Your First GAN with PyTorch
  12. Generating Images Based on Label Information
  13. Image-to-Image Translation and Its Applications
  14. Image Restoration with GANs
  15. Training Your GANs to Break Different Models
  16. Image Generation from Description Text
  17. Sequence Synthesis with GANs
  18. Reconstructing 3D models with GANs
  19. Other Books You May Enjoy