Skip to Content
Fundamentals of Deep Learning, 2nd Edition
book

Fundamentals of Deep Learning, 2nd Edition

by Nithin Buduma, Nikhil Buduma, Joe Papa
May 2022
Intermediate to advanced content levelIntermediate to advanced
387 pages
11h 47m
English
O'Reilly Media, Inc.
Content preview from Fundamentals of Deep Learning, 2nd Edition

Chapter 5. Implementing Neural Networks in PyTorch

Introduction to PyTorch

In this chapter, you will learn the basics of PyTorch, one of the most popular deep learning frameworks in use today. PyTorch was introduced by Facebook’s AI Research Lab in 2016 and gained users rapidly, both in industry and in research, through the following years. One reason for PyTorch’s widespread adoption was its intuitive, Pythonic feel, which fit naturally into the preexisting workstreams and coding paradigms followed by deep learning practitioners.

In particular, this chapter will discuss the data structures utilized by PyTorch, how to define neural models in PyTorch, and how to connect data with models for training and testing. Finally, we implement a practical example in PyTorch—a classifier for the MNIST digits dataset, complete with code for training and testing the classifier.

Installing PyTorch

Installing a CPU-compatible version of PyTorch is relatively simple. The PyTorch docs recommend using conda, a package management system. Within conda, you can create multiple environments, where an environment is a context that encapsulates all of your package installs. Access to a package does not transfer across environments—this allows the user to have a clean separation between different contexts by downloading packages within individual environments. We recommend that you create a conda environment for deep learning purposes that you can switch into whenever necessary. We refer you to the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Generative Deep Learning, 2nd Edition

Generative Deep Learning, 2nd Edition

David Foster
Math for Deep Learning

Math for Deep Learning

Ronald T. Kneusel
Grokking Deep Learning

Grokking Deep Learning

Andrew W. Trask

Publisher Resources

ISBN: 9781492082170Errata PageSupplemental Content