结论
torch.FloatTensor()默认生成32位浮点数,dtype 为 torch.float32
或 torch.float
验证
>>> tensor = torch.FloatTensor([[1,2],[3,4]])
>>> print tensor
tensor([[1., 2.],
[3., 4.]])
>>> print tensor.dtype
torch.float32
官网各类tensor对应数据类型如下:
https://pytorch.org/docs/stable/tensors.html?highlight=torch%20floattensor
Data type |
dtype |
CPU tensor |
GPU tensor |
---|---|---|---|
32-bit floating point |
|
|
|
64 |