操作
-
View/reshape
保持维度大小不变,改变shape -
Squeeze/unsqueeze
删减维度/增加维度 -
Transpose/t/permute
多维矩阵转置 -
Expand/repeat
维度扩展
1.View/reshape
image.png2.Squeeze/unsqueeze
unsqueeze(position)
position范围:[-a.dim()-1, a.dim()+1)
example
example
squeeze
image.png
3.Transpose/t/permute
-
**.t() **只能对2Dtensor操作
2D -
Transpose
QQ截图20200107170616.png - permute
4. Expand/repeat
-
Expand: broadcasting
推荐使用 -
Repeat: memory copied
复制数据
Repeat
网友评论