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

My assignment

Functions I have choosen.

I have choosen some of the basic function that allow operation on tensors. Because I am a beginner I thought it is good to start with basic ones.

  • torch.numel(input)
  • torch.from_numpy(ndarray)
  • torch.randn(*sizes)
  • torch.arange(start,end,step)
  • torch.reshape(input, shape)
# Import torch and other required modules
import torch

Function 1 - torch.numel(input)

It returns a number of elements in tensor

# Example 1
a = torch.randn(2,2,2)
a
tensor([[[-1.0944,  0.2224],
         [ 1.5870, -0.1892]],

        [[ 1.3065, -0.0491],
         [-0.1362, -1.0960]]])
torch.numel(a)
8