What is the relationship between torch.Tensor
and torch.FloatTensor
? In the Pytorch document, its says that torch.Tensor
is an alias for torch.FloatTensor
. I don’t quiet understand what this means.
For example, I created a tensor x
using torch.tensor
function which should return an instance of torch.Tensor
class.
>>> x = torch.tensor([1., 2.])
>>> isinstance(x, torch.Tensor)
True
>>> isinstance(x, torch.FloatTensor)
True
>>> issubclass(torch.FloatTensor, torch.Tensor)
False
It turns out x
is an instance of torch.FloatTensor
as well as torch.Tensor
. So, I initially thought that torch.FloatTensor
was a subclass of torch.Tensor
, which it turned out that it wasn’t!!
How is this possible that x
is an instance of both torch.FloatTensor
and torch.Tensor
when these two classes are not in inheritence relationship?
Also, what is the relationship between torch.Tensor
and torch.FloatTensor
and how are they different?