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

Assignment 1

Subtitle Here

An short introduction about PyTorch and about the chosen functions.

  • torch.linespace()
  • torch.cat()
  • torch.ones_like()
  • torch.transpose()
  • torch.clone
# Import torch and other required modules
import torch

Function 1 - torch.linspace()

This creates a 1D tensor between the start and endpoint

# Example 1 - with 10 steps
torch.linspace(1,20,10)
tensor([ 1.0000,  3.1111,  5.2222,  7.3333,  9.4444, 11.5556, 13.6667, 15.7778,
        17.8889, 20.0000])

Creates 1D tensor with equal steps between 1 and 20 with 10 steps in total.