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

Pytorch Basics

Subtitle Here

An short introduction about PyTorch and about the chosen functions.

  • Changing List to Tensor
  • Changing array to tensor
  • creating various types of tensors and accessing elements
  • Expanding tensors
  • Creating Convolutions
# Import torch and other required modules
import torch

Function 1 - torch.tensor (change this)

Converting List to Tensors

# Example 1 - Changing List to tensor
torch.tensor([[1, 2, 3], 
              [4,5,6], 
              [3, 4,89]])
tensor([[ 1,  2,  3],
        [ 4,  5,  6],
        [ 3,  4, 89]])

A list consisting of 3 seperate elements converted to tensor