Learn practical skills, build real-world projects, and advance your career
Created 4 years ago
Interesting 5 functions of pytorch
Let's familiarize ourselves with pytorch using few of it's basic functions.
An short introduction about PyTorch and about the chosen functions.
- torch.transpose
- torch.inverse
- torch.mm
- torch.arrange
- torch.reshape
# Import torch and other required modules
import torch
A = torch.rand(3,2)
A.shape
torch.Size([3, 2])
Function 1 - torch.transpose
This function will give you identity matrix. The identity matrix is the one where the elements of principle diagonal are one and everything else is zero.
# Example 1 - working (change this)
A_transpose_one = torch.transpose(A, 0, 1)
A_transpose_one.shape
torch.Size([2, 3])