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

前端自己做博客网站dw网页设计模板100套

前端自己做博客网站,dw网页设计模板100套,济南网站推广¥做下拉去118cr,ueditor html 转 wordpressPyTorch深度学习总结 第五章 PyTorch中张量(Tensor)统计操作 文章目录 PyTorch深度学习总结前言一、最值查找二、特殊值查询 前言 上文介绍了PyTorch中张量(Tensor)的计算操作#xff0c;本文将介绍张量的统计操作。 一、最值查找 函数描述torch.max()找出张量中的最大值to…PyTorch深度学习总结 第五章 PyTorch中张量(Tensor)统计操作 文章目录 PyTorch深度学习总结前言一、最值查找二、特殊值查询 前言 上文介绍了PyTorch中张量(Tensor)的计算操作本文将介绍张量的统计操作。 一、最值查找 函数描述torch.max()找出张量中的最大值torch.argmax()输出最大值所在位置torch.min()找出张量中的最小值torch.argmin()输出最小值所在位置torch.sort()对一维张量或多维(每个维度单独)进行排序torch.topk(A, k)根据指定值k计算出张量A取值为前k大的值并显示所在位置torch.kthvalue(A, k)根据指定值k计算出张量A取值为第k小的值并显示所在位置 创建张量 # 引入库 import torch# 创建张量A A torch.arange(2., 8.).reshape(2,3) print(A)输出结果为tensor([[2, 3, 4], [5, 6, 7]]) 测试函数 print(A.max()) print(A.argmax()) print(A.min()) print(A.argmin())输出结果为(含注释) tensor(7.) tensor(5) # 0-5的最后一位 tensor(2.) tensor(0) # 0-5的第一位 torch.sort() 创建随机张量B: # 创建随机张量B B torch.randperm(15).reshape(3, 5) # torch.randperm(n)可以生成有n个0-10之间整数组成的张量 print(B)输出结果为 tensor( [[13, 9, 1, 2, 0], [ 4, 14, 12, 3, 7], [ 5, 6, 8, 11, 10]]) 对张量B进行排序 # 升序输出 print(B.sort()) # 分别输出排序后的值以及该值在原索引中不同维度的位置(列数)输出结果为 torch.return_types.sort( valuestensor([[ 0, 1, 2, 9, 13], [ 3, 4, 7, 12, 14], [ 5, 6, 8, 10, 11]]), indicestensor([[4, 2, 3, 1, 0], [3, 0, 4, 2, 1], [0, 1, 2, 4, 3]])) # 降序输出 print(B.sort(descendingTrue))输出结果为 torch.return_types.sort( valuestensor([[13, 9, 2, 1, 0], [14, 12, 7, 4, 3], [11, 10, 8, 6, 5]]), indicestensor([[0, 1, 3, 2, 4], [1, 2, 4, 0, 3], [3, 4, 2, 1, 0]])) 测试函数torch.topk() # 选取每个维度最大和次大的值及其位置 print(B.topk(2))输出结果为 torch.return_types.topk( valuestensor([[13, 9], [14, 12], [11, 10]]), indicestensor([[0, 1], [1, 2], [3, 4]])) # 选取2-dim维度前2大的值及其位置 print(B) print(B.topk(2, dim0)) # 每列最大的两个值输出结果为(含注释) tensor([[13, 9, 1, 2, 0], [ 4, 14, 12, 3, 7], [ 5, 6, 8, 11, 10]]) torch.return_types.topk( valuestensor([[13, 14, 12, 11, 10], [ 5, 9, 8, 3, 7]]), indicestensor([[0, 1, 1, 2, 2], [2, 0, 2, 1, 1]])) # indices表示对应元素的行数 # 选取2-dim最大和次大的值及其位置 print(B.topk(2, dim1)) # 与默认情况相同默认情况输出结果为 torch.return_types.topk( valuestensor([[13, 9], [14, 12], [11, 10]]), indicestensor([[0, 1], [1, 2], [3, 4]])) 测试函数torch.kthvalue() # 选取每个维度第2小的值及其位置 print(B) print(B.kthvalue(2))输出结果为 tensor([[13, 9, 1, 2, 0], [ 4, 14, 12, 3, 7], [ 5, 6, 8, 11, 10]]) torch.return_types.kthvalue( valuestensor([1, 4, 6]), indicestensor([2, 0, 1])) 二、特殊值查询 函数描述torch.mean(A, dim0)根据指定维度计算均值torch.sum(A, dim0)根据指定维度求和torch.cumsum(A, dim0)根据指定维度计算累加和torch.median(A, dim0)根据指定维度计算中位数torch.cumprod(A, dim0)根据指定维度计算乘积torch.std(A, dim0)根据指定维度计算标准差 测试函数(维度0) print(A) print(A.mean(dim0)) print(A.sum(dim0)) print(A.cumsum(dim0)) print(A.median(dim0)) print(A.cumprod(dim0)) print(A.std(dim0))输出结果为(含注释) tensor([[2., 3., 4.], [5., 6., 7.]]) # 张量A tensor([3.5000, 4.5000, 5.5000]) # 每列均值 tensor([ 7., 9., 11.]) # 每列求和 tensor([[ 2., 3., 4.], [ 7., 9., 11.]]) # 每列累加求和 torch.return_types.median( valuestensor([2., 3., 4.]), indicestensor([0, 0, 0])) # 每列中位数及索引 tensor([[ 2., 3., 4.], [10., 18., 28.]]) # 每列累乘 tensor([2.1213, 2.1213, 2.1213]) # 每列标准差 print(A) print(A.mean(dim1)) print(A.sum(dim1)) print(A.cumsum(dim1)) print(A.median(dim1)) print(A.cumprod(dim1)) print(A.std(dim1))输出结果为(含注释) tensor([[2., 3., 4.], [5., 6., 7.]]) # 张量A tensor([3., 6.]) # 每行均值 tensor([ 9., 18.]) # 每行求和 tensor([[ 2., 5., 9.], [ 5., 11., 18.]]) # 按行逐个累加 torch.return_types.median( valuestensor([3., 6.]), indicestensor([1, 1])) # 每行中位数 tensor([[ 2., 6., 24.], [ 5., 30., 210.]]) # 按行逐个累乘 tensor([1., 1.]) # 每行标准差
http://www.zqtcl.cn/news/583905/

