举例:
一维变二维
t = torch.Tensor([0.3469, 0.4094, 0.4969, 0.5594])
方法:
t[None]
t.unsqueeze(dim=0)
t.reshape(1,-1)
t.view(1,-1)
输出效果:
tensor([[0.3469, 0.4094, 0.4969, 0.5594]])
举例:
一维变二维
t = torch.Tensor([0.3469, 0.4094, 0.4969, 0.5594])
方法:
t[None]
t.unsqueeze(dim=0)
t.reshape(1,-1)
t.view(1,-1)
输出效果:
tensor([[0.3469, 0.4094, 0.4969, 0.5594]])