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

Assignment 1

PyTorch is an open source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook's AI Research lab. The following are the 5 functions that I have chosen

  • torch.chunk
  • torch.masked_select
  • torch.std_mean
  • torch.index_select
  • torch.argmax
# Uncomment and run the appropriate command for your operating system, if required

# Linux / Binder
# !pip install numpy torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

# Windows
# !pip install numpy torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

# MacOS
# !pip install numpy torch torchvision torchaudio
# Import torch and other required modules
import torch

Function 1 - torch.chunk

Splits a tensor into a specific number of chunks.

# Example 1 - working (change this)
t1 = torch.tensor([[1., 2], [3, 4],[ 5, 6]])
torch.chunk(t1,3,0)
(tensor([[1., 2.]]), tensor([[3., 4.]]), tensor([[5., 6.]]))