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

Lesson 1 PyTorch Basics: Tensors & Gradients

import torch

TENSORS

A tensor is a number, vector, matrix, or any n-dimensional array

#number
t1 = torch.tensor(4.)
t1
tensor(4.)
  1. is a shorthand for 4.0

This indicates that a floating-point number is created and this can be verified using the dtype attribute of our tensor.