tensor
Definition
Tensor--"张量", actually it is a little bit like the vector to store numbers(linear algebra)
Operation
import torch
第一步永远是先导入torch库才能使用
0 Initializatin
x = torch.empty(a, b)
a rows and b columns of 0x = torch.random(a, b)
a rows and b columns of random numberx = torch.zeros(a, b, dtype = torch.long)
use dtype to specify the type of the entries in tensor(in this case, type is long)x = torch.tensor([x1, x2, ...])
use square brackets to init the size/ values of a tensory = torch.random_like(x, detype = torch.float)
,_like
mesans using an existing tensor to init another one(in this case, we use the size of the old tensor to create a new tensor with type float)