Introduction to PyTorch
Tags: python, machinelearning, deeplearning, beginners
Published: 2022-05-02 22:03:15

## Table of Contents <a name="TOC">
1. [What is PyTorch](#what-is-pytorch)
2. [The PyTorch EcoSystem](#the-pytorch-ecosystem)
3. [Beginner PyTorch Projects](#beginner-pytorch-projects)
4. [Helpful Links](#helpful-links)


### What is [PyTorch](https://pytorch.org/)

{% embed https://www.youtube.com/watch?v=IC0_FRiX-sw %}

[PyTorch](https://pytorch.org/docs/stable/index.html) is an open source [machine learning](https://www.techtarget.com/searchenterpriseai/definition/machine-learning-ML#:~:text=Machine%20learning%20(ML)%20is%20a,to%20predict%20new%20output%20values.) framework that uses Python 3.7 or greater. You can [start locally](https://pytorch.org/get-started/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](https://www.anaconda.com/) 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.`
```

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

```
import torch
x = torch.rand(5, 3)
print(x)
```

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]])
```

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()
```

[Back to TOC](#TOC)

### The PyTorch EcoSystem
There are many tools and libraries available for you including the following:

- [PennyLane](https://pennylane.ai/)

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

- [Emsemble-Pytorch](https://ensemble-pytorch.readthedocs.io/)

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

- [PyTorch Lightning](https://github.com/williamFalcon/pytorch-lightning)

A Keras-like ML library for PyTorch

- [PyTorch Geometric](https://github.com/rusty1s/pytorch_geometric)

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

- [PyTorch-NLP](https://pytorchnlp.readthedocs.io/)

Basic utilities for PyTorch natural language processing

- [AdaptDL](https://github.com/petuum/adaptdl)

A resource-adaptive deep learning training and scheduling framework

And there are so many more. Check them out [right here](https://pytorch.org/ecosystem/)

[Back to TOC](#TOC)

### Beginner PyTorch Projects

#### [CHATBOT TUTORIAL](https://pytorch.org/tutorials/beginner/chatbot_tutorial.html)

#### [NLP FROM SCRATCH: CLASSIFYING NAMES WITH A CHARACTER-LEVEL RNN](https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial)

#### [LANGUAGE TRANSLATION WITH NN.TRANSFORMER AND TORCHTEXT](https://pytorch.org/tutorials/beginner/translation_transformer.html)

#### [TRAIN A MARIO-PLAYING RL AGENT](https://pytorch.org/tutorials/intermediate/mario_rl_tutorial.html)

[Back to TOC](#TOC)

### Helpful Links
- [PyTorch For Deep Learning](https://www.youtube.com/watch?v=GIsg-ZUy0MY)
- [A Gentle Introduction to PyTorch Library for Deep Learning](https://www.analyticsvidhya.com/blog/2021/04/a-gentle-introduction-to-pytorch-library/)
- [PyTorch Tutorials](https://pytorch.org/tutorials/)
- [Introduction to PyTorch Code Examples](https://cs230.stanford.edu/blog/pytorch/)
- [PyTorch Documentation](https://pytorch.org/docs/stable/index.html)
- [PyTorch GitHub](https://github.com/pytorch/pytorch)
- [Follow PyTorch on Twitter](https://twitter.com/PyTorch?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor)