v = torch.tensor([1, 2, 3, 4]) row = v[None, :] # same as unsqueeze(0) col = v[:, None] # same as unsqueeze(1) print(row.shape, col.shape) # torch.Size([1, 4]) torch.Size([4, 1])