PyTorch tutorial: Get started with deep learning in Python

Learn how to create a simple neural network, and a more accurate convolutional neural network, with the PyTorch deep learning library

Become An Insider

Sign up now and get FREE access to hundreds of Insider articles, guides, reviews, interviews, blogs, and other premium content. Learn more.

PyTorch is a Python-based tensor computing library with high-level support for neural network architectures. It also supports offloading computation to GPUs. A product of Facebook’s AI research team and open sourced a little more than a year ago, PyTorch has fast become the first choice of many deep learning practitioners.  

In this tutorial, we’ll dive into the basics of running PyTorch on Linux, from installation to creating and training a simple neural network that can recognize digits. We’ll cap it off by tackling a more complicated example that uses convolutional neural networks (CNNs) to improve accuracy. This won’t be a full introduction to neural networks, but I will explain neural networking concepts as they crop up in our code.

While a computer with a GPU is not necessary for this tutorial, it is recommended. If you want to follow along in a Jupyter notebook, you can make use of the version of this article on GitHub.

Install PyTorch

The easiest way to install PyTorch is to use the Anaconda Python distribution. If you have Anaconda installed, you can get the latest PyTorch by entering this command:

To continue reading this article register now