Learn practical skills, build real-world projects, and advance your career
import torch
#number
t1 = torch.tensor(4.)
print(t1)
t1.shape
tensor(4.)
torch.Size([])
t1.dtype
torch.float32
#vector
t2 = torch.tensor([1.,2,3,4])
print(t2)
t2.shape
tensor([1., 2., 3., 4.])
torch.Size([4])
#matrix
t3 = torch.tensor([[5.,6],[7,8],[9,10]])
print(t3)
t3.shape
tensor([[ 5., 6.], [ 7., 8.], [ 9., 10.]])
torch.Size([3, 2])