当前位置: 首页 > wzjs >正文

网站建设哪家好?看这里襄阳专业做网站

网站建设哪家好?看这里,襄阳专业做网站,郑州专业公司网站制作公司,哪个网站找做软件下载torch.stack方法详解 pytorch官网注释 Parameters tensors:张量序列,也就是要进行stack操作的对象们,可以有很多个张量。 dim:按照dim的方式对这些张量进行stack操作,也就是你要按照哪种堆叠方式对张量进行堆叠。dim的…

torch.stack方法详解

stack解释
pytorch官网注释
pytorch官网

Parameters
tensors:张量序列,也就是要进行stack操作的对象们,可以有很多个张量。
dim:按照dim的方式对这些张量进行stack操作,也就是你要按照哪种堆叠方式对张量进行堆叠。dim的取值范围为闭区间[0,输入Tensor的维数]
return
堆叠后的张量

二、例子

2.1 一维tensor进行stack操作

import torch as tx = t.tensor([1, 2, 3, 4])
y = t.tensor([5, 6, 7, 8])print(x.shape)
print(y.shape)z1 = t.stack((x, y), dim=0)
print(z1)
print(z1.shape)z2 = t.stack((x, y), dim=1)
print(z2)
print(z2.shape)
torch.Size([4])
torch.Size([4])
tensor([[1, 2, 3, 4],[5, 6, 7, 8]])
torch.Size([2, 4])
tensor([[1, 5],[2, 6],[3, 7],[4, 8]])
torch.Size([4, 2])

图解

2.2 2个二维tensor进行stack操作

 import torch as tx = t.tensor([[1,2,3],[4,5,6]])y = t.tensor([[7,8,9],[10,11,12]])print(x.shape)print(y.shape)z1 = t.stack((x,y), dim=0)print(z1)print(z1.shape)z2 = t.stack((x,y), dim=1)print(z2)print(z2.shape)z3 = t.stack((x,y), dim=2)print(z3)print(z3.shape)
torch.Size([2, 3])
torch.Size([2, 3])
tensor([[[ 1,  2,  3],[ 4,  5,  6]],[[ 7,  8,  9],[10, 11, 12]]])
torch.Size([2, 2, 3])
tensor([[[ 1,  2,  3],[ 7,  8,  9]],[[ 4,  5,  6],[10, 11, 12]]])
torch.Size([2, 2, 3])
tensor([[[ 1,  7],[ 2,  8],[ 3,  9]],[[ 4, 10],[ 5, 11],[ 6, 12]]])
torch.Size([2, 3, 2])

在这里插入图片描述

2.3 多个二维tensor进行stack操作

import torchx = torch.tensor([[1,2,3],[4,5,6]])
y = torch.tensor([[7,8,9],[10,11,12]])
z = torch.tensor([[13,14,15],[16,17,18]])
print(x.shape)
print(y.shape)
print(z.shape)r1 = torch.stack((x,y,z),dim=0)
print(r1)
print(r1.shape)r2 = torch.stack((x,y,z),dim=1)
print(r2)
print(r2.shape)r3 = torch.stack((x,y,z),dim=2)
print(r3)
print(r3.shape)
torch.Size([2, 3])
torch.Size([2, 3])
torch.Size([2, 3])
tensor([[[ 1,  2,  3],[ 4,  5,  6]],[[ 7,  8,  9],[10, 11, 12]],[[13, 14, 15],[16, 17, 18]]])
torch.Size([3, 2, 3])
tensor([[[ 1,  2,  3],[ 7,  8,  9],[13, 14, 15]],[[ 4,  5,  6],[10, 11, 12],[16, 17, 18]]])
torch.Size([2, 3, 3])
tensor([[[ 1,  7, 13],[ 2,  8, 14],[ 3,  9, 15]],[[ 4, 10, 16],[ 5, 11, 17],[ 6, 12, 18]]])
torch.Size([2, 3, 3])

2.4 2个三维tensor进行stack操作

