应用
torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]])
-----------------------------------------------------
tensor([[ 0.1000, 1.2000],
[ 2.2000, 3.1000],
[ 4.9000, 5.2000]])
-----------------------------------------------------
torch.tensor([[0.11111, 0.222222, 0.3333333]],
dtype=torch.float64,
device=torch.device('cuda:0')) # creates a torch.cuda.DoubleTensor
-----------------------------------------------------
tensor([[ 0.1111, 0.2222, 0.3333]], dtype=torch.float64, device='cuda:0')
-----------------------------------------------------
API
torch.tensor(data, dtype=None, device=None, requires_grad=False, pin_memory=False) → Tensor
参数 | 描述 |
---|---|
data (array_like) | |
dtype (torch.dtype, optional) | |
device (torch.device, optional) | |
requires_grad (bool, optional) | |
pin_memory (bool, optional) |
参考:
https://pytorch.org/docs/stable/generated/torch.tensor.html#torch.tensor