>>> t = torch.tensor([[1,1,1,1],[2,2,2,2],[3,3,3,3]], dtype= torch.float32)
>>>
>>> t
tensor([[1., 1., 1., 1.],
[2., 2., 2., 2.],
[3., 3., 3., 3.]])
>>> t.size()
torch.Size([3, 4])
>>> t.shape()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'torch.Size' object is not callable
>>> t.shape
torch.Size([3, 4])
>>>
>>>
>>> len(t.shape)
2
>>> torch.tensor(t.shape).prod()
tensor(12)
>>> t.numel()
12
>>> t
tensor([[1., 1., 1., 1.],
[2., 2., 2., 2.],
[3., 3., 3., 3.]])
>>> t.reshape(2,2,3)
tensor([[[1., 1., 1.],
[1., 2., 2.]],
[[2., 2., 3.],
[3., 3., 3.]]])
>>> t.shape
torch.Size([3, 4])
>>> t.size()
torch.Size([3, 4])
>>> t = t.reshape(2,2,3)
>>> t.shape
torch.Size([2, 2, 3])
>>> torch.tensor(t.shape).prod()
tensor(12)
>>> t.numel()
12
>>> t.reshape(1,12).squeeze()
tensor([1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.])
>>> t.reshape(1,12).squeeze().shape
torch.Size([12])
>>> t.reshape(1,12).squeeze()
tensor([1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.])
>>> t.reshape(1,12).squeeze().unsqueeze(dim=0)
tensor([[1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]])