pytorch中和unsqueeze一样的维度扩充方法
torch.arange((10))[None, :],torch.arange((10))[:,None] #在外面增加了一个维度
output:
(tensor([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]),
tensor([[0],
[1],
[2],
[3],
[4],
[5],
[6],
[7],
[8],
[9]]))
torch.arange((10))[None, :].shape,torch.arange((10))[:,None].shape
output:
(torch.Size([1, 10]), torch.Size([10, 1]))