交换维度顺序

应用

>>> x = torch.randn(2, 3)
>>> x
tensor([[ 1.0028, -0.9893,  0.5809],[-0.1669,  0.7299,  0.4942]])
>>> torch.transpose(x, 0, 1)
tensor([[ 1.0028, -0.1669],[-0.9893,  0.7299],[ 0.5809,  0.4942]])

API

torch.transpose(input, dim0, dim1) → Tensor
参数 描述
input (Tensor) the input tensor.
dim0 (int) the first dimension to be transposed
dim1 (int) the second dimension to be transposed

参考:
https://pytorch.org/docs/stable/generated/torch.transpose.html#torch.transpose

pytorch torch.transpose相关推荐

  1. torch.transpose()

    首先transpose是为了转换矩阵维度的,在numpy和pytorch中的作用都是一样的,分别举例说明: arr = np.arange(24).reshape((2, 3, 4)) [[[ 0 1 ...

  2. PyTorch : torch.nn.xxx 和 torch.nn.functional.xxx

    PyTorch : torch.nn.xxx 和 torch.nn.functional.xxx 在写 PyTorch 代码时,我们会发现在 torch.nn.xxx 和 torch.nn.funct ...

  3. PyTorch | torch.linspace()创建均分数列张量 | torch.linspace()如何使用?| torch.linspace()使用方法 | torch.linspace例子

    公众号[计算机视觉联盟]后台回复[PyTorch]可以获得独家PyTorch学习教程pdf版 通过torch.linspace创建均分数列 张量 步长=(Start - end)/(Steps - 1 ...

  4. PyTorch | torch.full()使用方法 | torch.full()如何使用? torch.full()例子说明 | 通过torch.full创建全相同的张量

    公众号[计算机视觉联盟]后台回复[PyTorch]可以获得独家PyTorch学习教程pdf版 举例子说明torch.full()使用方法: t = torch.full((3,3),10)print( ...

  5. PyTorch | torch.zeros()如何使用?torch.zeros使用方法 | torch.zeros()例子

    公众号[计算机视觉联盟]后台回复[PyTorch]可以获得独家PyTorch学习教程pdf版 还是用实际例子比较明显 out_t = torch.tensor(([1]))t = torch.zero ...

  6. PyTorch | torch.randperm()使用方法

    公众号[计算机视觉联盟]后台回复[PyTorch]可以获得PyTorch学习教程pdf版 返回一个0~n-1的数组,随机打散的 t = torch.randperm(8) 结果: tensor([5, ...

  7. PytorchRuntimeError: inconsistent tensor sizes at /pytorch/torch/lib/TH/generic/THTensorMath.c:2709

    1.pytorch在得到dataset时没有问题,得到DataLoader时也没有问题,以batch size = 512遍历数据时,出现了: RuntimeError: inconsistent t ...

  8. 如何使用PyTorch torch.max()

    In this article, we'll take a look at using the PyTorch torch.max() function. 在本文中,我们将介绍如何使用PyTorch ...

  9. numpy.transpose和torch.transpose函数解析

    问题 今天在想把一个三维的[3, x, y]的tensor转为[x, y, 3]遇到一些问题,最后的解决方法是把tensor转为numpy,然后使用numpy.transpose(mytensor, ...

最新文章

  1. 《Adobe Premiere Pro CC经典教程(彩色版)》——2.2 建立项目
  2. 如果三十年前有这些AI技术,可可西里的悲剧不会发生
  3. SAP PM 入门系列14 – PM模块与其它模块的集成
  4. RNN循环神经网络的直观理解:基于TensorFlow的简单RNN例子
  5. 18个最新的极简主义风格网站
  6. Vue 深度监听和初始绑定
  7. Mongodb内存管理和使用情况情况查询
  8. [html] html和html5有什么区别呢?
  9. php抽象类继承抽象类,PHP面向对象程序设计高级特性详解(接口,继承,抽象类,析构,克隆等)...
  10. Selenium2+python自动化49-判断文本(text_to_be_present_in_element)
  11. python——redis
  12. 关于单反相机中的APS-C
  13. 近3年专著类计算机参考文献,参考文献著作类
  14. 极坐标格式下的二维傅里叶变换与逆变换推导
  15. maven命令创建支持eclipse的多模块maven项目
  16. 用动画做出一个正方体并且3d旋转,详解
  17. python 小说下载工具_Python制作全网小说下载器
  18. MFC中通过SendMessage修改Edit控件的文本
  19. 微信在线接口调试工具的使用
  20. 2、Ubuntu介绍加环境搭建详细教程

热门文章

  1. pix4d无人机影像处理_让无人机创造更大价值?你还差一个Pix4D培训会!
  2. 微课|玩转Python轻松过二级(2.1.4节):列表、元组、字典、集合概述
  3. 1000道Python题库系列分享十二(9道编程题)
  4. 1000道Python题库系列分享十一(9道)
  5. Python内置函数int()高级用法
  6. 使用Anaconda3配置多版本Python虚拟开发环境详细步骤
  7. Python泛型函数与单分发器
  8. Python+tkinter实现任意多层级关系的组合框
  9. 开多线程出现importerror_那些年让你迷惑的并行、并发、多线程、多进程、协程...
  10. 网络 网络层 | IP协议、网段划分、公网与私网、路由选择