y =x = torch.tensor([1, 0])
x = torch.unsqueeze(x, dim=1)
print(x)
y = torch.unsqueeze(y, dim=0)
print(y)
# tensor([[1],
# [0]])
# tensor([[1, 0]])
torch.unsqueeze函数使用示例
于 2023-05-10 14:32:11 首次发布
y =x = torch.tensor([1, 0])
x = torch.unsqueeze(x, dim=1)
print(x)
y = torch.unsqueeze(y, dim=0)
print(y)
# tensor([[1],
# [0]])
# tensor([[1, 0]])