Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
Pytorch basic functions
Below are the basic functions selected for this assignment
- torch.reciprocal
- torch.round
- torch.transpose
- torch.sign
- torch.matmul
# Import torch and other required modules
import torch
Function 1 - torch.reciprocal
Reciprocal function is used to return the reciprocal of the input.
# Example 1 - Generating random numbers.
a = torch.randn(7)
torch.reciprocal(a)
tensor([-1.4730, 0.6938, -1.9660, 1.5038, -0.6142, -0.6400, 1.8415])
Tensor 'a' generated with 7 numbers using randn function & reciprocal function is used to generate reciprocal of a i.e., 1/a