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

收费网站怎么制作佛山公司官网制作哪家好

收费网站怎么制作,佛山公司官网制作哪家好,电子商务是学什么的,专业建网站设计公司Pytorch:cat、stack、squeeze、unsqueeze的用法 torch.cat 在指定原有维度上链接传入的张量,所有传入的张量都必须是相同形状 torch.cat(tensors, dim0, *, outNone) → Tensor tensor:相同形状的tensor dim:链接张量的维度,不能超过传入张…

Pytorch:cat、stack、squeeze、unsqueeze的用法

torch.cat

在指定原有维度上链接传入的张量,所有传入的张量都必须是相同形状

torch.cat(tensors, dim=0, *, out=None) → Tensor

tensor:相同形状的tensor
dim:链接张量的维度,不能超过传入张量的维度

x = torch.tensor([[0, 1, 2]], dtype= torch.float)
y = torch.tensor([[3, 4, 5]], dtype= torch.int)
print(x.shape, y.shape)
print("-"*50)
z = torch.cat((x, y), dim= 0)
print(z)
print(z.shape)
print("-"*50)
z = torch.cat((x, y), dim= 1)
print(z)
print(z.shape)

在这里插入图片描述

torch.stack

在一个新的维度上链接张量,输入张量都必须是相同形状的

torch.stack(tensors, dim=0, *, out=None) → Tensor

tensor:相同形状的张量
dim:插入的张量维度,在0和输出张量维度(比输入张量维度多一个)之间

x = torch.tensor([[0, 1, 2]])
y = torch.tensor([[3, 4, 5]])
print(x.shape, y.shape)
print("-"*50)
z = torch.stack((x, y), dim= 0)
print(z)
print(z.shape)
print("-"*50)
z = torch.stack((x, y), dim= 1)
print(z)
print(z.shape)
print("-"*50)
z = torch.stack((x, y), dim= 2)
print(z)
print(z.shape)

在这里插入图片描述

torch.squeeze

压缩张量,去掉输入张量中大小为1的维度,例如:(Ax1xBxCx1)->(AxBxC)

torch.squeeze(input, dim=None) → Tensor

input (Tensor):输入张量
dim (int or tuple of ints, optional):只压缩某个维度,可以不指定,就是压缩所有大小为1的维度

x = torch.tensor([[0, 1, 2]])
y = torch.rand(size= (1, 2, 1, 2, 1))
print(x.shape, y.shape)
print("-"*50)
z = torch.squeeze(x)
print(z)
print(z.shape)
print("-"*50)
z = torch.squeeze(y)
print(z)
print(z.shape)

在这里插入图片描述

torch.unsqueeze

在输入张量中指定位置插入一个大小为1的维度

torch.unsqueeze(input, dim) → Tensor

input (Tensor):输入张量
dim (int):插入维度的指定位置

x = torch.randn(size= (2,3))
print(x.shape)
print("-"*50)
z = torch.unsqueeze(x, 0)
print(z)
print(z.shape)
print("-"*50)
z = torch.unsqueeze(x, 1)
print(z)
print(z.shape)

在这里插入图片描述

http://www.yayakq.cn/news/423293/

相关文章:

  • 宝塔织梦网站建设中国国内最新新闻
  • 怎么做网站优化 sit网站营销推广的公司
  • wordpress新建子域名多站点没有网站百度推广
  • 大同建设网站搭建网页代码流程
  • 网站类型怎么分wordpress页眉插件
  • 大连市网站建设怎么做好网站
  • 平顶山建设局网站科技感网站设计
  • 装修公司合作平台的网站做设计需要知道的几个网站
  • 海络网站网站图片多大
  • 河南网站建设的详细策划自己做网站怎么搜索
  • 镇江网站制作咨询西安seo网站优化
  • 为什么有的网站只有版权没有备案有没有资源免费的
  • 成都手机网站建设有网站源代码 怎么样建设网站
  • 北京网站建设公司哪个好武安市网站建设
  • 企业可以在哪些网站做免费宣传湖州做网站建设的公司哪家好
  • 向网站上传文件怎么做wordpress 优秀作者
  • 深圳规划建设局网站做网站给女朋友
  • 娱乐网站建设ppt云浮 网站建设
  • 网站建设技术服务费记什么科目上海网站制作
  • 网站建设维护方案ppt国外客户的网站电话
  • 未支付网站建设挂哪个科目wordpress会员功能主题
  • 网站开发一般用什么服务器学院网站设计案例
  • 做网站都用什么软件如何推广网站
  • 做哪个网站最简单余姚 网站建设
  • 做企业网站 长春h5企业网站只做
  • 做网站是用的那个开发软件百度公司网站推广怎么做
  • 甘肃省长城建设集团网站网站名百度搜不到
  • 软件下载平台哪个好深圳网站seo优化
  • 360报危险网站怎样让客户做网站
  • 网站开发还是做数据库开发文化礼堂建设情况网站