reshape:
x = np.array([[[1,2,3],[4,5,6]],
[[7,8,9],[10,11,12]]])
print(x.reshape(2,6))
输出
[[ 1 2 3 4 5 6]
[ 7 8 9 10 11 12]]
torch.view:
# print(4&3)
x = torch.tensor([[[1,2,3],[4,5,6]],
[[7,8,9],[10,11,12]]])
print(x.view(2,6))
结果:
tensor([[ 1, 2, 3, 4, 5, 6],
[ 7, 8, 9, 10, 11, 12]])
作用是一样的,都以行开始排列