Search

Scalar, Vector, Matrix, and Tensor

Requirements
To follow this setup, it is required to have following …
No Requirements
Basic Types [torch]
# Scalar scalar = torch.tensor(1) scalar # Vector vector = torch.tensor([1,2,3]) vector # Matrix matrix = torch.tensor([[1,2,3],[4,5,6],[7,8,9]]) matrix # Tensor tensor = torch.tensor([[[1,2,3],[4,5,6],[7,8,9]],[[11,12,13],[14,15,16],[17,18,19]],[[21,22,23],[24,25,26],[27,28,29]]]) tensor
Python
복사
Synopsis [torch.functions]
a = torch.tensor(4., requires_grad = True) # Get torch shape/size a.shape >>> torch.Size([3, 3, 3]) >>> torch.Size([z, y, x]) # if Numpy a.dtype >>> dtype(’float64’) # if PyTorch a.dtype >>> torch.foat64 # Compute derivatives # Resquires to have requires_grad = True a.backward()
Python
복사

Reference