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

如何区分网站开发语言精准获客

如何区分网站开发语言,精准获客,截屏的图片wordpress不能显示,wordpress 多个sidebartorch.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://www.dtcms.com/wzjs/178039.html

相关文章:

  • 滨海企业做网站多少钱网站关键词排名快速提升
  • 私服充值网站怎么做的宁波网站推广大全
  • 宝塔如何添加ip域名做网站seo是什么技术
  • 微信公众平台登录入口官网seo营销推广多少钱
  • 人事处网站建设绩效目标概述企业网站快速排名
  • 推荐几个的网站网上的推广公司
  • 织梦cms网站模板修改全媒体运营师报名入口
  • 网站主机注册舟山seo
  • 网站点击滚动图片代码网络推广怎么做好
  • 三合一网站模板百度关键字搜索量查询
  • 卓越科技建站无锡做网站互联网营销师培训班
  • html判断域名 然后再跳转到网站许昌网络推广外包
  • 电商型企业网站建设百度推广系统营销平台
  • 可信网站图标 费流量网站内链优化
  • 江苏营销型网站策划营销管理系统
  • 贵州一帆建设工程有限公司网站北京seo运营
  • 中文网站建设教程网络营销策略内容
  • 一流的高密做网站的网络营销主要是什么
  • 石家庄高端网站开发百度免费发布信息
  • 漳州网站建设到博大优秀的网页设计网站
  • 网站做3年3年包括什么软件中国建设网官方网站
  • 那个网站教做馒头成都正规搜索引擎优化
  • 有了云服务器怎么做网站免费发广告的平台
  • 深圳品牌模板网站建设google play 应用商店
  • 做ppt赚钱的网站东莞网站关键词优化公司
  • 网站正在建设中 html源码怎么开通网站
  • php怎么做网站快seo引擎搜索网址
  • 网站维护收费徐州seo招聘
  • seo优化的主要任务seo优化常识
  • 网站seo插件成都seo工程师