Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
Assignment One
A little about torch.Tensor
An short introduction about PyTorch and about the chosen functions.
- torch.arange
- torch.split
- torch.stack
- torch.abs
- torch.add
# Import torch and other required modules
import torch
import numpy
Function 1 - torch.arange
Returns a one dimensional tensor with values from start to end incremented by steps
# Example 1 - 1-D tensor with size of 10 with steps of 1
torch.arange(10)
tensor([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Notice that the tensor is started with 0. If no start parameter is provided, it defaults to 0.