Learn practical skills, build real-world projects, and advance your career
Updated 3 years ago
Assignment 1 - Exploring PyTorch Functions
Five PyTorch functions that I selected
An short introduction about PyTorch and about the chosen functions.
- torch.tensor
- torch.is_tensor()
- torch.log()
- torch.fill_diagonal_()
- torch.rot90()
# Import torch and other required modules
import torch
import numpy as np
Function 1 - torch.abs()
I have taken the torch.abs() function. What it does is, it converts every negative value to it's absolute value from the given input tensor.
# Example 1 - working
a = torch.tensor([-1,-2])
torch.abs(a)
tensor([1, 2])
I have taken a Pytorch Tensor for compute it's negative values to it's absolute value.