Learn practical skills, build real-world projects, and advance your career

Title Here : << 5 Interesting Tensor Operations >>

An short introduction about PyTorch and about the chosen functions.

  • function 1 -----> torch.baddbmm()

    This function performs the matrix multiplication on batch_1 & batch_2 and then add input with the final product.

  • function 2 -----> torch.arange()

    This function helps to initialize a tensor with a range of value.

  • function 3 -----> torch.chunk()

    This function is used to split the tensors into the desired number of chunks.

  • function 4 -----> torch.add() & torch.mul()

    To add & multiply tensors with each other elementwise we use add & mul tensor operations.

  • function 5 -----> torch.dot() & torch.mv() & torch.mm()

To perform vector-vector product, matrix-vector product & matrix-matrix product use these tensor functions.

Before we begin, let's install and import PyTorch

# Uncomment and run the appropriate command for your operating system, if required

# Linux / Binder
# !pip install numpy torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

# Windows
# !pip install numpy torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

# MacOS
# !pip install numpy torch torchvision torchaudio
# Import torch and other required modules
import torch

##PyTorch:
It was introduced by the Facebook AI Research (FAIR) team, back in early 2017, PyTorch has become a highly popular and widely used Deep Learning (DL) framework.

It is a python-based scientific computing package used as a deep learning research platform for more flexibility & speed.

It is used insted of numpy where we have to process a large dataset because PyTorch can use the power of GPU.