当前位置:网站首页>torch.roll()
torch.roll()
2022-08-05 02:33:00 【00000cj】
torch.roll(input, shifts, dims=None) -> Tensor
Definition
Scrolls the tensor input along the given dimension.Elements beyond the last position are reintroduced at the first position.If dims is None, the tensor will be flattened before rolling and then restored to its original shape.
Parameters
- input (Tensor) - input tensor
- shifts (int or tuple of python: ints) - The number of positions to shift the elements of the tensor.If shifts is a tuple, dims must be a tuple of the same size, with each dimension rolling the corresponding value
- dims (int or tuple of python: ints) - scroll along the dimension specified by dims
Example
import torchx = 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],# [twenty three],# [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],# [twenty one],# [4, 3]])Reference
边栏推荐
- Cloud Native (32) | Introduction to Platform Storage System in Kubernetes
- 1873. 计算特殊奖金
- Data storage practice based on left-order traversal
- [Decryption] Can the NFTs created by OpenSea for free appear in my wallet without being chained?
- 网络安全与元宇宙:找出薄弱环节
- 【genius_platform软件平台开发】第七十六讲:vs预处理器定义的牛逼写法!!!!(其他组牛逼conding人员告知这么配置来取消宏定义)
- Common hardware delays
- 编译预处理等细节
- 2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
- js中try...catch和finally的用法
猜你喜欢

lua learning

【OpenCV 图像处理2】:OpenCV 基础知识

C语言实现简单猜数字游戏
![02 [Development Server Resource Module]](/img/60/f77ed0bb0e5654c9dcd70b73a5bee8.png)
02 [Development Server Resource Module]

Apache DolphinScheduler, a new generation of distributed workflow task scheduling platform in practice - Medium

C language diary 9 3 kinds of statements of if

The design idea of DMicro, the Go microservice development framework

Matlab画图3

js中try...catch和finally的用法

在这个超连接的世界里,你的数据安全吗
随机推荐
LeetCode uses the minimum cost to climb the stairs----dp problem
C学生管理系统 指定位置插入学生节点
Industry case | insurance companies of the world's top 500 construction standards can be used to drive the business analysis system
C student management system Find student nodes based on student ID
matlab绘制用颜色表示模值大小的箭头图
mysql tree structure query problem
解决connect: The requested address is not valid in its context
Access Characteristics of Constructor under Inheritance Relationship
leetcode-对称二叉树
undo问题
数据增强Mixup原理与代码解读
【日常训练】1403. 非递增顺序的最小子序列
1667. 修复表中的名字
[ROS](10)ROS通信 —— 服务(Service)通信
SuperMap支持的国产环境汇总
关于#sql shell#的问题,如何解决?
STM32使用stm32cubemx LL库系列教程
LeetCode使用最小花费爬楼梯----dp问题
View handler stepping record
散列表的查找(哈希表)