How to interpret Tensor sizes?
I'm having difficulty understanding the difference between the following:
x1 = torch.tensor([1, 2, 3])  # single brackets
x2 = torch.tensor([[1, 2, 3]])  # double brackets
When checking their sizes:
x1.size() and x2.size() we get the following:
torch.Size([3])
torch.Size([1, 3])

Which I interpret as x1 being a (3x1) column vector, while x2 is a (1x3) row vector.
However, when attempting to transpose both vectors:
print(x1.T)
print(x2.T), we get:
tensor([1, 2, 3])
tensor([[1],
        [2],
        [3]])

x1 seems to be unaffected by transposition?
Further when attempting to force x1 to be a (1x3) row vector using &quot;.view()&quot;:
print(x1.view(1, -1)) we get:
tensor([[1, 2, 3]])  # double brackets

So how come &quot;.T&quot; didn't do the trick, but &quot;.view(1, -1)&quot; was able to transform x1 into a (1x3) row vector?
What really is x1 when we first assigned it?

As per official documentation -

Expects input to be &lt;= 2-D tensor and transposes dimensions 0 and 1.
0-D and 1-D tensors are returned as is. When input is a 2-D tensor this is equivalent to transpose(input, 0, 1).

x = torch.randn(())
torch.t(x)
#tensor(0.1995)

x = torch.randn(3)
x
#tensor([ 2.4320, -0.4608,  0.7702])

torch.t(x)
#tensor([ 2.4320, -0.4608,  0.7702])

x = torch.randn(2, 3)
x
#tensor([[ 0.4875,  0.9158, -0.5872],
#        [ 0.3938, -0.6929,  0.6932]])

torch.t(x)
#tensor([[ 0.4875,  0.3938],
#        [ 0.9158, -0.6929],
#        [-0.5872,  0.6932]])

This is the reason why x1 has no effect. It's currently a 1D tensor and NOT a 2D tensor. There is a difference between the shape of (3,) and (3,1). The first only has a single axis while the other has 2 axis (similar to the double brackets you added)
This statement, Which I interpret as x1 being a (3x1) column vector, while x2 is a (1x3) row vector. is incorrect to some extent.
x1 #(3,) 1D tensor
x1.reshape((3,1) #(3,1) #2D tensor

x1.T #(1,3) 2D tensor with successful transpose

