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实现倒计时的示例

复制代码 代码如下:import timecount = 0 a = input('time:') b = a * 60 while (count <...

python实现多层感知器

python实现多层感知器

写了个多层感知器,用bp梯度下降更新,拟合正弦曲线,效果凑合。 # -*- coding: utf-8 -*- import numpy as np import matplotli...

Python 实现文件打包、上传与校验的方法

不多说,我们直接上源码: # -*- coding:UTF-8 -*- ''' 实现文件打包、上传与校验 Created on 2018年1月12日 @author: liuyazh...

python pandas 如何替换某列的一个值

python pandas 如何替换某列的一个值

摘要:本文主要是讲解怎么样替换某一列的一个值。 应用场景: 假如我们有以下的数据集: 我们想把里面不是pre的字符串全部换成Nonpre,我们要怎么做呢? 做法很简单。 df['c...

解决python3运行selenium下HTMLTestRunner报错的问题

修改HTMLTestRunner.py以支持python3+ 搜索到的结果整理 修改一: 在python shell里输入 >>>import HTMLTestRunn...