pytorch permute维度转换方法

yipeiwu_com6年前Python基础

permute

prediction = input.view(bs, self.num_anchors,
  self.bbox_attrs, in_h, in_w).permute(0, 1, 3, 4, 2).contiguous()

转置:

import torch

x = torch.linspace(1, 9, steps=9).view(3, 3)

b=x.permute(1,0)
print(b)
print(b.permute(1,0))

以上这篇pytorch permute维度转换方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python 带有参数的装饰器实例代码详解

demo.py(装饰器,带参数的装饰器): def set_level(level_num): def set_func(func): def call_func(*ar...

给Python初学者的一些编程技巧

交换变量   x = 6 y = 5 x, y = y, x print x >>> 5 print y >>> 6 if...

Python中tell()方法的使用详解

 tell()方法返回的文件内的文件读/写指针的当前位置。 语法 以下是tell()方法的语法: fileObject.tell() 参数  &nbs...

对Python中Iterator和Iterable的区别详解

Python中 list,truple,str,dict这些都可以被迭代,但他们并不是迭代器。为什么? 因为和迭代器相比有一个很大的不同,list/truple/map/dict这些数据...

python学习数据结构实例代码

在学习python的过程中,用来练习代码,并且复习数据结构的 #coding:utf-8 #author:Elvis class Stack(object): def _...