首页 > 其他 > 详细

reshape&view&transpose

时间:2020-09-23 23:07:05      阅读:64      评论:0      收藏:0      [点我收藏+]
x = torch.tensor([1, 2, 3])
tensor([[1, 1, 1],
        [2, 2, 2],
        [3, 3, 3]])
x.reshape(-1)
tensor([1, 1, 1, 2, 2, 2, 3, 3, 3])

 view

a = torch.arange(0,20)	
a.view(4,5).shape
a.view(-1,5).shape (4,5)
a.view(4,5).shape (4,5)
#-1表示该为不知道设置多少

 

?view(-1,1,4) view(1,-1,4)

 

transpose

b = a.transpose(1, 2)  # Swaps 2nd and 3rd dimension

  

  

reshape&view&transpose

原文:https://www.cnblogs.com/lyl0618/p/13721561.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!