import torchx= torch.tensor([[[1,2,3],[4,5,6]],[[2,3,4],[5,6,7]]])
y = torch.tensor([[[7,8,9],[10,11,12]],[[8,9,10],[11,12,13]]])
print(x.shape)
print(y.shape)
z1 = torch.stack((x,y),dim=0)
print(z1)
print(z1.shape)
z2 = torch.stack((x,y),dim=1)
print(z2)
print(z2.shape)
z3 = torch.stack((x,y),dim=2)
print(z3)
print(z3.shape)
z4 = torch.stack((x,y),dim=3)
print(z4)
print(z4.shape)
torch.Size([2, 2, 3])
torch.Size([2, 2, 3])
tensor([[[[ 1,  2,  3],[ 4,  5,  6]],[[ 2,  3,  4],[ 5,  6,  7]]],[[[ 7,  8,  9],[10, 11, 12]],[[ 8,  9, 10],[11, 12, 13]]]])
torch.Size([2, 2, 2, 3])
tensor([[[[ 1,  2,  3],[ 4,  5,  6]],[[ 7,  8,  9],[10, 11, 12]]],[[[ 2,  3,  4],[ 5,  6,  7]],[[ 8,  9, 10],[11, 12, 13]]]])
torch.Size([2, 2, 2, 3])
tensor([[[[ 1,  2,  3],[ 7,  8,  9]],[[ 4,  5,  6],[10, 11, 12]]],[[[ 2,  3,  4],[ 8,  9, 10]],[[ 5,  6,  7],[11, 12, 13]]]])
torch.Size([2, 2, 2, 3])
tensor([[[[ 1,  7],[ 2,  8],[ 3,  9]],[[ 4, 10],[ 5, 11],[ 6, 12]]],[[[ 2,  8],[ 3,  9],[ 4, 10]],[[ 5, 11],[ 6, 12],[ 7, 13]]]])
torch.Size([2, 2, 3, 2])

参考文献

[1] PyTorch基础(18)-- torch.stack()方法

[2]pytorch官网注释


文章转载自:

http://RsBsWwn6.ffLnj.cn
http://tadtzziT.ffLnj.cn
http://UWsraJ6T.ffLnj.cn
http://hOh2NZkc.ffLnj.cn
http://QFIhtxnj.ffLnj.cn
http://pI3W4lD5.ffLnj.cn
http://nLdjgbZu.ffLnj.cn
http://DIDXS9lp.ffLnj.cn
http://VQL4UE6O.ffLnj.cn
http://4MoaJb0o.ffLnj.cn
http://6HrujaA9.ffLnj.cn
http://RtjDQkH4.ffLnj.cn
http://oDAFSKcd.ffLnj.cn
http://UfB7WcaW.ffLnj.cn
http://R2fLoXuH.ffLnj.cn
http://IZMBmlZM.ffLnj.cn
http://LrC4MNR7.ffLnj.cn
http://om3rRb4q.ffLnj.cn
http://sJZnvNg4.ffLnj.cn
http://l40Ngpat.ffLnj.cn
http://m0ibZYZb.ffLnj.cn
http://rwZXYDTC.ffLnj.cn
http://jtGEjJXM.ffLnj.cn
http://jIL10RIi.ffLnj.cn
http://sqccErth.ffLnj.cn
http://IO0nbYBS.ffLnj.cn
http://tpza5Fg2.ffLnj.cn
http://kYkUJDBT.ffLnj.cn
http://iYQQ6fYC.ffLnj.cn
http://5wdCETVp.ffLnj.cn
http://www.dtcms.com/wzjs/614204.html

相关文章:

  • 北京长空建设有限公司网站wordpress 同城生活
  • 响应式网站后台聊城做网站价位
  • 石家庄网站建设推广公司报价音乐分享网站源码
  • 网站右侧二维码阿里云网站备案拍照点
  • 做评测好的视频网站江苏城乡建设学院网站
  • 用npp做网站电商设计就是网站设计吗
  • 网站开发与调试实验报告房地产市场分析
  • 网站优化基础建一个个人网站多少钱
  • 广州公司制作网站什么是关键词举例说明
  • 云建站规划图电影免费在线观看
  • 赫山区网站建设做代收水果是什么网站
  • 怎么在网站上做排名ui手机app界面设计
  • 做公司网站需不需要注册建设个人网站需要备案吗
  • 毕业设计做网站用什么软件百度官网平台
  • 宁波网站推广找哪家公司网站建设业务元提成
  • 网站制作公司中企动力推荐石家庄专门做网站的公司
  • 高端定制网站公司哪家好微信商城小程序怎么做
  • 网站批量收录四川城乡住房和城乡建设厅网站首页
  • 专门做投票的网站有哪些wordpress中调用分类目录文章列表
  • 网站搭建php源码房产中介网站开发
  • 北京网站建设制作方案关键词优化的技巧
  • asp网站栏目修改做网站的人
  • 龙岩网站设计理念网站开发最好用什么语言
  • 重庆建设工程安全管理协会网站网站欢迎界面设计
  • 网站 免费认证久久建筑网会员登陆
  • 网站开发制作公司排行免费的云存储空间
  • 北京市建设公租房网站代理做减肥网站
  • 网站推广应该怎么做?济宁做网站多少钱
  • 濮阳免费网站制作十大互联网装修平台排名
  • 上海网站建设 方案汽水音乐怎么推广赚钱