suppose a is a tensor, then what's the difference between:
type(a)
a.type
a.type()
I couldn't find a document differentiating these.
suppose a is a tensor, then what's the difference between:
type(a)
a.type
a.type()
I couldn't find a document differentiating these.
type is the python in-built method.
<class 'torch.Tensor'>torch.Tensor.type (x.type()) is pytorch in-built method.
torch.DoubleTensor, etc.Edit:
And about x.type() vs x.type -
When you write a function name with parentheses x.type () it will actually execute the function and return its value. Whereas without parentheses x.type it is simply a reference to function.
type(a) - returns the class type
a.type - returns built method type
a.type() - return the data type
>>> a = torch.Tensor()
>>> type(a)
<class 'torch.Tensor'>
>>> a.type
<built-in method type of Tensor object at 0x7f6a0acfc140>
>>> a.type()
'torch.FloatTensor'