Learn practical skills, build real-world projects, and advance your career
Created 3 years ago
import torch
# Number
t1 = torch.tensor(4.)
t1
tensor(4.)
t1.dtype
torch.float32
# Vector
t2 = torch.tensor([1., 2, 3, 4])
t2
tensor([1., 2., 3., 4.])
# Matrix
t3 = torch.tensor([[5., 6],
[7, 8],
[9, 10]])
t3
tensor([[ 5., 6.],
[ 7., 8.],
[ 9., 10.]])