Deep Learning with PyTorch
Eli Stevens and Luca Antiga
  • MEAP began April 2018
  • Publication in Fall 2020 (estimated)
  • ISBN 9781617295263
  • 450 pages (estimated)
  • printed in black & white

Perfectly motivating and practical without being shallow.

Carlos Andres Mariscal
Every other day we hear about new ways to put deep learning to good use: improved medical imaging, accurate credit card fraud detection, long range weather forecasting, and more. PyTorch puts these superpowers in your hands, providing a comfortable Python experience that gets you started quickly and then grows with you as you—and your deep learning skills—become more sophisticated. Deep Learning with PyTorch will make that journey engaging and fun.
Table of Contents detailed table of contents

Part 1: Core PyTorch

1 PyTorch from 1 Mile Away

1.1 Introduction

1.1.1 The Deep Learning Revolution

1.1.2 The Tools Behind the Revolution

1.2 Where PyTorch Comes From

1.3 Why PyTorch

1.4 The Anatomy of PyTorch

1.5 Wrapping up

1.6 Summary

2 A Whirlwind Tour of PyTorch

2.1 Introduction

2.2 Evaluating the hardware

2.3 Installing PyTorch

2.3.1 Making sure things work

2.3.2 Using Jupyter Notebooks

2.4 Playing with pre-trained networks

2.4.1 A pre-trained network that recognizes the subject of an image

2.4.2 A pre-trained network that makes stuff up

2.4.3 A pre-trained network that describes scenes

2.5 Training a neural network with PyTorch

2.6 Summary

3 It Starts with a Tensor

3.1 Data in the Learnable Computing Era

3.2 Tensors

3.3 Tensors and Storages

3.4 Size, offset, strides

3.5 Numeric Types

3.6 Indexing Tensors

3.7 NumPy interoperability

3.8 Serializing tensors

3.9 Moving tensors to the GPU

3.10 The tensor API

3.11 Conclusion

3.12 Summary

4 The World as Tensors

4.1 Real-World Data Representation

4.1.1 Tabular Data

4.1.2 Time Series

4.1.3 Text

4.1.4 Audio

4.1.5 Images

4.1.6 Volumetric Data

4.1.7 Video Data

4.2 Summary

5 The Mechanics of Learning

5.1 Algorithms that learn

5.2 Learning through Differentiation

5.2.1 A Hot Problem

5.2.2 Better Linear than Sorry

5.2.3 The Good Loss

5.2.4 From Problem to PyTorch

5.2.5 Down Along the Gradient

5.2.6 Getting Analytical

5.2.7 The Training Loop

5.2.8 Autograd: Back-propagate all things

5.2.9 Optimizers a-la Carte

5.2.10 Training, Validation and Overfitting

5.2.11 Autograd Nits and Switching it Off

5.3 Beyond Linear into Neural Networks

5.3.1 All We Need is Activations

5.4 The PyTorch nn module

5.4.1 Finally a Neural Network

5.5 Closing

5.6 Summary

6 Telling Birds from Airplanes - Learning from Images

6.1 A dataset of tiny images

6.1.1 Downloading CIFAR10

6.1.2 The Dataset class

6.1.3 Dataset transforms

6.1.4 Normalizing data

6.2 Distinguishing birds from airplanes

6.2.1 Building the dataset

6.2.2 A fully connected classifier

6.2.3 A loss for classifying

6.2.4 Training the classifier

6.3 Leveraging spatial patterns: convolutions

6.3.1 The limits of going fully connected

6.3.2 The case for convolutions

6.3.3 Convolutions in action

6.3.4 Looking further with depth and pooling

6.3.5 Subclassing nn.Module

6.3.6 The Functional API

6.3.7 Training our Convnet

6.4 Closing

6.5 Summary

Part 2: Learning from Images in the Real-World: Early Detection of Lung Cancer

7 How hard can curing cancer be?

7.1 What is a CT scan, exactly?

7.2 The project: an end-to-end malignancy detector for lung cancer

7.2.1 Why can’t we just throw data at a neural network until it works?

7.3 This chapter: loading our CT data and providing a dataset implementation

