In Python3 & PyTorch 1.0.0,
torch.LongTensor and torch.cuda.LongTensor means int64.
HalfTensor : float16
FloatTensor : float32
DoubleTensor : float64
ByteTensor : uint8(unsigned)
CharTensor : int8(signed)
ShortTensor : int16(signed)
IntTensor : int32(signed)
LongTensor : int64(signed)
One example of conversion from LongTensor to FloatTensor:
1 | |
Attention:
1 | |
b.type() equals LongTensor. The implicit type casting did not work because type(a) is torch.Tensor instead of Python raw numbers or Numpy array.
The solution is as follows:
1 | |
Here, b.type() equals FloatTensor.