본문 바로가기
IT/machine learning

[pytorch] difference between torch.Tensor and torch.LongTensor

by Jang HyunWoong 2018. 7. 6.

A [torch.Tensor] is a multiple dimensional matrix containing elements of a single data type.


[torch.Tensor] is same as [torch.FloatTensor].


look at this table.


Data typedtypeCPU tensorGPU tensor
32-bit floating pointtorch.float32 or torch.floattorch.FloatTensortorch.cuda.FloatTensor
64-bit floating pointtorch.float64 or torch.doubletorch.DoubleTensortorch.cuda.DoubleTensor
16-bit floating pointtorch.float16 or torch.halftorch.HalfTensortorch.cuda.HalfTensor
8-bit integer (unsigned)torch.uint8torch.ByteTensortorch.cuda.ByteTensor
8-bit integer (signed)torch.int8torch.CharTensortorch.cuda.CharTensor
16-bit integer (signed)torch.int16 or torch.shorttorch.ShortTensortorch.cuda.ShortTensor
32-bit integer (signed)torch.int32 or torch.inttorch.IntTensortorch.cuda.IntTensor
64-bit integer (signed)torch.int64 or torch.longtorch.LongTensortorch.cuda.LongTensor

- <pytorch.org/docs/stable/tensors.html>


So, when we define a value as [torch.Tensor], it's a float type value.


[torch.LongTensor] is an int64 data type value.

[torch.Tensor] is a float32 data type value.





반응형