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

Have a look at Pytorch Basic Tensor Operations !

Exploring five of tensor operations

Pytorch is a deep learning framework. This is created and maintained by Facebook as opensource project. Pytorch is prefered mostly by researchers, because it is useful in quick creation of prototypes.

These are my best 5 picks of tensor operation which is needed in most of real life projects.

  • torch.rand
  • torch.add
  • torch.tolist
  • apply_
  • torch.to
# Import torch and other required modules
import torch

1) torch.randn

This function is used to create a tensor with random real numbers from Standard Normal Distribution.

# Create a tensor with a random number
r1 = torch.randn(1)

r1
tensor([2.3830])
r1.shape
torch.Size([1])