Learn practical skills, build real-world projects, and advance your career
# Jovian Commit Essentials
# Please retain and execute this cell without modifying the contents for `jovian.commit` to work
!pip install jovian --upgrade -q
import jovian
jovian.utils.colab.set_colab_file_id('1uGyxmfnfRPZ4jsVmUbNIsSLXtce9A1qq')

Torch Functions

An short introduction about PyTorch and about the chosen functions.

  • where - This function allow users to select values from two tensor depending on certain conditions. It works like an If else condition.
  • take - It allows user to select certain indices from a source tensor. Source tensor could be of any dimension
  • index_select - It allows users to selct certain rows or columns based on the index value provided along the row or column dimension
  • TORCH.ARGMAX - It allows user to select the index of largest value in the tensor
  • TORCH.AMAX - It allows user to select the largest value in a given dimension

Before we begin, let's install and import PyTorch

# 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.where

Add some explanations