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

Pytorch Tensors

Assignment 1 - All About torch.Tensor

An short introduction about PyTorch and about the chosen functions.

  • new_empty
  • clone
  • expand_as
  • index_add_
  • item
# Import torch and other required modules
import torch
tensor = torch.tensor(())

Function 1 - tensor.new_empty()

Sometimes we wish to generate a new tensor without copying any data. This function allows us to do this by using
uninitialized data.

# Example 1 - sample usage
tensor.new_empty((1,2))
tensor([[-1.1012e+13,  4.5765e-41]])

We can specify the dimensions of the tensor that we desire in the parameters of the function call.