当前位置:网站首页>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)
边栏推荐
- PostgreSQL 出现cross-database references are not implemented的bug
- Here comes Wi Fi 7. How strong is it?
- Kingbase export table structure
- My creation anniversary
- 我的创作纪念日
- c语言 --- 分支结构
- An annotation elegant implementation of interface data desensitization
- Technology cloud report: side B of mixed office: how to have both security and efficiency?
- Seura 2 test code summary
- Mobileone: the mobile terminal only needs 1ms of high-performance backbone
猜你喜欢

PostgreSQL 出现cross-database references are not implemented的bug

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

科班出身,结果外包都不要

基于xlsx的B+树索引实现

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

科技雲報道:混合辦公的B面:安全與效率如何兼得?

leetcode - 295. 数据流的中位数

多机局域网办公神器 rustdesk 使用强推!!!

Technology cloud report: side B of mixed office: how to have both security and efficiency?

Efficientnetv2 - get smaller models and faster training with NAS, scaling, and fused mbconv
随机推荐
Kingbase export table structure
为什么说测试岗位是巨坑?8年测试人告诉你千万别上当
Data statistical analysis (SPSS) [3]
Zhai Jia: from technical engineer to open source entrepreneur of "net red"
Baidu AI Cloud service grid product CSM release 𞓜 hot public beta
Libuv库概述及libevent、libev、libuv对比(转载)
智能视觉组比赛流程草案
How to back up all data on Apple mobile phone in 2 steps (free)
《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作
【新功能】Ambire 钱包集成了 Metis 网络
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
Nuxt - 每个页面单独设置 SEO 相关标签及网页标题、图标等(页面配置 head)
在命令行登录mysql数据库以及查看版本号
MobileOne: 移动端仅需1ms的高性能骨干
Data collection and management [3]
leetcode:304. 2D area and retrieval - matrix immutable
Binary tree serialization and deserialization (leetcode (difficult))
Whose encryption key is written in the code? (that's you)
Influence of air resistance on the trajectory of table tennis
大神们 在富函数的open中从mysql连接池里取连接 连接池初始化是20个 如果富函数的并行度是1