DEV Community

Cover image for Introduction to PyTorch
Tina Huynh
Tina Huynh

Posted on

Introduction to PyTorch

Table of Contents

  1. What is PyTorch
  2. The PyTorch EcoSystem
  3. Beginner PyTorch Projects
  4. Helpful Links

What is PyTorch

PyTorch is an open source machine learning framework that uses Python 3.7 or greater. You can start locally with the instructions to get started on their website.

Pre-requisites include:

  • Python 3.7 or greater
  • A package manager (Anaconda or pip) - Anaconda is the recommended package manager

To install Anaconda, right-click the 64-bit installer link, select copy link location and use the following commands:

# The version of Anaconda may be different depending on when you are installing`
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sh Miniconda3-latest-Linux-x86_64.sh
# and follow the prompts. The defaults are generally good.`
Enter fullscreen mode Exit fullscreen mode

To ensure that PyTorch was installed correctly, run the sample PyTorch code:

import torch
x = torch.rand(5, 3)
print(x)
Enter fullscreen mode Exit fullscreen mode

The output should be similar to:

tensor([[0.3380, 0.3845, 0.3217],
        [0.8337, 0.9050, 0.2650],
        [0.2979, 0.7141, 0.9069],
        [0.1449, 0.1132, 0.1375],
        [0.4675, 0.3947, 0.1426]])
Enter fullscreen mode Exit fullscreen mode

Additionally, you can check if your GPU driver and CUDA is enabled and accessible by PyTorch by running the following commands:

import torch
torch.cuda.is_available()
Enter fullscreen mode Exit fullscreen mode

Back to TOC

The PyTorch EcoSystem

There are many tools and libraries available for you including the following:

A library for quantum ML, automatic differentation, and optimization of hybrid quantum-classical computations.

A framework for PyTorch to improve the performance and robustness of DL models.

A Keras-like ML library for PyTorch

A library for deep learning on irregular input data such as graphs, point clouds, and manifolds.

Basic utilities for PyTorch natural language processing

A resource-adaptive deep learning training and scheduling framework

And there are so many more. Check them out right here

Back to TOC

Beginner PyTorch Projects

CHATBOT TUTORIAL

NLP FROM SCRATCH: CLASSIFYING NAMES WITH A CHARACTER-LEVEL RNN

LANGUAGE TRANSLATION WITH NN.TRANSFORMER AND TORCHTEXT

TRAIN A MARIO-PLAYING RL AGENT

Back to TOC

Helpful Links

Top comments (0)