例子1
import torch
T = torch.tensor([[1,2,3],[4,5,6]])
T_Shape = T.reshape(-1,1)
print(T_Shape.shape)
print(T_Shape)
输出:
torch.Size([6, 1])
tensor([[1],
[2],
[3],
[4],
[5],
[6]])
例子2
import torch
T = torch.tensor([[1,2,3],[4,5,6]])
T_Shape = T.reshape(-1)
print(T_Shape.shape)
print(T_Shape)
输出:
torch.Size([6])
tensor([1, 2, 3, 4, 5, 6])