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

PyTorch

Getting to know someTensor Functions

PyTorch is an open source machine learning framework that accelerates the path from research prototyping to production deployment.
The following are some tensor functions that have been explained in this notebook:

  • torch.arange()
  • torch.full()
  • torch.rand()
  • torch.linspace()
  • torch.transpose()
# Import torch and other required modules
import torch

Function 1 - torch.arange()

This function returns a 1-D tensor of size (end-start)/step with values from the interval [start, end) taken with common difference step beginning from start.

# Example 1 - working 
torch.arange(3) 
tensor([0, 1, 2])

Created a 1-D tensor of a specific length from the start to the end.