相关文章:

  • 株洲网站设计外包运营wordpress seo插件教程
  • 做湘菜的网站wordpress外贸网站
  • 可以做书的网站做网站的软件叫什么
  • 深圳营销型网站公司电话网站优化北京如何联系?
  • 网站配资公司网站织梦怎么关闭网站
  • 建设企业网站哪家好网站页面布局设计思路
  • 长尾词在线挖掘数字营销服务商seo
  • cms傻瓜式建站系统帝国 cms 网站关键字
  • 东莞营销网站建设直播php 网站 项目
  • 网站访问量什么意思wordpress 静态商店
  • 汕头建站平台网站如何配置域名
  • 大芬网站建设石嘴山网站建设
  • 彩票网站开发解决方案wordpress网站如何与关联
  • 怎么做各大视频网站的会员代理芜湖的网站建设
  • 番禺做网站开发免费素材下载网站
  • 做网站服务公司王业美
  • 遵义网站建设推广城乡住房建设部官网查询
  • 电商设计网站素材免费建站网站seo
  • 做雕塑网站丹阳网站推广
  • 夏津网站建设公司应用分析网站
  • 长春seo网站优化个人网站要有什么
  • 网站开发流程步骤 口袋青海个人旅游网站建设
  • php企业网站多少钱图书馆网站建设建议
  • 企业网站建设综合实训学习体会个人网站空间申请
  • 企业小型网站要多少钱合肥城乡建设网站首页
  • 济南建站公司注意事项做钓鱼网站要什么工具
  • 网站建设数据录入创建网络公司
  • 行业网站建设报价摄影标志logo设计欣赏
  • 做reference的网站网站首页 模板
  • 微信php网站开发流程图做网站优化好的网络公司