当前位置:网站首页>torch.roll
torch.roll
2022-06-30 17:35:00 【GY-赵】
x = torch.arange(1,10).view(3,3)
print(x,"\n")
print(torch.roll(x,shifts=1,dims=0)) #shift 表示偏移几次 ,dim表示沿着哪个维度 这里dim=0表示行
print(torch.roll(x,shifts=1,dims=0)==torch.roll(x,shifts=4,dims=0)) #可见shift是可以循环计数,以3为周期
#参数可以是组合形式,表示先后进行沿着地dim 0 ,1先后偏移1行,1列 ,注意:shift是整体循环偏移,不是取代指定位置的值
torch.roll(x,shifts=(1,1),dims=(0,1))
输出
tensor([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
tensor([[7, 8, 9],
[1, 2, 3],
[4, 5, 6]])
tensor([[True, True, True],
[True, True, True],
[True, True, True]])
tensor([[9, 7, 8],
[3, 1, 2],
[6, 4, 5]])
x = torch.arange(1,10).view(3,3)
print(x,"\n")
print(torch.roll(x,shifts=1,dims=0)) #shift 正负表示正向偏移 和反向偏移
print(torch.roll(x,shifts=-1,dims=0))
输出
tensor([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
tensor([[7, 8, 9],
[1, 2, 3],
[4, 5, 6]])
tensor([[4, 5, 6],
[7, 8, 9],
[1, 2, 3]])
边栏推荐
- 如何利用AI技术优化独立站客服系统?听听专家怎么说!
- AI chief architect 10-aica-lanxiang, propeller frame design and core technology
- Tensorflow2 深度学习十必知
- 服务器之间传文件夹,文件夹内容为空
- Volcano engine was selected into the first "panorama of edge computing industry" in China
- Classic problem of leetcode dynamic programming (I)
- Multipass Chinese document - setting graphical interface
- 麻烦问下 Flink支持同步数据到 sqlserver么
- Tsinghua only ranks third? 2022 release of AI major ranking of Chinese Universities of soft science
- 分布式事务
猜你喜欢

Redis - persistent RDB and persistent AOF

Tsinghua only ranks third? 2022 release of AI major ranking of Chinese Universities of soft science

mysql for update 死锁问题排查

Multipass Chinese document - setting graphical interface

MySQL advanced - basic index and seven joins

OneFlow源码解析:算子签名的自动推断

autocad中文语言锁定只读警报怎么解决?

LeetCode动态规划经典题(一)

EasyNVR平台设备通道均在线,操作出现“网络请求失败”是什么原因?

教你30分钟快速搭建直播间
随机推荐
如何做好软件系统的需求调研,七种武器让你轻松搞定
程序员女友给我做了一个疲劳驾驶检测
[Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
PHP uses queues to solve maze problems
Summary of methods for offline installation of chrome extensions in China
Countdowncatch and completabilefuture and cyclicbarrier
「经验」浅谈聚类分析在工作中的应用
如何利用AI技术优化独立站客服系统?听听专家怎么说!
电子元器件行业在线采购系统精准匹配采购需求,撬动电子产业数字化发展
Optimize with netcorebeauty Net core independent deployment directory structure
国内离线安装 Chrome 扩展程序的方法总结
报名“互联网+”大赛华为云命题,诸多礼品任你拿!
Distributed transaction
MySQL n'a pas pu trouver MySQL. Solution temporaire pour le fichier Sock
系统集成项目管理工程师认证高频考点:编制项目范围管理计划
Rust 操控大疆可编程无人机 tello
Another CVPR 2022 paper was accused of plagiarism, and Ping An insurance researchers sued IBM Zurich team
英飞凌--GTM架构-Generic Timer Module
C WinForm program interface optimization example
autocad中文语言锁定只读警报怎么解决?