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

Title Here

Subtitle Here

An short introduction about PyTorch and about the chosen functions.

  • new_tensor
  • is_leaf
  • torch.cat
  • torch.where
  • torch.take
# Import torch and other required modules
import torch
import numpy as np

Function 1 - new_tensor

When data is a tensor x, new_tensor() reads out ‘the data’ from whatever it is passed, and constructs a leaf variable.

# Example 1 - working
tensor=torch.ones((3,),dtype=torch.int32)
data=[[1, 2], [3, 4.5]]
tensor.new_tensor(data)
tensor([[1, 2],
        [3, 4]], dtype=torch.int32)

We can also pass numpy array