Reputation: 85
I have a simple question regarding the shapes of 2 different tensors - tensor_1
and tensor_2
.
tensor_1.shape
outputs torch.Size([784, 1])
;tensor_2.shape
outputs torch.Size([784])
.I understand that the first one is rank-2 tensor, whereas the second is rank-1. What's hard for me is to conceptualize the difference between shape [784, 1]
and [784]
.
Is it correct to think that tensor_1
has 784 rows and 1 column with a scalar inside each place? If so, why can't we call it simply a column vector (which is, in fact, rank-1 tensor), which also has values displayed vertically?
Similarly, can the shape of the second tensor ([784]
) be imagined as 784 values inside a horizontal vector?
Upvotes: 4
Views: 2136
Reputation: 6618
You cant call tensor_1
as column vector because of its dimension . indexing that particular tensor is done in 2D
eg . tensor_1[1,1]
Coming to tensor_2
, its a scalar tensor having only one dimension.
And of course you can make it have a shape of tensor_1
, just do
tensor_2 = tensor_2.unsqueeze(1) #This method will make tensor_2 have a shape of tensor_1
Upvotes: 3