This concise, easy-to-use reference puts one of the most popular frameworks for deep learning research and development at your fingertips. Author Joe Papa provides instant access to syntax, design patterns, and code examples to accelerate your development and reduce the time you spend searching for answers.
Research scientists, machine learning engineers, and software developers will find clear, structured PyTorch code that covers every step of neural network development-from loading data to customizing training loops to model optimization and GPU/TPU acceleration. Quickly learn how to deploy your code to production using AWS, Google Cloud, or Azure and deploy your ML models to mobile and edge devices.
• Learn basic PyTorch syntax and design patterns
• Create custom models and data transforms
• Train and deploy models using a GPU and TPU
• Train and test a deep learning classifier
• Accelerate training using optimization and distributed training
• Access useful PyTorch libraries and the PyTorch ecosystem
Author(s): Joe Papa
Edition: 1
Publisher: O'Reilly Media
Year: 2021
Language: English
Commentary: Vector PDF
Pages: 310
City: Sebastopol, CA
Tags: Neural Networks; Deep Learning; Natural Language Processing; Python; Generative Adversarial Networks; Transfer Learning; Sentiment Analysis; Docker; Optimization; Flask; PyTorch; Image Classification; Loss Functions; Google Colaboratory; TensorBoard; Tensor Calculus; Data Preparation; Model Deployment; TorchServe; Torchtext
Cover
Copyright
Table of Contents
Preface
Who Should Read This Book
Why I Wrote This Book
Navigating This Book
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Chapter 1. An Introduction to PyTorch
What Is PyTorch?
Why Use PyTorch?
Getting Started
Running in Google Colaboratory
Running on a Local Computer
Running on Cloud Platforms
Verifying Your PyTorch Environment
A Fun Example
Chapter 2. Tensors
What Is a Tensor?
Simple CPU Example
Simple GPU Example
Moving Tensors Between CPUs and GPUs
Creating Tensors
Tensor Attributes
Data Types
Creating Tensors from Random Samples
Creating Tensors Like Other Tensors
Tensor Operations
Indexing, Slicing, Combining, and Splitting Tensors
Tensor Operations for Mathematics
Automatic Differentiation (Autograd)
Chapter 3. Deep Learning Development with PyTorch
The Overall Process
Data Preparation
Data Loading
Data Transforms
Data Batching
General Data Preparation (torch.utils.data)
Model Development
Model Design
Training
Validation
Testing
Model Deployment
Saving Models
Deploying to PyTorch Hub
Deploying to Production
Chapter 4. Neural Network Development Reference Designs
Image Classification with Transfer Learning
Data Processing
Model Design
Training and Validation
Testing and Deployment
Sentiment Analysis with Torchtext
Data Processing
Model Design
Training and Validation
Testing and Deployment
Generative Learning—Generating Fashion-MNIST Images with DCGAN
Data Processing
Model Design
Training
Testing and Deployment
Chapter 5. Customizing PyTorch
Custom Layers and Activations
Custom Layer Example (Complex Linear)
Custom Activation Example (Complex ReLU)
Custom Model Architectures
Custom Loss Functions
Custom Optimizer Algorithms
Custom Training, Validation, and Test Loops
Chapter 6. PyTorch Acceleration and Optimization
PyTorch on a TPU
PyTorch on Multiple GPUs (Single Machine)
Data Parallel Processing
Model Parallel Processing
Combined Data Parallel Processing and Model Parallel Processing
Distributed Training (Multiple Machines)
Model Optimization
Hyperparameter Tuning
Quantization
Pruning
Chapter 7. Deploying PyTorch to Production
PyTorch Deployment Tools and Libraries
Common Example Model
Python API
TorchScript
TorchServe
ONNX
Mobile Libraries
Deploying to a Flask App
Colab Flask App
Deploying to the Cloud with TorchServe
Quick Start with Docker
Deploying to Mobile and Edge
iOS
Android
Other Edge Devices
Chapter 8. The PyTorch Ecosystem and Additional Resources
The PyTorch Ecosystem
Torchvision for Image and Video
Datasets and I/O
Models
Transforms, Operations, and Utilities
Torchtext for NLP
Create a Dataset Object
Preprocess Data
Create a Dataloader for Batching
Data (torchtext.data)
Datasets (torchtext.datasets)
Vocabularies (torchtext.vocab)
TensorBoard for Visualization
Learning Curves with SCALARS
Model Architectures with GRAPHS
Data with IMAGES, TEXT, and PROJECTOR
Weight Distributions with DISTRIBUTIONS and HISTOGRAMS
Hyperparameters with HPARAMS
The TensorBoard API
Papers with Code
Additional PyTorch Resources
Tutorials
Books
Online Courses and Live Training
Index