当前位置:网站首页>torch.roll()
torch.roll()
2022-08-05 02:32:00 【00000cj】
torch.roll(input, shifts, dims=None) -> Tensor
定义
沿给定维度滚动张量输入。超出最后一个位置的元素在第一个位置重新引入。如果 dims 为 None,则张量将在滚动前被展平,然后恢复到原始形状。
参数
- input (Tensor) - 输入张量
- shifts (int or tuple of python: ints) - 张量元素移动的位置数。如果 shifts 是元组,则 dims 必须是大小相同的元组,每个维度都会滚动对应的值
- dims (int or tuple of python: ints) - 沿着dims指定的维度进行滚动
示例
import torch
x = torch.tensor([1, 2, 3, 4, 5, 6, 7, 8]).view(4, 2)
print(x)
# tensor([[1, 2],
# [3, 4],
# [5, 6],
# [7, 8]])
x1 = torch.roll(x, 1)
print(x1)
# tensor([[8, 1],
# [2, 3],
# [4, 5],
# [6, 7]])
x2 = torch.roll(x, 1, 0)
print(x2)
# tensor([[7, 8],
# [1, 2],
# [3, 4],
# [5, 6]])
x3 = torch.roll(x, -1, 0)
print(x3)
# tensor([[3, 4],
# [5, 6],
# [7, 8],
# [1, 2]])
x4 = torch.roll(x, shifts=(2, 1), dims=(0, 1))
print(x4)
# tensor([[6, 5],
# [8, 7],
# [2, 1],
# [4, 3]])参考
边栏推荐
- Pisanix v0.2.0 发布|新增动态读写分离支持
- 01 [Foreword Basic Use Core Concepts]
- Using OpenVINO to implement the flying paddle version of the PGNet inference program
- 【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗
- “嘀哩哩,等灯等灯”,工厂安全生产的提示音
- 浅谈数据安全治理与隐私计算
- Industry case | insurance companies of the world's top 500 construction standards can be used to drive the business analysis system
- Go 微服务开发框架 DMicro 的设计思路
- "Dilili, wait for the lights, wait for the lights", the prompt sound for safe production in the factory
- 亚马逊云科技携手中科创达为行业客户构建AIoT平台
猜你喜欢

【解密】OpenSea免费创造的NFT都没上链竟能出现在我的钱包里?

正则表达式,匹配中间的某一段字符串
![[C language] Detailed explanation of stacks and queues (define, destroy, and data operations)](/img/7b/8b3f1e4f0000aa34fc1f8fff485765.png)
[C language] Detailed explanation of stacks and queues (define, destroy, and data operations)

The 2022 EdgeX China Challenge will be grandly opened on August 3

Unleashing the engine of technological innovation, Intel joins hands with ecological partners to promote the vigorous development of smart retail
![02 [Development Server Resource Module]](/img/60/f77ed0bb0e5654c9dcd70b73a5bee8.png)
02 [Development Server Resource Module]

KingbaseES V8 GIS data migration solution (2. Introduction to the capabilities of Kingbase GIS)

leetcode 15

Matlab map with color representation module value size arrow

Understand the recommendation system in one article: Recall 06: Two-tower model - model structure, training method, the recall model is a late fusion feature, and the sorting model is an early fusion
随机推荐
LPQ(局部相位量化)学习笔记
散列表的查找(哈希表)
蚁剑高级模块开发
线性表的查找
浅谈数据安全治理与隐私计算
DAY22:sqli-labs 靶场通关wp(Less01~~Less20)
领域驱动设计——MDD
SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型
Greenplum数据库故障分析——能对数据库base文件夹进行软连接嘛?
HOG特征学习笔记
常见的硬件延迟
正则表达式,匹配中间的某一段字符串
C student management system head to add a student node
行业案例|世界 500 强险企如何建设指标驱动的经营分析系统
重新审视分布式系统:永远不会有完美的一致性方案……
【C语言】详解栈和队列(定义、销毁、数据的操作)
Matlab画图3
Live preview | 30 minutes started quickly!Look at credible distributed AI chain oar architectural design
the mechanism of ideology
[深入研究4G/5G/6G专题-51]: URLLC-16-《3GPP URLLC相关协议、规范、技术原理深度解读》-11-高可靠性技术-2-链路自适应增强(根据无线链路状态动态选择高可靠性MCS)