a=torch.Tensor([[[1,2,3],[4,5,6]]])
b=torch.Tensor([1,2,3,4,5,6])
print(a.view(1,6))
print(b.view(1,6))
得到的结果都是tensor([[1., 2., 3., 4., 5., 6.]])
再看一个例子:
a=torch.Tensor([[[1,2,3],[4,5,6]]])
print(a.view(3,2))
将会得到:
tensor([[1., 2.],
[3., 4.],
[5., 6.]])