当前位置:网站首页>Channel Shuffle类
Channel Shuffle类
2022-06-12 11:45:00 【蛊惑one】
ShuffleNet 中引入了 channel shuffle, 用来进行不同分组的特征之间的信息流动, 以提高性能。而Detectron2使用的pytorch版本一般较低,没有channel shuffle这个类,因此编写这个轮子用于通道洗牌。实现了与1.11.0官方库相同的结果。
官方文档:ChannelShuffle — PyTorch 1.11.0 documentation
import torch
import torch.nn as nn
class ChannelShuffle(nn.Module):
def __init__(self, groups):
super(ChannelShuffle, self).__init__()
self.groups = groups
def forward(self, x):
B, C, H, W = x.shape
chnls_per_group = C // self.groups
assert C % self.groups == 0
x = x.view(B, self.groups, chnls_per_group, H, W) # 通道分组 (B,C,H,W)->(B,group,C,H,W)
x = torch.transpose(x, 1, 2).contiguous() # 通道洗牌
x = x.view(B, -1, H, W) # 重新展开为(B,C,H,W)
return x
channel_shuffle = ChannelShuffle(2)
input = torch.randn(1, 4, 2, 2)
print(input)
output = channel_shuffle(input)
print(output)边栏推荐
- Windows10安装mysql-8.0.28-winx64
- Promise controls the number of concurrent requests
- conda环境下pip install 无法安装到指定conda环境中(conda环境的默认pip安装位置)
- Problems in cross validation code of 10% discount
- UML系列文章(31)体系结构建模---部署图
- mysql的悲观锁和乐观锁
- The evil 203 in systemctl
- ARM处理器模式与寄存器
- JS to load and display Excel files
- 【QNX Hypervisor 2.2 用户手册】4 构建QNX Hypervisor系统
猜你喜欢

UML series articles (31) architecture modeling - deployment diagram

异步路径处理

Windows10 install mysql-8.0.28-winx64

Who moved my package lock

当自己有台服务器之后

PIP install in the CONDA environment cannot be installed into the specified CONDA environment (the default PIP installation location of the CONDA environment)

C# 35. 选择默认网卡

C# 35. Select default network card
![[Blue Bridge Cup SCM 11th National race]](/img/da/3c8a9efd5b28f67816f239531a0339.png)
[Blue Bridge Cup SCM 11th National race]

Video JS library uses custom components
随机推荐
Node crawler puppeter usage
First understand the onion model, analyze the implementation process of middleware, and analyze the source code of KOA Middleware
K59. Chapter 2 installing kubernetes V1.23 based on binary packages -- cluster deployment
Go sends SMS based on alicloud
QML学习 第二天
邻居子系统之ARP协议数据处理过程
K52. Chapter 1: installing kubernetes v1.22 based on kubeadm -- cluster deployment
Inter class and intra class relations in video classification -- regularization
【藍橋杯單片機 國賽 第十一届】
文件夹目录结构自动生成
ARM指令集之Load/Store访存指令(一)
Tpage design
7-5 复数四则运算
【蓝桥杯单片机 国赛 第十一届】
【深度学习基础】神经网络的学习(4)
Les humains veulent de l'argent, du pouvoir, de la beauté, de l'immortalité, du bonheur... Mais les tortues ne veulent être qu'une tortue.
5g NR Protocol Learning - - ts38.211 downlink channel
Who moved my package lock
NVIDIA Jetson Nano Developer Kit 入门
Doris records service interface calls