美文网首页
(六)Tensor维度变换

(六)Tensor维度变换

作者: zelda2333 | 来源:发表于2020-02-12 10:32 被阅读0次

操作

  • View/reshape
    保持维度大小不变,改变shape
  • Squeeze/unsqueeze
    删减维度/增加维度
  • Transpose/t/permute
    多维矩阵转置
  • Expand/repeat
    维度扩展

1.View/reshape

image.png

2.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
permute

4. Expand/repeat

  • Expand: broadcasting
    推荐使用
  • Repeat: memory copied
    复制数据
Expand
Repeat

相关文章

网友评论

      本文标题:(六)Tensor维度变换

      本文链接:https://www.haomeiwen.com/subject/odaractx.html