pytorch中tensor进行reshape操作后原始数据的顺序
在pytorch中,经常需要对tensor进行reshape操作,使其符合特定网络的输入格式。在将网络的输
出重新reshape回输入前的形状时,tensor的特征是否还是按输入的顺序进行排列?
带着疑问做了下面的实验
1 | |
输出
1 | |
将x1, x2和x3三个tensor通过stack操作堆到一起后通过reshape操作改变维度的形状
接着再将reshape完的tensor变回原来的形状,发现输出数据的顺序和改变形状之前相同
表明在reshape过程中,tensor能够保持数据的顺序
pytorch中tensor进行reshape操作后原始数据的顺序
http://yojayc.github.io/2021/11/19/pytorch中tensor进行reshape操作后原始数据的顺序/