t = torch.randn(3, 4) print(t.unsqueeze(0).shape) # torch.Size([1, 3, 4]) print(t.unsqueeze(1).shape) # torch.Size([3, 1, 4]) print(t.unsqueeze(-1).shape) # torch.Size([3, 4, 1])