**List of contents to cover**

1. Pytorch

2. Why Pytorch

3. Step-by step guide to Install Pytorch

4. Basic Operation in Pytorch

5. Tensor vs Numpy

6. Video explanation

# 1. Pytorch

- Pytorch is a Face-book AI researchers’ deep learning platform. Py in Pytorch is Python since it supports all Python packages and is used in the language Python. The torch is a pre-existing machine learning which is based on Lua programming language.

# 2. Why Pytorch

- The major reason for the usage of Pytorch for beginners is that it does include an amazing user-friendly API. Therefore, it is very easy to implement neural networks in Pytorch if you understand Python language.
- The main reason for Pytorch being used by experts is the use of the dynamic computation graph. In the stage of backpropagation, you could use derivatives during the implementation of deep neural networks. We use computational graphs to consider these derivatives. The other computation graphs on the platform are static. However, dynamic computation graphs have some advantages over static computation graphs.
- Pytorch Software has GPU support and we will use CUDA that is developed by NVIDIA to add GPU support for speed. It is very simple to debug Pytorch because it is similar to Python language.

# 3. Step-by step guide to Install Pytorch

- Use the pip tool of python to install Pytorch. Here we are using pip3 as we are using Python3, if you are using Python 2, uses the pip command.
- Here we are installing both torch and torch vision.
- Import Pytorch and check its version.
- Torch has CUDA availability. If it is present in your software then it will show otherwise it will show false. Here we are using Google colab which has GPU support, which is free to use.
- Turn on the CUDA version available on your platform.
- The installation is completed for Pytorch.

# 4. Basic Operation in Pytorch

- Just like Python and Numpy we have torch.rand to create random matrix or vector in Pytorch.
- Here we are creating three by three (3×3) matrix.
- It has a floating values.
- Also create a 3×3 matrix of zeros
- Then create a 3×3 matrix and here we have created a vector of 5 elements that are used once.
- In every array, it shows tensor. tensor is an n-dimensional array. In Numpy you have np to represent arrays and torch has tensor to represent its array values.
- tensor is the core data type that is used to hold the data. It also supports Numpy. There is an interchangeability option in Pytorch. That will be discussed in further steps.
- Write torch.Tensor (3, 3), will create a 3×3 tensor with random elements.
- You also create a specific matrix in Pytorch. For example, we have created a tensor of a 2×2 matrix where the elements are (
*1, 3)*and (*5, 7*). Once we run this above-created matrix we will get a 2×2 tensor of*{1, 3}, {5, 7}.*

# 5. Tensor vs Numpy

As discussed above Pytorch has tensor and Numpy interchange ability option.

- Tensor is much better than Numpy is because it is much faster than Numpy.
- When we perform the matrix computation between Numpy and tensor, tensor always takes lesser time to compute compared to Numpy.
- Numpy performs ‘array’ data-type operation, and Pytorch performs ‘tensor’ data-type operations.