Book Image

Mastering PyTorch - Second Edition

By : Ashish Ranjan Jha
4 (1)
Book Image

Mastering PyTorch - Second Edition

4 (1)
By: Ashish Ranjan Jha

Overview of this book

PyTorch is making it easier than ever before for anyone to build deep learning applications. This PyTorch deep learning book will help you uncover expert techniques to get the most out of your data and build complex neural network models. You’ll build convolutional neural networks for image classification and recurrent neural networks and transformers for sentiment analysis. As you advance, you'll apply deep learning across different domains, such as music, text, and image generation, using generative models, including diffusion models. You'll not only build and train your own deep reinforcement learning models in PyTorch but also learn to optimize model training using multiple CPUs, GPUs, and mixed-precision training. You’ll deploy PyTorch models to production, including mobile devices. Finally, you’ll discover the PyTorch ecosystem and its rich set of libraries. These libraries will add another set of tools to your deep learning toolbelt, teaching you how to use fastai to prototype models and PyTorch Lightning to train models. You’ll discover libraries for AutoML and explainable AI (XAI), create recommendation systems, and build language and vision transformers with Hugging Face. By the end of this book, you'll be able to perform complex deep learning tasks using PyTorch to build smart artificial intelligence models.
Table of Contents (21 chapters)
20
Index

What this book covers

Chapter 1, Overview of Deep Learning Using PyTorch, includes brief notes on various deep learning terminologies and concepts useful for understanding later parts of this book. This chapter also gives a quick overview of PyTorch in contrast with TensorFlow as a language and tools that will be used throughout this book for building deep learning models. Finally, we train a neural network model using PyTorch.

Chapter 2, Deep CNN Architectures, is a rundown of the most advanced deep CNN model architectures that have been developed in recent years. We use PyTorch to create many of these models and train them for appropriate tasks.

Chapter 3, Combining CNNs and LSTMs, walks through an example where we build a neural network model with a CNN and LSTM that generates text/captions as output when given images as inputs using PyTorch.

Chapter 4, Deep Recurrent Model Architectures, goes through recent advancements in recurrent neural architectures, specifically RNNs, LSTMs, and GRUs. Upon completion, you will be able to create complex recurrent architecture in PyTorch.

Chapter 5, Advanced Hybrid Models, discusses some advanced, unique hybrid neural architectures such as the Transformers that have revolutionized the world of natural language processing. This chapter also discusses RandWireNNs, taking a peek into the world of neural architecture search, using PyTorch.

Chapter 6, Graph Neural Networks, walks us through the basic concepts behind GNNs, different kinds of graph learning tasks, and different types of GNN model architectures. The chapter then dives deep into a few of those architectures, namely Graph Convolutional Networks (GCNs) and Graph Attention Networks (GATs). This chapter uses PyTorch Geometric as the library of choice for building GNNs in PyTorch.

Chapter 7, Music and Text Generation with PyTorch, demonstrates the use of PyTorch to create deep learning models that can compose music and write text with practically nothing being provided to them at runtime.

Chapter 8, Neural Style Transfer, discusses a special type of CNN model that can mix multiple input images and generate artistic-looking arbitrary images.

Chapter 9, Deep Convolutional GANs, explains GANs and trains one using PyTorch on a specific task.

Chapter 10, Image Generation Using Diffusion, implements a diffusion model from scratch as a state-of-the-art text-to-image generation model, using PyTorch.

Chapter 11, Deep Reinforcement Learning, explores how PyTorch can be used to train agents on a deep reinforcement learning task, such as a player in a video game.

Chapter 12, Model Training Optimizations, explores how to efficiently train large models with limited resources through distributed training as well as mixed precision training practices in PyTorch. By the end of this chapter, you will have mastered the skill of training large models efficiently using PyTorch.

Chapter 13, Operationalizing PyTorch Models into Production, runs through the process of deploying a deep learning model written in PyTorch into a real production system using Flask and Docker, as well as TorchServe. Then you’ll learn how to export PyTorch models both using TorchScript and ONNX. You’ll also learn how to ship PyTorch code as a C++ application. Finally, you’ll learn how to use PyTorch on some of the popular cloud computing platforms.

Chapter 14, PyTorch on Mobile and Embedded Devices, walks through the process of using various pre-trained PyTorch models and deploying them on different mobile operating systems – Android and iOS.

Chapter 15, Rapid Prototyping with PyTorch, discusses various tools and libraries such as fastai and PyTorch Lightning that make the process of model training in PyTorch several times faster. This chapter also explains how to profile PyTorch code to understand resource utilization.

Chapter 16, PyTorch and AutoML, walks through setting up ML experiments effectively using AutoML and Optuna with PyTorch.

Chapter 17, PyTorch and Explainable AI, focuses on making machine learning models interpretable to a layman using tools such as Captum, combined with PyTorch.

Chapter 18, Recommendation Systems with PyTorch, builds a deep-learning-based movie recommendation system from scratch using PyTorch.

Chapter 19, PyTorch and Hugging Face, discusses how to use Hugging Face libraries such as Transformers, Accelerate, Optimum, and so on, with PyTorch to build cutting-edge multi-modal AI models.