Safemotion Lib
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
fastreid.modeling.backbones.osnet.OSBlock Class Reference
Inheritance diagram for fastreid.modeling.backbones.osnet.OSBlock:

Public Member Functions

 __init__ (self, in_channels, out_channels, bn_norm, IN=False, bottleneck_reduction=4, **kwargs)
 
 forward (self, x)
 

Public Attributes

 conv1
 
 conv2a
 
 conv2b
 
 conv2c
 
 conv2d
 
 gate
 
 conv3
 
 downsample
 
 IN
 
 relu
 

Detailed Description

Omni-scale feature learning block.

Definition at line 229 of file osnet.py.

Constructor & Destructor Documentation

◆ __init__()

fastreid.modeling.backbones.osnet.OSBlock.__init__ ( self,
in_channels,
out_channels,
bn_norm,
IN = False,
bottleneck_reduction = 4,
** kwargs )

Definition at line 232 of file osnet.py.

240 ):
241 super(OSBlock, self).__init__()
242 mid_channels = out_channels // bottleneck_reduction
243 self.conv1 = Conv1x1(in_channels, mid_channels, bn_norm)
244 self.conv2a = LightConv3x3(mid_channels, mid_channels, bn_norm)
245 self.conv2b = nn.Sequential(
246 LightConv3x3(mid_channels, mid_channels, bn_norm),
247 LightConv3x3(mid_channels, mid_channels, bn_norm),
248 )
249 self.conv2c = nn.Sequential(
250 LightConv3x3(mid_channels, mid_channels, bn_norm),
251 LightConv3x3(mid_channels, mid_channels, bn_norm),
252 LightConv3x3(mid_channels, mid_channels, bn_norm),
253 )
254 self.conv2d = nn.Sequential(
255 LightConv3x3(mid_channels, mid_channels, bn_norm),
256 LightConv3x3(mid_channels, mid_channels, bn_norm),
257 LightConv3x3(mid_channels, mid_channels, bn_norm),
258 LightConv3x3(mid_channels, mid_channels, bn_norm),
259 )
260 self.gate = ChannelGate(mid_channels)
261 self.conv3 = Conv1x1Linear(mid_channels, out_channels, bn_norm)
262 self.downsample = None
263 if in_channels != out_channels:
264 self.downsample = Conv1x1Linear(in_channels, out_channels, bn_norm)
265 self.IN = None
266 if IN: self.IN = nn.InstanceNorm2d(out_channels, affine=True)
267 self.relu = nn.ReLU(True)
268

Member Function Documentation

◆ forward()

fastreid.modeling.backbones.osnet.OSBlock.forward ( self,
x )

Definition at line 269 of file osnet.py.

269 def forward(self, x):
270 identity = x
271 x1 = self.conv1(x)
272 x2a = self.conv2a(x1)
273 x2b = self.conv2b(x1)
274 x2c = self.conv2c(x1)
275 x2d = self.conv2d(x1)
276 x2 = self.gate(x2a) + self.gate(x2b) + self.gate(x2c) + self.gate(x2d)
277 x3 = self.conv3(x2)
278 if self.downsample is not None:
279 identity = self.downsample(identity)
280 out = x3 + identity
281 if self.IN is not None:
282 out = self.IN(out)
283 return self.relu(out)
284
285

Member Data Documentation

◆ conv1

fastreid.modeling.backbones.osnet.OSBlock.conv1

Definition at line 243 of file osnet.py.

◆ conv2a

fastreid.modeling.backbones.osnet.OSBlock.conv2a

Definition at line 244 of file osnet.py.

◆ conv2b

fastreid.modeling.backbones.osnet.OSBlock.conv2b

Definition at line 245 of file osnet.py.

◆ conv2c

fastreid.modeling.backbones.osnet.OSBlock.conv2c

Definition at line 249 of file osnet.py.

◆ conv2d

fastreid.modeling.backbones.osnet.OSBlock.conv2d

Definition at line 254 of file osnet.py.

◆ conv3

fastreid.modeling.backbones.osnet.OSBlock.conv3

Definition at line 261 of file osnet.py.

◆ downsample

fastreid.modeling.backbones.osnet.OSBlock.downsample

Definition at line 262 of file osnet.py.

◆ gate

fastreid.modeling.backbones.osnet.OSBlock.gate

Definition at line 260 of file osnet.py.

◆ IN

fastreid.modeling.backbones.osnet.OSBlock.IN

Definition at line 265 of file osnet.py.

◆ relu

fastreid.modeling.backbones.osnet.OSBlock.relu

Definition at line 267 of file osnet.py.


The documentation for this class was generated from the following file: