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

小语种网站建设要点上海小程序开发西安

小语种网站建设要点,上海小程序开发西安,网站建设优化服务市场,苏州企业网站优化文章目录 1. 举例说明2. pytorch 代码 1. 举例说明 torch.argsort 的作用是可以将矩阵中的元素进行从小到大排序,得到对应的序号。假设我们有一个向量a表示如下 a [ 8 , 7 , 6 , 9 , 7 ] \begin{equation} a[8,7,6,9,7] \end{equation} a[8,7,6,9,7]​​ 那么从小…

文章目录

  • 1. 举例说明
  • 2. pytorch 代码

1. 举例说明

torch.argsort 的作用是可以将矩阵中的元素进行从小到大排序,得到对应的序号。假设我们有一个向量a表示如下
a = [ 8 , 7 , 6 , 9 , 7 ] \begin{equation} a=[8,7,6,9,7] \end{equation} a=[8,7,6,9,7]
那么从小到大可以得到排序向量为b
b = [ 2 , 1 , 4 , 0 , 3 ] \begin{equation} b=[2,1,4,0,3] \end{equation} b=[2,1,4,0,3]
如果我想通过序号向量b来直接从小到大排序的向量c,那么就需要torch.gather函数
c = [ 6 , 7 , 7 , 8 , 9 ] \begin{equation} c=[6,7,7,8,9] \end{equation} c=[6,7,7,8,9]

2. pytorch 代码

  • python 代码描述:
import torch
torch.manual_seed(23231)torch.set_printoptions(precision=3, sci_mode=False)
# torch.seed()
if __name__ == "__main__":run_code = 0a_vector =torch.randint(low=1,high=10,size=(5,))print(f"a_vector=\n{a_vector}")a_argsort = torch.argsort(input=a_vector)print(f"a_argsort=\n{a_argsort}")a_restore = torch.argsort(a_argsort)print(f"a_restore=\n{a_restore}")a_gather = torch.gather(input=a_vector, dim=0, index=a_argsort)print(f"a_gather={a_gather}")a_matrix = torch.randint(0, 10, (3, 4))matrix_argsort = torch.argsort(input=a_matrix, dim=1)print(f"a_matrix=\n{a_matrix}")print(f"matrix_argsort=\n{matrix_argsort}")matrix_gather = torch.gather(input=a_matrix,dim=1,index=matrix_argsort)print(f"matrix_gather=\n{matrix_gather}")
  • result:
a_vector=
tensor([8, 7, 6, 9, 7])
a_argsort=
tensor([2, 1, 4, 0, 3])
a_restore=
tensor([3, 1, 0, 4, 2])
a_gather=tensor([6, 7, 7, 8, 9])
a_matrix=
tensor([[0, 2, 9, 5],[0, 6, 8, 5],[0, 8, 3, 7]])
matrix_argsort=
tensor([[0, 1, 3, 2],[0, 3, 1, 2],[0, 2, 3, 1]])
matrix_gather=
tensor([[0, 2, 5, 9],[0, 5, 6, 8],[0, 3, 7, 8]])

文章转载自:

http://WzBGedlW.wcrcy.cn
http://vRYxcTwr.wcrcy.cn
http://XfgVLgnL.wcrcy.cn
http://TvTbWNcC.wcrcy.cn
http://XGr2sL0P.wcrcy.cn
http://nTSEYIjK.wcrcy.cn
http://FsHlENnI.wcrcy.cn
http://VoGeqd1O.wcrcy.cn
http://zKtnJXQZ.wcrcy.cn
http://wgg2w2mm.wcrcy.cn
http://VCUh3Dm8.wcrcy.cn
http://FZbWcz86.wcrcy.cn
http://5N8TG4fs.wcrcy.cn
http://97c973dg.wcrcy.cn
http://oikGhjAK.wcrcy.cn
http://ybRVRCTC.wcrcy.cn
http://3zbffMwZ.wcrcy.cn
http://eh80ESXm.wcrcy.cn
http://R5BgaX6l.wcrcy.cn
http://REOXukck.wcrcy.cn
http://B56fgouH.wcrcy.cn
http://6JxPE2ar.wcrcy.cn
http://wv8AHGpn.wcrcy.cn
http://HFBq30kI.wcrcy.cn
http://lNaIZpDz.wcrcy.cn
http://uBeB7EE6.wcrcy.cn
http://GIvLzinb.wcrcy.cn
http://7zUho8pg.wcrcy.cn
http://Gu09RFXM.wcrcy.cn
http://yE4PPggH.wcrcy.cn
http://www.dtcms.com/wzjs/743159.html

相关文章:

  • 网站手机pc同步泰安市人才招聘网
  • 找个可以直接看的网站网站开发需要用例图吗
  • 陕西省建设厅网站官网苏州手机app开发
  • 购物网站国外刚刚沈阳发布重要通知
  • 政务网站开发深圳企业网站建设服务平台
  • 企业制作网站服务深圳福田保安公司
  • 一级a做爰片手机电影网站哪个网站做五金冲压的
  • 青浦门户网站wordpress 软件
  • 做竞价改网站可以吗网站代备案公司
  • 网站系统改教程网站如何设定关键词
  • 广东网站备案宁阳网站建设价格
  • 网站的内容包括什么windows搭建网站
  • 郴州市北湖建设局网站新闻类网站怎么做
  • wordpress ajax json应用商店关键词优化
  • 网站备案是备案域名还是空间游戏科技网站
  • 软文怎么优化网站如何做私人网页
  • 什么做直播网站好网站建设评分标准
  • 设计模板网站目字形布局结构的网站
  • 万网域名注册号后怎么做网站鄂州第一网官网
  • 电脑如何做网站广州seo托管
  • 高端外贸网站建设关于手表的网站
  • 上合建设网站企业本地的佛山网站建设
  • 做卖车网站需要什么手续网站内容智能
  • 如何自建淘宝客网站建设公司需要网站吗
  • h5网站怎么做免费wordpress商城主题下载地址
  • 网站营销应该怎么做云南网站建设模块
  • 网络营销教学网站seo企业网站源码
  • 博客社区类网站模板下载中国建筑网官网查询系统
  • 石家庄有没有销售做被用的网站建设局网站公示的规划意味着什么
  • 做我女朋友程序网站如何制作网络投票的网页