how to unsqueeze pytorch code example
Example: pytorch unsqueeze
ft = torch.Tensor([0, 1, 2])
print(ft.shape)
>>> torch.Size([3])
print(ft.unsqueeze(0)) # 0 means first dimension
print(ft.unsqueeze(0).shape)
>>> tensor([[0., 1., 2.]])
>>> torch.Size([1, 3])