当前位置:网站首页>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)边栏推荐
- Record the pits encountered when using JPA
- C# 35. Select default network card
- B.刷墙(C语言)
- 視頻分類的類間和類內關系——正則化
- Inter class and intra class relations in video classification -- regularization
- ARM指令集之批量Load/Store指令
- 5G NR协议学习--TS38.211下行通道
- 多普勒效应的基本原理
- 人類想要擁有金錢、權力、美麗、永生、幸福……但海龜只想做一只海龜
- Video JS library uses custom components
猜你喜欢

First understand the onion model, analyze the implementation process of middleware, and analyze the source code of KOA Middleware

Rich text editor copying pictures in word documents

Unlimited growth, we will all go to the future | the 15th anniversary of the founding of InfoQ China

6.6 RL:MDP及奖励函数

Basic principle of Doppler effect

UML series articles (31) architecture modeling - deployment diagram

QML学习 第一天

当自己有台服务器之后

IP地址管理

Pytoch notes
随机推荐
Inter class and intra class relations in video classification -- regularization
PDSCH 相关
6.6 separate convolution
UML series articles (31) architecture modeling - deployment diagram
人类想要拥有金钱、权力、美丽、永生、幸福……但海龟只想做一只海龟
一个人必须不停地写作,才能不被茫茫人海淹没。
Spark common encapsulation classes
SSL引入原因及加密步骤
QML学习 第二天
K58. Chapter 1 installing kubernetes V1.23 based on kubeadm -- cluster deployment
Promise controls the number of concurrent requests
M-arch (fanwai 10) gd32l233 evaluation -spi drive DS1302
postman传入list
When you have a server
为什么新品发布上架之后会没有流量,新品应该怎么发布?
Face recognition PIP failed to install Dlib Library
K52. Chapter 1: installing kubernetes v1.22 based on kubeadm -- cluster deployment
Design of virtual scrolling list
机器学习之线性模型
【深度学习基础】反向传播法(1)