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

Assignment 1

Assignment 1 - All About torch.Tensor

An short introduction about PyTorch and about the chosen functions.

  • torch.tensor
  • torch.empty
  • torch.rand
  • torch.zeros
  • torch.from_numpy (There is one very interesting feature - Torch Tensor is connected to the np array and changes simultaneously with it! Check it out!)
# Import torch
import torch

torch.tensor

A torch.tensor is a multi-dimensional matrix containing elements of a single data type.
Torch defines nine CPU tensor types and nine GPU tensor types.

import torch

torch.Tensor is an alias for the default tensor type (torch.FloatTensor). So we can just write