当前位置:网站首页>Mécanisme d'attention du canal de fixation
Mécanisme d'attention du canal de fixation
2022-06-29 04:06:00 【Viatorsun】

Mécanisme d'attention basé sur les canaux De CVPR2018: Squeeze-and-Excitation Networks
Code officiel:https://github.com/hujie-frank/SENet

import numpy as np
import torch
from torch import nn
from torch.nn import init
class SEAttention(nn.Module):
def __init__(self, channel=512,reduction=16):
super().__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.se = nn.Sequential(nn.Linear(channel, channel // reduction, bias=False),
nn.ReLU(inplace=True),
nn.Linear(channel // reduction, channel, bias=False),
nn.Sigmoid() )
def init_weights(self):
for m in self.modules():
if isinstance(m, nn.Conv2d):
init.kaiming_normal_(m.weight, mode='fan_out')
if m.bias is not None:
init.constant_(m.bias, 0)
elif isinstance(m, nn.BatchNorm2d):
init.constant_(m.weight, 1)
init.constant_(m.bias, 0)
elif isinstance(m, nn.Linear):
init.normal_(m.weight, std=0.001)
if m.bias is not None:
init.constant_(m.bias, 0)
def forward(self, x):
b, c, _, _ = x.size()
y = self.avg_pool(x).view(b, c)
y = self.se(y).view(b, c, 1, 1)
return x * y.expand_as(x)
if __name__ == '__main__':
feature = torch.randn(50,512,7,7)
se = SEAttention(channel=512,reduction=8)
output = se(feature)
print(output.shape)
边栏推荐
- Data statistical analysis (SPSS) [3]
- 女程序员晒出5月的工资条:工资是高,但是真累,网友评论炸锅了
- Kingbase export table structure
- I came from a major, so I didn't want to outsource
- Runtimeerror in yolox: dataloader worker (PID (s) 17724, 1364, 18928) exited unexpectedly
- Distributed ID solution
- 请问大佬,Oracle CDC报错 Call snapshotState on closed sou
- 增额终身寿险下架了吗?现在还有哪些增额终身寿险产品?
- 【C语言】开启一个线程
- 我的创作纪念日
猜你喜欢

不使用union实现Mysql 列转行

Cloud native weekly | grafana 9 was officially released; The Chinese version of cloud native vocabulary is now online

MySQL复习资料(附加)case when

基于xlsx的B+树索引实现

HCIE-Security Day41:理论学习:信息收集与网络探测

Microsecond TCP timestamp

If you choose the right school, you can enter Huawei as a junior college. I wish I had known

谁家的加密密钥,写死在代码里?(说的就是你)

Ask the handler about the memory leak scenario in the interview. Don't just know static internal classes & weak references!

Anaconda自带的Spyder编辑器启动报错问题
随机推荐
Runtimeerror in yolox: dataloader worker (PID (s) 17724, 1364, 18928) exited unexpectedly
Data collection and management [3]
Logstash starts too slowly or even gets stuck
[new function] ambire wallet integrates Metis network
Error: schema validation failed with the following error: the data path '' should not have other properties (projects)
CANoe-如何在Trace窗口解析报文并显示信息(Program Node和结构体类型系统变量的使用)
How to merge upstream and downstream SQL data records
NotImplementedError: Could not run torchvision::nms
Analysis on the types of source code anti leakage technology
项目开发修养
微秒级 TCP 时间戳
Wi-Fi 7 来啦,它到底有多强?
MySQL can only add small tables when adding tables dynamically. If you increase the size of tables, you won't read data when running tasks. Is there any solution
Mobileone: the mobile terminal only needs 1ms of high-performance backbone
赚钱的5个层次,你在哪一层?
【C语言】 详解线程退出函数 pthread_exit
《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作
Vg4131sxxxn0s1 wireless module hardware specification
要不是和阿里P7聊过,我也不知道自己是个棒槌
【FPGA数学公式】使用FPGA实现常用数学公式