import torch v = torch.tensor([1, 2, 3, 4]) # shape (4,) row = v.unsqueeze(0) # (1, 4) — one row col = v.unsqueeze(1) # (4, 1) — one column print(row.shape, col.shape) # torch.Size([1, 4]) torch.Size([4, 1])