Safemotion Lib
Loading...
Searching...
No Matches
smreid
fastreid
layers
se_layer.py
Go to the documentation of this file.
1
# encoding: utf-8
2
"""
3
@author: liaoxingyu
4
@contact: sherlockliao01@gmail.com
5
"""
6
7
from
torch
import
nn
8
9
10
class
SELayer
(nn.Module):
11
def
__init__
(self, channel, reduction=16):
12
super(SELayer, self).
__init__
()
13
self.
avg_pool
= nn.AdaptiveAvgPool2d(1)
14
self.
fc
= nn.Sequential(
15
nn.Linear(channel, int(channel / reduction), bias=
False
),
16
nn.ReLU(inplace=
True
),
17
nn.Linear(int(channel / reduction), channel, bias=
False
),
18
nn.Sigmoid()
19
)
20
21
def
forward
(self, x):
22
b, c, _, _ = x.size()
23
y = self.
avg_pool
(x).view(b, c)
24
y = self.
fc
(y).view(b, c, 1, 1)
25
return
x * y.expand_as(x)
fastreid.layers.se_layer.SELayer
Definition
se_layer.py:10
fastreid.layers.se_layer.SELayer.forward
forward(self, x)
Definition
se_layer.py:21
fastreid.layers.se_layer.SELayer.fc
fc
Definition
se_layer.py:14
fastreid.layers.se_layer.SELayer.__init__
__init__(self, channel, reduction=16)
Definition
se_layer.py:11
fastreid.layers.se_layer.SELayer.avg_pool
avg_pool
Definition
se_layer.py:13
Generated by
1.10.0