当前位置:网站首页>torch. roll
torch. roll
2022-06-30 19:06:00 【Gy Zhao】
x = torch.arange(1,10).view(3,3)
print(x,"\n")
print(torch.roll(x,shifts=1,dims=0)) #shift Indicates the number of offsets ,dim Indicates which dimension to follow here dim=0 Said line
print(torch.roll(x,shifts=1,dims=0)==torch.roll(x,shifts=4,dims=0)) # so shift It can be counted circularly , With 3 For cycles
# The parameter can be a combination , It means to go along the ground successively dim 0 ,1 Sequential migration 1 That's ok ,1 Column , Be careful :shift Is the overall cycle offset , Does not replace the value of the specified position
torch.roll(x,shifts=(1,1),dims=(0,1))
Output
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 Positive and negative indicate positive offset And reverse offset
print(torch.roll(x,shifts=-1,dims=0))
Output
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]])
边栏推荐
- 4个技巧告诉你,如何使用SMS促进业务销售?
- Delete duplicate elements in the sorting linked list ii[unified operation of linked list nodes --dummyhead]
- 煤炭行业数智化供应商管理系统解决方案:数据驱动,供应商智慧平台助力企业降本增效
- GameFi链游系统开发NFT技术
- 华兴证券:混合云原生架构下的 Kitex 实践
- PyTorch学习(三)
- Tensorflow2 ten must know for deep learning
- mysql下载和安装详细教程
- 充值满赠,IM+RTC+X 全通信服务「回馈季」开启
- MRO工业品采购管理系统:赋能MRO企业采购各节点,构建数字化采购新体系
猜你喜欢

Swin-Transformer(2021-08)
Do you really understand the persistence mechanism of redis?

一点比较有意思的模块

System integration project management engineer certification high frequency examination site: prepare project scope management plan

CODING 正式入驻腾讯会议应用市场!

TCP packet sticking problem

Entry node of link in linked list - linked list topic

英飞凌--GTM架构-Generic Timer Module

Full recharge, im+rtc+x full communication service "feedback season" starts

Lenovo Yoga 27 2022, full upgrade of super configuration
随机推荐
Troubleshooting MySQL for update deadlock
NEON优化2:ARM优化高频指令总结
Countdowncatch and completabilefuture and cyclicbarrier
At present, the big guys are joining the two streams of flinksql, cdcmysql and Kafka, and the results are put into MySQL or KA
挑选智能音箱时,首选“智能”还是“音质”?这篇文章给你答案
The cloud native landing practice of using rainbow for Tuowei information
C# Winform程序界面优化实例
DTD modeling
ONEFLOW source code parsing: automatic inference of operator signature
ForkJoinPool
Geoffrey Hinton:我的五十年深度学习生涯与研究心法
mysql下载和安装详细教程
System integration project management engineer certification high frequency examination site: prepare project scope management plan
「经验」爬虫在工作中的实战应用『实现篇』
教你30分钟快速搭建直播间
煤炭行业数智化供应商管理系统解决方案:数据驱动,供应商智慧平台助力企业降本增效
sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户
「杂谈」如何改善数据分析工作中的三大被动局面
The easynvr platform equipment channels are all online. What is the reason for the "network request failure" in the operation?
屏幕显示技术进化史