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

Few funtions of pytorch with examples.

An short introduction about PyTorch and about the chosen functions.

  • function 1 - arange
  • function 2 - chunk
  • function 3 - reshape
  • function 4 - std_mean()
  • function 5 - unfold(dimesion,size,step)

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.arrange (Creation Ops)

Rwturns a one dimension tensor with the prameters chosen: START, END(ONLY ONE MANDATORY) and STEP.

# Example 1 - working 
torch.arange(8)
tensor([0, 1, 2, 3, 4, 5, 6, 7])