PyTorch Pocket Reference

Book description

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

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Who Should Read This Book
    2. Why I Wrote This Book
    3. Navigating This Book
    4. Conventions Used in This Book
    5. Using Code Examples
    6. O’Reilly Online Learning
    7. How to Contact Us
    8. Acknowledgments
  2. 1. An Introduction to PyTorch
    1. What Is PyTorch?
    2. Why Use PyTorch?
    3. Getting Started
      1. Running in Google Colaboratory
      2. Running on a Local Computer
      3. Running on Cloud Platforms
      4. Verifying Your PyTorch Environment
    4. A Fun Example
  3. 2. Tensors
    1. What Is a Tensor?
      1. Simple CPU Example
      2. Simple GPU Example
      3. Moving Tensors Between CPUs and GPUs
    2. Creating Tensors
      1. Tensor Attributes
      2. Data Types
      3. Creating Tensors from Random Samples
      4. Creating Tensors Like Other Tensors
    3. Tensor Operations
      1. Indexing, Slicing, Combining, and Splitting Tensors
      2. Tensor Operations for Mathematics
      3. Automatic Differentiation (Autograd)
  4. 3. Deep Learning Development with PyTorch
    1. The Overall Process
    2. Data Preparation
      1. Data Loading
      2. Data Transforms
      3. Data Batching
      4. General Data Preparation (torch.utils.data)
    3. Model Development
      1. Model Design
      2. Training
      3. Validation
      4. Testing
    4. Model Deployment
      1. Saving Models
      2. Deploying to PyTorch Hub
      3. Deploying to Production
  5. 4. Neural Network Development Reference Designs
    1. Image Classification with Transfer Learning
      1. Data Processing
      2. Model Design
      3. Training and Validation
      4. Testing and Deployment
    2. Sentiment Analysis with Torchtext
      1. Data Processing
      2. Model Design
      3. Training and Validation
      4. Testing and Deployment
    3. Generative Learning—Generating Fashion-MNIST Images with DCGAN
      1. Data Processing
      2. Model Design
      3. Training
      4. Testing and Deployment
  6. 5. Customizing PyTorch
    1. Custom Layers and Activations
      1. Custom Layer Example (Complex Linear)
      2. Custom Activation Example (Complex ReLU)
    2. Custom Model Architectures
    3. Custom Loss Functions
    4. Custom Optimizer Algorithms
    5. Custom Training, Validation, and Test Loops
  7. 6. PyTorch Acceleration and Optimization
    1. PyTorch on a TPU
    2. PyTorch on Multiple GPUs (Single Machine)
      1. Data Parallel Processing
      2. Model Parallel Processing
      3. Combined Data Parallel Processing and Model Parallel Processing
    3. Distributed Training (Multiple Machines)
    4. Model Optimization
      1. Hyperparameter Tuning
      2. Quantization
      3. Pruning
  8. 7. Deploying PyTorch to Production
    1. PyTorch Deployment Tools and Libraries
      1. Common Example Model
      2. Python API
      3. TorchScript
      4. TorchServe
      5. ONNX
      6. Mobile Libraries
    2. Deploying to a Flask App
    3. Colab Flask App
    4. Deploying to the Cloud with TorchServe
    5. Quick Start with Docker
    6. Deploying to Mobile and Edge
      1. iOS
      2. Android
      3. Other Edge Devices
  9. 8. The PyTorch Ecosystem and Additional Resources
    1. The PyTorch Ecosystem
    2. Torchvision for Image and Video
      1. Datasets and I/O
      2. Models
      3. Transforms, Operations, and Utilities
    3. Torchtext for NLP
      1. Create a Dataset Object
      2. Preprocess Data
      3. Create a Dataloader for Batching
      4. Data (torchtext.data)
      5. Datasets (torchtext.datasets)
      6. Vocabularies (torchtext.vocab)
    4. TensorBoard for Visualization
      1. Learning Curves with SCALARS
      2. Model Architectures with GRAPHS
      3. Data with IMAGES, TEXT, and PROJECTOR
      4. Weight Distributions with DISTRIBUTIONS and HISTOGRAMS
      5. Hyperparameters with HPARAMS
      6. The TensorBoard API
    5. Papers with Code
    6. Additional PyTorch Resources
      1. Tutorials
      2. Books
      3. Online Courses and Live Training
  10. Index

Product information

  • Title: PyTorch Pocket Reference
  • Author(s): Joe Papa
  • Release date: May 2021
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492090007