7.3.1 What is a nodule?

7.3.2 The LUNA Grand Challenge

7.3.3 How to get the data

7.4 Parsing LUNA’s annotation data

7.5 Loading individual CT scans

7.5.1 Hounsfield Units

7.6 Locating a nodule using the patient coordinate system

7.6.1 Extracting a nodule from a CT scan

7.7 A straightforward Dataset implementation

7.7.1 The getCtRawNodule function

7.7.2 LunaDataset._getitem_

7.7.3 A Test / Train Split

7.7.4 Rendering the data

7.8 Exercises

7.9 Summary

8 Classifying Suspected Tumors

9 Monitoring Metrics: Precision, Recall, and Pretty Pictures

10 Determining What to Classify With Segmentation And Clustering

11 Data Improvements, Augmentation

12 PyTorch in Production

13 Revisiting CycleGAN’s zebras

About the Technology

PyTorch is a machine learning framework with a strong focus on deep neural networks. Because it emphasizes GPU-based acceleration, PyTorch performs exceptionally well on readily-available hardware and scales easily to larger systems. Plus it's Pythonic! Thanks to its define-by-run computation graph model, PyTorch plays nicely with the Python data science ecosystem. It's instantly familiar if you're using Numpy, Pandas, or other similar tools.

It's easy to get started with PyTorch. It minimizes cognitive overhead without sacrificing the access to advanced features, meaning you can focus on what matters the most - building and training the latest and greatest deep learning models and contribute to making a dent in the world. PyTorch is also a snap to scale and extend, and it partners well with other Python tooling. PyTorch has been adopted by hundreds of deep learning practitioners and several first-class players like FAIR, OpenAI, FastAI and Purdue.

About the book

Deep Learning with PyTorch teaches you how to implement deep learning algorithms with Python and PyTorch. This book takes you into a fascinating case study: building an algorithm capable of detecting malignant lung tumors using CT scans. As the authors guide you through this real example, you'll discover just how effective and fun PyTorch can be. After a quick introduction to the deep learning landscape, you'll explore the use of pre-trained networks and start sharpening your skills on working with tensors. You'll find out how to represent the most common types of data with tensors and how to build and train neural networks from scratch on practical examples, focusing on images and sequences.

After covering the basics, the book will take you on a journey through larger projects. The centerpiece of the book is a neural network designed for cancer detection. You'll discover ways for training networks with limited inputs and start processing data to get some results. You'll sift through the unreliable initial results and focus on how to diagnose and fix the problems in your neural network. Finally, you'll look at ways to improve your results by training with augmented data, make improvements to the model architecture, and perform other fine tuning.

What's inside

  • Using the PyTorch tensor API
  • Understanding automatic differentiation in PyTorch
  • Training deep neural networks
  • Monitoring training and visualizing results
  • Implementing modules and loss functions
  • Loading data in Python for PyTorch
  • Interoperability with NumPy
  • Deploying a PyTorch model for inference

About the reader

Written for developers with some knowledge of Python as well as basic linear algebra skills. Some understanding of deep learning will be helpful, however no experience with PyTorch or other deep learning frameworks is required.

About the authors

Eli Stevens has worked in Silicon Valley for the past 15 years as a software engineer, and the past 7 years as Chief Technical Officer of a startup making medical device software. Luca Antiga is co-founder and CEO of an AI engineering company located in Bergamo, Italy, and a regular contributor to PyTorch.
Deep Learning with PyTorch authors Luca Antiga (L) and Eli Stevenson (R) eating dessert in San Francisco's Mission District with the book's editor Frances Lefkowitz. Luca is from Bergamo, Italy, Eli lives in San Jose, and Frances hails from San Francisco.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $49.99 pBook + eBook + liveBook
MEAP eBook $39.99 pdf + ePub + kindle + liveBook

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks

The book tackles a very specialized subject in an approachable manner. Examples are clear, and the intent of the topics explained is coherent.

Orlando Alejo Mendez Morales

The book provides a good introduction to deep learning and the PyTorch package.

Daniel Berecz

One of the most approachable books on Machine Learning.

Doniyor Ulmasov