# Pytorch Intro Pytorch Installation converting numpy to tensor Pytorch tutorial

## 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

1. 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

1. 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.
2.  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.
3. 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

1. 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.
2. Here we are installing both torch and torch vision.
3. Import Pytorch and check its version.
4. 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.
5. Turn on the CUDA version available on your platform.
6. The installation is completed for Pytorch.

# 4. Basic Operation in Pytorch

1. Just like Python and Numpy we have torch.rand to create random matrix or vector in Pytorch.
2. Here we are creating three by three (3×3) matrix.
3. It has a floating values.
4. Also create a 3×3 matrix of zeros
5. Then create a 3×3 matrix and here we have created a vector of 5 elements that are used once.
6. 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.
7. 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.
8. Write torch.Tensor (3, 3), will create a 3×3 tensor with random elements.
9. 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.

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