In:
img.shape
Out:
torch.Size([1, 28, 28])
In:
img = images.unsqueeze(1)
In:
img.shape
Out:
torch.Size([4, 1, 1, 28, 28])
Can anyone pls tell me why .unsqueeze fauntion adds 2 dimentions?
batch size = 4
In:
img.shape
Out:
torch.Size([1, 28, 28])
In:
img = images.unsqueeze(1)
In:
img.shape
Out:
torch.Size([4, 1, 1, 28, 28])
Can anyone pls tell me why .unsqueeze fauntion adds 2 dimentions?
batch size = 4
Are you sure you are not mixing up img
and images
?
Additionally to the unsqueezed dimension img
also has suddently a batch size of 4, which wasn’t there previously.
Could you print images.shape
before unsqueezing it?